Skip to content

Commit 316a69e

Browse files
committed
Implements export statement rewriting
1 parent d27e528 commit 316a69e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.babelrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports = {
2222
return {
2323
visitor: {
2424
ImportDeclaration: function(path, state) {
25+
if (!path.node.source) return;
2526
var source = path.node.source.value;
2627
if (source.match(/^\.{0,2}\//) && !source.endsWith('.es.js')) {
2728
path.replaceWith(
@@ -32,6 +33,19 @@ module.exports = {
3233
);
3334
}
3435
},
36+
ExportNamedDeclaration: function(path, state) {
37+
if (!path.node.source) return;
38+
const source = path.node.source.value;
39+
if (source.match(/^\.{0,2}\//) && !source.endsWith('.es.js')) {
40+
path.replaceWith(
41+
types.exportNamedDeclaration(
42+
path.node.declaration,
43+
path.node.specifiers,
44+
types.stringLiteral(source + '.es.js'),
45+
),
46+
);
47+
}
48+
},
3549
},
3650
};
3751
},

0 commit comments

Comments
 (0)