Skip to content

Commit

Permalink
Implements export statement rewriting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukejacksonn committed Dec 6, 2019
1 parent d27e528 commit 316a69e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
return {
visitor: {
ImportDeclaration: function(path, state) {
if (!path.node.source) return;
var source = path.node.source.value;
if (source.match(/^\.{0,2}\//) && !source.endsWith('.es.js')) {
path.replaceWith(
Expand All @@ -32,6 +33,19 @@ module.exports = {
);
}
},
ExportNamedDeclaration: function(path, state) {
if (!path.node.source) return;
const source = path.node.source.value;
if (source.match(/^\.{0,2}\//) && !source.endsWith('.es.js')) {
path.replaceWith(
types.exportNamedDeclaration(
path.node.declaration,
path.node.specifiers,
types.stringLiteral(source + '.es.js'),
),
);
}
},
},
};
},
Expand Down

0 comments on commit 316a69e

Please sign in to comment.