phil_lgr
phil_lgr

Reputation: 372

Can I use ES6 modules (import export) to write webpack config files?

I started seeing:

(node:6420) Warning: require() of ES modules is not supported.

when starting my webpack build and was wondering if using all import export for webpack.config.js was supported yet.

edit 1: I want to know if it's supported without using @babel/register or other transforms

Upvotes: 2

Views: 1649

Answers (2)

deepMIn
deepMIn

Reputation: 29

If your code runs in Node, you can use the fs package to interact with the file system

Upvotes: 0

nickbullock
nickbullock

Reputation: 6589

Is is supported in Node 13. You can use either the .mjs extension (for files where you need to use import/export), or set "type": "module" in your package.json.

Upvotes: 1

Related Questions