1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

fix(basic-lib generator): Ensure all project.json files have a rootDir value (#16384)

* fix(nx): add rootDir to existing project.json files

The @nx/js:tsc executor was creating builds with a structural mismatch where TypeScript
output files lived in a nested src/ directory, but package.json pointed to non-existent
dist/ paths. This caused "Cannot find module" errors throughout the dependency chain.

This fix adds the rootDir configuration to flatten the build output structure and updates
all package.json main/types fields to match the actual file locations.

Changes applied systematically across all affected libraries:
• Added "rootDir": "libs/{name}/src" to project.json build options
• Updated package.json "main" from "dist/index.js" to "index.js"
• Updated package.json "types" from "dist/index.d.ts" to "index.d.ts"

* fix(nx-plugin): set rootDir for any newly generated libs

The basic-lib generator was creating new libraries with the same package.json path bugs
that we just fixed in existing libraries. Without this template fix, any newly generated
library would inherit the broken configuration pattern.

Updated the generator templates to include:
• Added rootDir configuration to project.json template
• Fixed package.json template paths to use flattened structure
• Corrected template syntax bug (missing space in <%= name %>)

This ensures all future libraries created with "nx generate @bitwarden/nx-plugin:basic-lib"
will have proper build configuration from the start, preventing regression of the
systematic rootDir issue.
This commit is contained in:
Addison Beck
2025-09-22 12:32:23 -04:00
committed by GitHub
parent 3f14fdc62d
commit b481063810
30 changed files with 60 additions and 45 deletions

View File

@@ -4,8 +4,8 @@
"description": "Assets used in Bitwarden clients",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "ui-foundation",
"scripts": {

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/assets",
"main": "libs/assets/src/index.ts",
"tsConfig": "libs/assets/tsconfig.lib.json",
"assets": ["libs/assets/*.md"]
"assets": ["libs/assets/*.md"],
"rootDir": "libs/assets/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Exports the ClientType enum",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/client-type",
"main": "libs/client-type/src/index.ts",
"tsConfig": "libs/client-type/tsconfig.lib.json",
"assets": ["libs/client-type/*.md"]
"assets": ["libs/client-type/*.md"],
"rootDir": "libs/client-type/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Async test tools for state and clients",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/core-test-utils",
"main": "libs/core-test-utils/src/index.ts",
"tsConfig": "libs/core-test-utils/tsconfig.lib.json",
"assets": ["libs/core-test-utils/*.md"]
"assets": ["libs/core-test-utils/*.md"],
"rootDir": "libs/core-test-utils/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Guid utilities extracted from common",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/guid",
"main": "libs/guid/src/index.ts",
"tsConfig": "libs/guid/tsconfig.lib.json",
"assets": ["libs/guid/*.md"]
"assets": ["libs/guid/*.md"],
"rootDir": "libs/guid/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Logging primitives",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/logging",
"main": "libs/logging/src/index.ts",
"tsConfig": "libs/logging/tsconfig.lib.json",
"assets": ["libs/logging/*.md"]
"assets": ["libs/logging/*.md"],
"rootDir": "libs/logging/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Services for sending and recieving messages from different contexts of the same application.",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/messaging",
"main": "libs/messaging/src/index.ts",
"tsConfig": "libs/messaging/tsconfig.lib.json",
"assets": ["libs/messaging/*.md"]
"assets": ["libs/messaging/*.md"],
"rootDir": "libs/messaging/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Custom Nx tools like generators and executors for Bitwarden projects",
"private": true,
"type": "commonjs",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "Platform",
"generators": "./generators.json"

View File

@@ -34,7 +34,8 @@
"glob": "executors.json",
"output": "."
}
]
],
"rootDir": "libs/nx-plugin/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "<%= description %>",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "<%= team %>"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/<%= name %>",
"main": "libs/<%= name %>/src/index.ts",
"tsConfig": "libs/<%= name %>/tsconfig.lib.json",
"assets": ["libs/<%= name%>/*.md"]
"assets": ["libs/<%= name %>/*.md"],
"rootDir": "libs/<%= name %>/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Core serialization utilities",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/serialization",
"main": "libs/serialization/src/index.ts",
"tsConfig": "libs/serialization/tsconfig.lib.json",
"assets": ["libs/serialization/*.md"]
"assets": ["libs/serialization/*.md"],
"rootDir": "libs/serialization/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "The internal parts of @bitwarden/state that should not be used by other teams.",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/state-internal",
"main": "libs/state-internal/src/index.ts",
"tsConfig": "libs/state-internal/tsconfig.lib.json",
"assets": ["libs/state-internal/*.md"]
"assets": ["libs/state-internal/*.md"],
"rootDir": "libs/state-internal/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Test utilities and fakes for state management",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/state-test-utils",
"main": "libs/state-test-utils/src/index.ts",
"tsConfig": "libs/state-test-utils/tsconfig.lib.json",
"assets": ["libs/state-test-utils/*.md"]
"assets": ["libs/state-test-utils/*.md"],
"rootDir": "libs/state-test-utils/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Centralized application state management",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/state",
"main": "libs/state/src/index.ts",
"tsConfig": "libs/state/tsconfig.lib.json",
"assets": ["libs/state/*.md"]
"assets": ["libs/state/*.md"],
"rootDir": "libs/state/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Abstractions over storage APIs",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/storage-core",
"main": "libs/storage-core/src/index.ts",
"tsConfig": "libs/storage-core/tsconfig.lib.json",
"assets": ["libs/storage-core/*.md"]
"assets": ["libs/storage-core/*.md"],
"rootDir": "libs/storage-core/src"
}
},
"lint": {

View File

@@ -4,8 +4,8 @@
"description": "Test tools for the storage library",
"private": true,
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "platform"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/storage-test-utils",
"main": "libs/storage-test-utils/src/index.ts",
"tsConfig": "libs/storage-test-utils/tsconfig.lib.json",
"assets": ["libs/storage-test-utils/*.md"]
"assets": ["libs/storage-test-utils/*.md"],
"rootDir": "libs/storage-test-utils/src"
}
},
"lint": {

View File

@@ -3,8 +3,8 @@
"version": "0.0.0",
"description": "The very basic concept that constitutes a user, this needs to be very low level to facilitate Platform keeping their own code low level.",
"type": "commonjs",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "index.js",
"types": "index.d.ts",
"license": "GPL-3.0",
"author": "auth"
}

View File

@@ -12,7 +12,8 @@
"outputPath": "dist/libs/user-core",
"main": "libs/user-core/src/index.ts",
"tsConfig": "libs/user-core/tsconfig.lib.json",
"assets": ["libs/user-core/*.md"]
"assets": ["libs/user-core/*.md"],
"rootDir": "libs/user-core/src"
}
},
"test": {