Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the empty string importee should not always be treated as external module id #2733

Merged
merged 2 commits into from Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/mergeOptions.ts
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions test/function/samples/empty-string-as-module-name/_config.js
@@ -0,0 +1,15 @@
module.exports = {
LongTengDao marked this conversation as resolved.
Show resolved Hide resolved
description: 'allows using empty string as a valid module name',
LongTengDao marked this conversation as resolved.
Show resolved Hide resolved
options: {
LongTengDao marked this conversation as resolved.
Show resolved Hide resolved
external: () => false,
plugins: [
{
resolveId(importee, importer) {
if (importee === '') {
return importer + '#.js';
}
}
}
]
}
};
2 changes: 2 additions & 0 deletions test/function/samples/empty-string-as-module-name/main.js
@@ -0,0 +1,2 @@
import { importee } from '';
assert.strictEqual(importee, 'xxx');
LongTengDao marked this conversation as resolved.
Show resolved Hide resolved
@@ -0,0 +1 @@
export var importee = 'xxx';