Import instead of require for es6.promise
sheerun opened this issue · comments
I use both babel and babel-preset-env beta.2.
My .babelrc:
{
"presets": [
["env", {
"target": {
"node": "4"
},
"useBuiltIns": "usage",
"debug": true
}]
]
}
Resulting start of compiled .js file:
#!/usr/bin/env node
"use strict";
import "babel-polyfill/lib/core-js/modules/es6.promise";
require("babel-polyfill/lib/core-js/modules/es6.symbol");
require("babel-polyfill/lib/core-js/modules/web.dom.iterable");
require("babel-polyfill/lib/regenerator-runtime/runtime");
require("babel-polyfill/lib/core-js/modules/es6.string.starts-with");
I suspect this might be because regenerator-runtime is added? But really, I have no idea.
Here's minimal .js file to reproduce this issue:
const { startsWith } = require('lodash')
async function main () { }
it seems that both async and destruction are needed to trigger this
Seems like a bug, could you create a simple repository with the reproduced issue? It always help with looking into reported issues faster.
Here you go.. https://github.com/sheerun/babel-bug-repro
It is probably fixed by babel/babel#6304, I'll check
It may have been babel/babel#6230, but the other one hasn't been released yet. That said, this definitely should use the babel-helper-module-imports
that was added in that PR, so I'd say we should wait on this until beta.3
is released, then this can be updated to use that helper and we can publish a beta.3 of preset-env
This issue has been moved to babel/babel#6601.