-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
20.3.13
Description
Some context before:
Through this refactoring:
The lmdb-cache-store.ts file is now being re-exported.
When transpiled (see https://www.npmjs.com/package/@angular/build/v/21.0.3?activeTab=code):
var lmdb_cache_store_1 = require("./tools/esbuild/lmdb-cache-store");
Now, lmbd-cache-store.ts imports lmdb (which later on will be require('lmdb')):
| import { RootDatabase, open } from 'lmdb'; |
Where the problem starts:
Other files within this repository later on import stuff from @angular/build/private. Just as an example:
Which ends up being transpiled as (https://www.npmjs.com/package/@angular-devkit/build-angular/v/21.0.3?activeTab=code):
const private_1 = require("@angular/build/private");
So, assuming a simple script such as:
const devkit = require("@angular-devkit/build-angular");
const executeServerBuilder = devkit.executeServerBuilder;Will fail when run if lmdb is not installed (because of the chain of imports / requires).
Minimal Reproduction
Create a script such as the one mentioned above:
// index.js
const devkit = require("@angular-devkit/build-angular");
// Or anything that ends up loading `@angular/build/private`.
const executeServerBuilder = devkit.executeServerBuilder;- Start a new npm package or similar:
npm init -y - Install
@angular-devkit/build-angular, without installing the optional dependencies:npm i @angular-devkit/[email protected] --save-dev --omit optional. - Run the previous script, e.g.
node .ornode index.js.
Exception or Error
node:internal/modules/cjs/loader:1386
throw err;
^
Error: Cannot find module 'lmdb'
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI : 21.0.3
Node.js : 22.19.0
Package Manager : npm 10.9.3
Operating System : darwin arm64
┌───────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/build-angular │ 21.0.3 │ ^21.0.3 │
│ @angular/cli │ 21.0.3 │ ^21.0.3 │
└───────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response