From 44a23bb5839795f33065e50d231ea9341c5ce7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Wed, 7 Aug 2019 13:57:09 +0800 Subject: [PATCH] Avoid generate .* thing (#3034) * Update getExportBlock.ts * Create _config.js * Create main.js * Update _config.js * Update _config.js * Update _config.js * Update main.js * Update main.js * Update main.js --- src/finalisers/shared/getExportBlock.ts | 2 +- .../samples/avoid-exports-dot-asterisk/_config.js | 9 +++++++++ test/function/samples/avoid-exports-dot-asterisk/main.js | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test/function/samples/avoid-exports-dot-asterisk/_config.js create mode 100644 test/function/samples/avoid-exports-dot-asterisk/main.js diff --git a/src/finalisers/shared/getExportBlock.ts b/src/finalisers/shared/getExportBlock.ts index 679274d22ac..05beb20173c 100644 --- a/src/finalisers/shared/getExportBlock.ts +++ b/src/finalisers/shared/getExportBlock.ts @@ -27,7 +27,7 @@ export default function getExportBlock( if (!dep.reexports) return false; return dep.reexports.some(expt => { if (expt.reexported === 'default') { - local = dep.namedExportsMode ? `${dep.name}.${expt.imported}` : dep.name; + local = dep.namedExportsMode && expt.imported !== '*' ? `${dep.name}.${expt.imported}` : dep.name; return true; } return false; diff --git a/test/function/samples/avoid-exports-dot-asterisk/_config.js b/test/function/samples/avoid-exports-dot-asterisk/_config.js new file mode 100644 index 00000000000..76470f6f02d --- /dev/null +++ b/test/function/samples/avoid-exports-dot-asterisk/_config.js @@ -0,0 +1,9 @@ +module.exports = { + description: 'avoid return or set module.exports to dot-asterisk style', + options: { + external: () => true, + output: { + format: 'cjs' + } + } +}; diff --git a/test/function/samples/avoid-exports-dot-asterisk/main.js b/test/function/samples/avoid-exports-dot-asterisk/main.js new file mode 100644 index 00000000000..4feb2566d99 --- /dev/null +++ b/test/function/samples/avoid-exports-dot-asterisk/main.js @@ -0,0 +1,2 @@ +import * as path from 'path'; +export { path as default };