Do I need to include import "babel-polyfill"
to the top of each entry file, or is it enough to have babel-polyfill
rule just in webpack.config file? I am confused by polyfill docs and still getting following error: only one instance of babel-polyfill is allowed
My webpack.config in short:
entry1: ['babel-polyfill', 'homepage.js'],
entry2: ['babel-polyfill', 'not-homepage.js'],
entry3: ['babel-polyfill', 'contacts.js']
You are getting the error because you are calling multiple instances of the babel-polyfill.
You can choose any of the two option, but not both.
If you use webpack, don't put separate entries pointing to separate files, but rather point to a directory.
E.g: If your files are in app/js
module.exports = {
entry: ['babel-polyfill', './app/js']
};
If you decide to import it, make sure you import/require it only once at the entry-point to your application, before anything else is called.