From 57b7218151e1dc36130e809f6d15412f667a8e65 Mon Sep 17 00:00:00 2001 From: addisonbeck Date: Fri, 15 Aug 2025 11:23:21 -0400 Subject: [PATCH] nx: add a project.json to @bitwarden/common This commit adds Nx integration to @bitwarden/common using the nx:run-script executor as a temporary facade. This approach allows us to get 'nx build @bitwarden/common' commands working immediately without requiring architectural changes to resolve circular dependencies and cross-library coupling. IMPORTANT: This is intentionally a hack solution. The real benefits of Nx (proper dependency boundaries, build optimization, accurate dependency graph, tree-shaking friendly architecture) require fixing the underlying circular dependencies between @bitwarden/common, state-test-utils, and key-management libraries first. When properly implemented, the project.json will likely use: - @nx/js:tsc executor instead of nx:run-script - Proper dependsOn configuration for build dependencies - Clean sourceRoot and include/exclude patterns - Elimination of the ../key-management/src/index.ts cross-library include - Resolution of the circular dependency chain Even as a facade, this gives us immediate workflow benefits: unified 'nx build' commands across the monorepo, Nx caching and parallelization for existing scripts, and dependency graph visualization. It also establishes the project.json structure and Nx patterns we'll need when we tackle the architectural refactoring. This lets the team start using Nx commands today while we work on the harder problem of untangling library dependencies in the background. --- libs/common/project.json | 41 +++++++++++++++++++++++++++++++++++ libs/common/tsconfig.lib.json | 10 +++++++++ 2 files changed, 51 insertions(+) create mode 100644 libs/common/project.json create mode 100644 libs/common/tsconfig.lib.json diff --git a/libs/common/project.json b/libs/common/project.json new file mode 100644 index 00000000000..848bcd73c20 --- /dev/null +++ b/libs/common/project.json @@ -0,0 +1,41 @@ +{ + "name": "@bitwarden/common", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/common/src", + "projectType": "library", + "tags": ["scope:common", "type:lib"], + "targets": { + "build": { + "executor": "nx:run-script", + "dependsOn": [], + "options": { + "script": "build" + } + }, + "build:watch": { + "executor": "nx:run-script", + "options": { + "script": "build:watch" + } + }, + "clean": { + "executor": "nx:run-script", + "options": { + "script": "clean" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/common/**/*.ts"] + } + }, + "test": { + "executor": "nx:run-script", + "options": { + "script": "test" + } + } + } +} diff --git a/libs/common/tsconfig.lib.json b/libs/common/tsconfig.lib.json new file mode 100644 index 00000000000..f752320e586 --- /dev/null +++ b/libs/common/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"], + "exclude": ["jest.config.js", "src/**/*.spec.ts", "**/*.stories.ts"] +}