We are using padStart
.
To support earlier version of Node we are using babel and its @babel/preset-env
preset:
[
"@babel/preset-env",
{
targets: {
node: "6.11.5"
},
// Support padStart et cetera
useBuiltIns: "usage"
}
]
useBuiltIns
automatically brings in the padStart
polyfill.
This works when we include core-js
in our dependencies. This doesn't work when we include only @babel/polyfill
in our dependencies. This is the error message on deploy to Google Firebase Functions:
Cannot find module 'core-js/modules/es7.string.pad-start'
That message goes away when we explicitly install core-js
.
Why do we need to include core-js
explicitly when @babel/polyfill
includes it?
This is how we installed @babel/polyfill
and core-js
.
npm install @babel/polyfill --save
npm install core-js --save