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
No response
Description
Dear Angular Team,
We are experiencing an issue with external dependencies when using Angular 19. In our project, we utilize importmap to load external dependencies and have a custom registry hook for resolving these dependencies on our SSR server. However, we encounter an error when attempting to build the project in version 19.
Causes of the Issue:
-
Dependency Filtering:
- This part of the code (https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/application/execute-build.ts#L160) only retains Node.js dependencies for the server, leading to issues with external dependencies.
-
Prerendering:
- Even though we do not have prerender routes, this section (https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/application/execute-post-bundle.ts#L133) attempts to call the prerender hook, resulting in an error.
- We are unable to set partialSSRBuild as it is an internal variable, and appShellOptions and prerenderOptions are set by default when outputMode is specified.
-
Custom Hook:
- Custom load hook (https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.ts) does not load dependencies as expected.
Minimal Reproduction
https://stackblitz.com/edit/stackblitz-starters-iudtwvic?file=package.json
npm run build.
Exception or Error
Your Environment
Angular CLI: 19.0.4
Node: 20.13.1
Package Manager: npm 10.5.2
OS: darwin arm64
Angular: 19.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1900.4
@angular-devkit/build-angular 19.0.4
@angular-devkit/core 19.0.4
@angular-devkit/schematics 19.0.4
@angular/cdk 19.0.2
@angular/cli 19.0.4
@angular/ssr 19.0.4
@schematics/angular 19.0.4
rxjs 7.8.1
typescript 5.6.3
zone.js 0.15.0
Possible Solutions
-
Expose partialSSRBuild Configuration:
- Allow developers to manually configure or override the partialSSRBuild setting. This would provide more control over the build process and help accommodate projects with custom SSR requirements.
-
Enhance or Extend Custom Hook:
- Modify or extend the existing custom hook to better handle dependency resolution. This could involve implementing functionality similar to that discussed in this issue (SSR: Native Federation and Node.js Remote Loading angular-architects/module-federation-plugin#622). Specifically, enabling dynamic loading and resolution of dependencies that are not present in the initial bundle.