use require() in .mjs bundles - Angular 13

713 Views Asked by At

I recently upgraded my project to Angular 13, I noticed that the new ng-packgr 13 bundles in .mjs extension by default. I have lots of code that uses require() to import some static assets and files. I can change them to import() but is there any other way to switch back to classic .js extension using ng-packagr?

Another reason is, I have some require() which imports dynamic files from node_modules only upon installation of certain packages. With require() it's not giving a compile error but with import it's expecting the file to be present.

0

There are 0 best solutions below