Skip to content

Instantly share code, notes, and snippets.

@futurist
Created June 2, 2016 01:56
Show Gist options
  • Save futurist/ff44cfebbaf1ed4b56d88c04e3b8e0e5 to your computer and use it in GitHub Desktop.
Save futurist/ff44cfebbaf1ed4b56d88c04e3b8e0e5 to your computer and use it in GitHub Desktop.
fix es3 compatibility for exports default
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