Created
June 2, 2016 01:56
-
-
Save futurist/ff44cfebbaf1ed4b56d88c04e3b8e0e5 to your computer and use it in GitHub Desktop.
fix es3 compatibility for exports default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ref: http://www.aliued.com/?p=3240 | |
// babel-template.js file, line 124 to add below: | |
if (replacement) { | |
replacement[TEMPLATE_SKIP] = true; | |
path.replaceInline(replacement); | |
// fix es3 compatibility: | |
// exports.default -> exports["default"] | |
var pnode = path.parent | |
if(t.isMemberExpression(pnode)){ | |
var prop = pnode.property; | |
if (!pnode.computed && t.isIdentifier(prop) && !t.isValidIdentifier(prop.name)) { | |
pnode.property = t.stringLiteral(prop.name); | |
pnode.computed = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment