-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
This is a feature request (even if that the behavior was not expected).
I'm creating a JavaScript application for MediaWiki. They are using an old JavaScript parser (I don't exactly know its support). default is an expected keyword.
Input Code
import test from "foo"
test()Output
var _foo = require("foo")
var _foo2 = _interopRequireDefault(_foo)
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj}
^^^^^
}
(0, _foo2.default)()
^^^^^MediaWiki parser will throw a parser error due to the default keywords.
As a workaround i'm adding an additional compilation step:
browserify -d -t [ babelify ] src/index.js -o dist/pre-script.js
babel --plugins transform-es3-modules-literals dist/pre-script.js --out-file dist/script.jsI can't use the plugin in the first pass because the helpers are not transpiled.
Babel Configuration (.babelrc, package.json, cli command)
{
"presets": ["es2015"],
"comments": false,
"minified": true,
"retainLines": false,
"sourceMaps": "map"
}Expected Behavior
Transpile helpers.
Current Behavior
Not transpiling helpers.
Possible Solution
This is not an easy issue. We could use the plugin ordering capability to let Babel know what feature are used in the helpers. Then if it detect the transform-es3-modules-literals plugin Babel could apply the transformation to helpers as well.
Context
I might be the only one with that issue. I'm OK with my current workaround but I still created the issue because this is maybe something to consider in the future.
Your Environment
| software | version(s) |
|---|---|
| Babel | 6.24.1 (babel-core 6.25.0) |
| MediaWiki | < 1.30 |