The entry point for my code starts with the following imports:
import 'source-map-support/register';
import 'babel-polyfill';
console.log('polyfill included?', global._babelPolyfill);
[...]
However, when running I see that global._babelPolyfill
is undefined
.
I also notice that in my transpiled code, there is no require('babel-polyfill')
.
Why is that?
My guess is that babel thinks that babel-polyfill
is not required. However, when I don't include it, I get the following error:
ReferenceError: regeneratorRuntime is not defined
at /opt/node-modules/my-module/node_modules/dependency/promise.js:9:57
at Object.<anonymous> (/opt/node-modules/my-module/node_modules/dependency/promise.js:35:2)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/node-modules/fio/src/file.js:1:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
[...]
So I definitely need it. My guess is that somehow the dependency (another node module I am importing later in my code) is not configured correctly and that when babel transpiles my code it does not detect that, so it still figures babel-polyfill is not required.
I would love actual documentation to back-up actually why that is if that is indeed the case.
UPDATE on why this is not the same as another question: The accepted solution is to use babel-polyfill, but I'm already doing it. My question is why babel-polyfill is not being imported in my transpiled code and therefore not available in my run code.