symfony / webpack-encore

A simple but powerful API for processing & compiling assets built around Webpack
https://symfony.com/doc/current/frontend.html
MIT License
2.23k stars 199 forks source link

Using type module breaks preset-env polyfills #1337

Open m10 opened 2 months ago

m10 commented 2 months ago

When using Webpack Encore in a project with "type": "module" in package.json the resulting bundle file contains require calls which include the polyfills through @babel/preset-env. These should have been replaced by wepack with the file contents. This problem does not occur when using a simple plain webpack config.

Removing "type": "module" (and rewriting the config as commonjs) the issue is not present.

Reproduction repository: https://github.com/m10/encore-type-module Also see branch "commonjs" for a working version without type module: https://github.com/m10/encore-type-module/tree/commonjs and the branch "webpack" for a working version with type module but without encore, using a simple webpack config instead: https://github.com/m10/encore-type-module/tree/webpack