#Runtime error with esbuild: Dynamic require of "./category-page.module-7XEIW7T3.js" is not supported

2 messages · Page 1 of 1 (latest)

little minnow
#

I've created a ticket in Github for this (https://github.com/angular/angular-cli/issues/26332), but maybe someone in here can tell me what I'm doing wrong.

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.

GitHub

CLI tool for Angular. Contribute to angular/angular-cli development by creating an account on GitHub.

normal rock
#

I have no idea, but if I were in this position, I'd create a brand new project, with the same version of Angular and the CLI as the one you're using, and I'd compare the files of the generated project (angular.json, tsconfig files, etc.)