Skip to content

Commit 0b70abd

Browse files
committed
fix: @putout/plugin-nodejs: convert-commonjs-to-esm: exports: ExportDefaultSpecifier -> ExportNamespaceSpecifier: stage 1 (https://github.com/tc39/proposal-export-default-from)
1 parent 47d4eb4 commit 0b70abd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
export print from './print';
4-
export parse from './parse';
5-
export generate from './generate';
6-
export template from './template';
3+
export * as print from './print';
4+
export * as parse from './parse';
5+
export * as generate from './generate';
6+
export * as template from './template';

packages/plugin-nodejs/lib/convert-commonjs-to-esm-exports/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const {
88
isObjectExpression,
99
isStringLiteral,
1010
isImportDefaultSpecifier,
11-
exportDefaultSpecifier,
11+
exportNamespaceSpecifier,
1212
} = types;
1313

1414
const {replaceWith} = operator;
@@ -107,7 +107,10 @@ function addExportToBinding(name, path) {
107107
if (isImportDefaultSpecifier(bindingPath)) {
108108
const {local} = bindingPath.node;
109109
const {source} = bindingPath.parentPath.node;
110-
const exportNode = exportNamedDeclaration(null, [exportDefaultSpecifier(local, local)], source);
110+
const specifiers = [
111+
exportNamespaceSpecifier(local),
112+
];
113+
const exportNode = exportNamedDeclaration(null, specifiers, source);
111114

112115
replaceWith(bindingPath.parentPath, exportNode);
113116
return '';

0 commit comments

Comments
 (0)