Webpack 2 not working on IE11?

I have a very simple javascript project that uses webpack (^ 2.6.0) as a module. There is one dependency as a provider module, and I have one entry point. My configuration is as follows:

const path = require('path'); const webpack = require('webpack'); module.exports = { entry: { bundle: './modules/main.js', vendor: ['react'] }, output: { path: path.join(__dirname, 'build'), filename: '[name].js', chunkFilename: '[id].js' }, plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: "vendor" }) ] }; 

This creates bundle.js and vendor.js . The vendor package also contains the webpack-bootstrap code, which loads before any of my modules load. Now, indicating that the bootstrap code indicates that in line 40 the web packet generated

 /******/ var resolvedPromise = new Promise(function(resolve) { resolve(); }); 

Unfortunately, Promise is not available in IE11, and even if you include a polyfill that includes Promise (like import 'babel-polyfill' ) as the first thing at the entry point or even as your own entry point, it will never be executed before running the bootstrap code, which means that I cannot use this code in IE11 unless I manually enable Promise-polyfill in front of my webpack packages. Not surprisingly, IE11 throws a Promise is not defined error before I get any code or even a vendor package.

Am I missing something or is this the expected behavior? I cannot find anything in webpack docs to counter this problem.

+5
source share
2 answers

It seems that the problem is related to webpack 2.6.0, the error has already been released: https://github.com/webpack/webpack/issues/4916

+4
source

I had a similar problem when switching to babel 7. I did not specify the useBuiltIns key so that the poly-regiments were not applied.

"useBuiltIns": "usage" is an important line that I was missing.

"debug": true also really helped in determining which polyfields were applied

 { "presets": [ [ "@babel/preset-env", { "targets": { "browsers": ["IE >= 11"] }, "useBuiltIns": "usage", "debug": true } ], "@babel/preset-react" ], "plugins": [ "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-proposal-class-properties", "@babel/plugin-transform-classes" ], "ignore": ["/node_modules/*"] } 
0
source

Source: https://habr.com/ru/post/1268187/


All Articles