Skip to content

No longer includes externalDependencies in esbuild exclusions #30048

Closed

Description

@OysteinAmundsen

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

Activity

  1. alan-agius4 commented on Apr 7, 2025

    @alan-agius4
    Collaborator

    I tried to take a look at the project provided, but the project doesn't build

    Application bundle generation failed. [4.103 seconds]
    
    ✘ [ERROR] TS2688: Cannot find type definition file for 'Multer'.
      The file is in the program because:
        Entry point of type library 'Multer' specified in compilerOptions [plugin angular-compiler]
    
    
    ✘ [ERROR] TS2694: Namespace 'global.Express' has no exported member 'Multer'. [plugin angular-compiler]
    
        apps/backend/src/app/transcribe/transcribe.controller.ts:17:44:
          17 │   transscribe(@UploadedFile() file: Express.Multer.File) {
             ╵                                             ~~~~~~
    
  2. OysteinAmundsen commented on Apr 7, 2025

    @OysteinAmundsen
    Author

    Sorry about that @alan-agius4. Some missing typeRoots got lost here, nescessary on linux but obviously not required on windows.
    Project runs as it should now.

  3. self-assigned this
    on Apr 8, 2025
  4. added
    freq1: low
    on Apr 8, 2025
  5. added theissue type on Apr 8, 2025
  6. added a commit that references this issue on Apr 8, 2025
    6fb0e0b
  7. added a commit that references this issue on Apr 10, 2025
    a297c41
  8. added a commit that references this issue on Apr 10, 2025
    6e6315d
  9. angular-automatic-lock-bot commented on May 11, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions