diff --git a/src/utils/mergeOptions.ts b/src/utils/mergeOptions.ts index f2f86f76e61..8f8c2629a98 100644 --- a/src/utils/mergeOptions.ts +++ b/src/utils/mergeOptions.ts @@ -168,7 +168,7 @@ function addUnknownOptionErrors( function getCommandOptions(rawCommandOptions: GenericConfigObject): GenericConfigObject { const command = { ...rawCommandOptions }; - command.external = (rawCommandOptions.external || '').split(','); + command.external = rawCommandOptions.external ? rawCommandOptions.external.split(',') : []; if (rawCommandOptions.globals) { command.globals = Object.create(null); diff --git a/test/function/samples/empty-string-as-module-name/_config.js b/test/function/samples/empty-string-as-module-name/_config.js new file mode 100644 index 00000000000..dfbc2595b37 --- /dev/null +++ b/test/function/samples/empty-string-as-module-name/_config.js @@ -0,0 +1,15 @@ +module.exports = { + description: 'allows using empty string as a valid module name', + options: { + external: () => false, + plugins: [ + { + resolveId(importee, importer) { + if (importee === '') { + return importer + '#.js'; + } + } + } + ] + } +}; diff --git a/test/function/samples/empty-string-as-module-name/main.js b/test/function/samples/empty-string-as-module-name/main.js new file mode 100644 index 00000000000..29634821528 --- /dev/null +++ b/test/function/samples/empty-string-as-module-name/main.js @@ -0,0 +1,2 @@ +import { importee } from ''; +assert.strictEqual(importee, 'xxx'); diff --git a/test/function/samples/empty-string-as-module-name/main.js#.js b/test/function/samples/empty-string-as-module-name/main.js#.js new file mode 100644 index 00000000000..221b08850db --- /dev/null +++ b/test/function/samples/empty-string-as-module-name/main.js#.js @@ -0,0 +1 @@ +export var importee = 'xxx';