Try loading webpack config as ESM
See original GitHub issueIs your feature request related to a problem? Please describe.
We are currently switching a few things to fully ESM with Node 16 (or trying it out at least) but got an error trying to use webpack config as full ESM.
[error] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /webpack.config.mjs
at new NodeError (node:internal/errors:329:5)
at Module.load (node:internal/modules/cjs/loader:970:11)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at resolveCustomWebpackConfig (..@angular-builders/custom-webpack/dist/custom-webpack-builder.js:47:33)
at Function.<anonymous> (..@angular-builders/custom-webpack/dist/custom-webpack-builder.js:26:46)
at Generator.next (<anonymous>)
at ..@angular-builders/custom-webpack/dist/custom-webpack-builder.js:8:71
at new Promise (<anonymous>)
Describe the solution you’d like
Maybe check if its a ES module before loading it.
Describe alternatives you’ve considered
Let’s discuss
Additional context
https://github.com/webpack/webpack-cli/releases/tag/webpack-cli%404.5.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ESM import on webpackConfig - Stack Overflow
I'm building a webpack app and I'm interested in use ESM through the entire app, meaning that build the webpack.config file with ESM...
Read more >How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >ECMAScript Modules - webpack
ECMAScript Modules (ESM) is a specification for using Modules in the Web. It's supported by all modern browsers and the recommended way of...
Read more >Lazy Loading | webpack
Let's try something different. We'll add an interaction to log some text to the console when the user clicks a button. However, we'll...
Read more >Externals - webpack
config.js indicates that the module jquery in import $ from 'jquery' should be excluded from bundling. In order to replace this module ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing this in favor of #1101
Ok, I’ll leave this issue open with a low priority in case someone has time to play around with it.