Skip to content

esbuild: Dynamic require of "./app.module-CHKXMOKU.js" is not supported #26332

@Burgov

Description

@Burgov

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

No

Description

I've been trying to migrate to esbuild for a while now, but I keep getting stuck on this issue: everything builds fine, but any require statement in my code (for example for lazy loaded routes) results in the following error:

Dynamic require of "./category-page.module-7XEIW7T3.js" is not supported

For this particular error, the piece of code in my source that causes the issue is:

  {
    path: 'category',
    loadChildren: () => import('./category/category-page/category-page.module').then(m => m.CategoryPageModule),
  },

And it happens when I try to navigate to the /category route.

In my tsconfig, I have the following settings (among other):

    "target": "ES2022",
    "module": "esnext",
    "moduleResolution": "node",

and I don't really know what else to look at.

There's clearly some setting wrong, because I'm unable to reproduce this in any other scenario.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.0
Node: 18.17.1
Package Manager: npm 9.8.1
OS: darwin arm64

Angular: 17.0.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.0
@angular-devkit/build-angular   17.0.0
@angular-devkit/core            17.0.0
@angular-devkit/schematics      17.0.0
@angular/cdk                    17.0.0
@angular/cli                    17.0.0
@angular/fire                   16.0.0
@angular/google-maps            17.0.0
@angular/material               17.0.0
@angular/ssr                    17.0.0
@schematics/angular             17.0.0
rxjs                            7.8.1
typescript                      5.2.2
webpack                         5.88.2
zone.js                         0.14.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions