Description
Command
serve
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
19.2.1
Description
The bug is here: https://github.com/angular/angular-cli/pull/29753/files#diff-725bf17eb0a0bed74c9aaca5f4c4ff2b2239a664a4baac4b29a43d961069adf7
Previously, the call to setExternalMetadata
contained everything included in angular.json "target.build.options.externalDependencies". It no longer does.
If I add for instance
"externalDependencies": [
"class-transformer",
"class-validator"
],
to my angular.json, and add a console.log right before the call to setExternalMetadata
in @angular/build/src/builders/application/execute-build.js
like this:
19.2.1
const { externalConfiguration, externalImports: { browser, server }, } = bundlingResult;
const implicitBrowser = browser ? [...browser] : [];
const implicitServer = server ? [...server] : [];
// TODO: Implement wildcard externalConfiguration filtering
console.log('External configuration: ', externalConfiguration);
// ==> ['class-transformer', 'class-validator']
executionResult.setExternalMetadata(externalConfiguration
? implicitBrowser.filter((value) => !externalConfiguration.includes(value))
: implicitBrowser, externalConfiguration
? implicitServer.filter((value) => !externalConfiguration.includes(value))
: implicitServer, externalConfiguration);
19.2.2
const exclusionsPrefixes = externalConfiguration.map((exclusion) => exclusion + '/');
const exclusions = new Set(externalConfiguration);
const explicitExternal = new Set();
...
console.log('External configuration: ', bundlingResult.externalConfiguration, [...explicitExternal]);
// ==> ['class-transformer', 'class-validator'], []
executionResult.setExternalMetadata(implicitBrowser, implicitServer, [...explicitExternal]);
I can see that buildingResult.externalConfiguration
contains my externalDependencies, but [...explicitExternal]
does not.
It seems that the change tries to collect known dependencies on client or server side and checks the result agains the externalDependencies. But if the dependencies are not known ahead of time, it will ignore them in the output. This makes SSR configurations using frameworks like NestJS hard to use.
Minimal Reproduction
Example repo:
https://github.com/OysteinAmundsen/home
Try to bun install && bun start
- it works fine.
Try to upgrade @angular-devkit/build-angular to 19.2.2 and bun install && bun start
. It breaks with
Exception or Error
Could not resolve "class-transformer"
Your Environment
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 19.2.6
Node: 22.14.0
Package Manager: npm 10.9.2
OS: win32 x64
Angular: 19.2.5
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1902.1
@angular-devkit/build-angular 19.2.1
@angular-devkit/core 19.2.6
@angular-devkit/schematics 19.2.6
@angular/cli 19.2.6
@angular/ssr 19.2.6
@schematics/angular 19.2.6
rxjs 7.8.2
typescript 5.7.3
zone.js 0.15.0
Anything else relevant?
No response