diff --git a/fixtures/js/hello_world.mjs b/fixtures/js/hello_world.mjs new file mode 100644 index 00000000..1b7393c1 --- /dev/null +++ b/fixtures/js/hello_world.mjs @@ -0,0 +1 @@ +document.getElementById('app').innerHTML = 'Hello World!'; \ No newline at end of file diff --git a/lib/config-generator.js b/lib/config-generator.js index 0c1927be..613ed6a0 100644 --- a/lib/config-generator.js +++ b/lib/config-generator.js @@ -92,7 +92,7 @@ class ConfigGenerator { config.stats = this.buildStatsConfig(); config.resolve = { - extensions: ['.js', '.jsx', '.vue', '.ts', '.tsx'], + extensions: ['.wasm', '.mjs', '.js', '.json', '.jsx', '.vue', '.ts', '.tsx'], alias: Object.assign({}, this.webpackConfig.aliases) }; diff --git a/test/functional.js b/test/functional.js index 72ff595e..4e70f258 100644 --- a/test/functional.js +++ b/test/functional.js @@ -1743,6 +1743,22 @@ module.exports = { done(); }); }); + + it('.mjs files are supported natively', (done) => { + const config = createWebpackConfig('web/build', 'dev'); + config.addEntry('main', './js/hello_world'); + config.setPublicPath('/build'); + + testSetup.runWebpack(config, (webpackAssert) => { + // check that main.js has the correct contents + webpackAssert.assertOutputFileContains( + 'main.js', + 'Hello World!' + ); + + done(); + }); + }); }); }); });