Skip to content

Commit 6868e4a

Browse files
committed
Add __esModule property to exports object
Fixes: node-fetch#442
1 parent c01a5d2 commit 6868e4a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

build/babel-plugin.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ module.exports = ({ types: t }) => ({
2929
)
3030
)
3131
),
32+
t.expressionStatement(
33+
t.callExpression(
34+
t.memberExpression(
35+
t.identifier('Object'), t.identifier('defineProperty')),
36+
[
37+
t.identifier('exports'),
38+
t.stringLiteral('__esModule'),
39+
t.objectExpression([
40+
t.objectProperty(t.identifier('value'), t.booleanLiteral(true))
41+
])
42+
]
43+
)
44+
),
3245
t.expressionStatement(
3346
t.assignmentExpression('=',
3447
expr.node.left, t.identifier('exports')

build/rollup-plugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function tweakDefault() {
77
var matches = /^(exports(?:\['default']|\.default)) = (.*);$/.exec(line);
88
if (matches) {
99
lines[i] = 'module.exports = exports = ' + matches[2] + ';\n' +
10+
'Object.defineProperty(exports, "__esModule", { value: true });\n' +
1011
matches[1] + ' = exports;';
1112
break;
1213
}

0 commit comments

Comments
 (0)