From 96df0fc331b2a729410c328c5975d430a750a4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:12:52 +0800 Subject: [PATCH 1/6] Create main.js --- test/function/samples/avoid-variable-be-empty/main.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/function/samples/avoid-variable-be-empty/main.js diff --git a/test/function/samples/avoid-variable-be-empty/main.js b/test/function/samples/avoid-variable-be-empty/main.js new file mode 100644 index 00000000000..7f810d3f328 --- /dev/null +++ b/test/function/samples/avoid-variable-be-empty/main.js @@ -0,0 +1 @@ +export default 0; From bb89fac24e647521e5f5a83cfdc2b5e34956bb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:31:17 +0800 Subject: [PATCH 2/6] Create _config.js --- .../avoid-variable-be-empty/_config.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/function/samples/avoid-variable-be-empty/_config.js diff --git a/test/function/samples/avoid-variable-be-empty/_config.js b/test/function/samples/avoid-variable-be-empty/_config.js new file mode 100644 index 00000000000..97a04cce087 --- /dev/null +++ b/test/function/samples/avoid-variable-be-empty/_config.js @@ -0,0 +1,20 @@ +module.exports = { + description: 'avoid variable from empty module name be empty', + options: { + input: '', + plugins: [ + { + resolveId (importee) { + if ( importee==='' ) { return ''; } + }, + load (path) { + if ( path==='' ) { return 'export default 0;'; } + }, + } + ], + output: { + format: 'cjs', + exports: 'default' + } + } +}; From 70bca7eac9dc46f1d6d2953fc8144c3273a9d83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:32:15 +0800 Subject: [PATCH 3/6] Update _config.js --- test/function/samples/avoid-variable-be-empty/_config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/function/samples/avoid-variable-be-empty/_config.js b/test/function/samples/avoid-variable-be-empty/_config.js index 97a04cce087..22318ca3420 100644 --- a/test/function/samples/avoid-variable-be-empty/_config.js +++ b/test/function/samples/avoid-variable-be-empty/_config.js @@ -5,10 +5,10 @@ module.exports = { plugins: [ { resolveId (importee) { - if ( importee==='' ) { return ''; } + return ''; }, load (path) { - if ( path==='' ) { return 'export default 0;'; } + return 'export default 0;'; }, } ], From 2a2eca05af85c62a6daa192eabff2d8bb5c7c324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:32:29 +0800 Subject: [PATCH 4/6] Update _config.js --- test/function/samples/avoid-variable-be-empty/_config.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/function/samples/avoid-variable-be-empty/_config.js b/test/function/samples/avoid-variable-be-empty/_config.js index 22318ca3420..9571570ca02 100644 --- a/test/function/samples/avoid-variable-be-empty/_config.js +++ b/test/function/samples/avoid-variable-be-empty/_config.js @@ -13,8 +13,7 @@ module.exports = { } ], output: { - format: 'cjs', - exports: 'default' + format: 'cjs' } } }; From 51e688dda928349bd1623421a99095469ce95297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:32:42 +0800 Subject: [PATCH 5/6] Delete main.js --- test/function/samples/avoid-variable-be-empty/main.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/function/samples/avoid-variable-be-empty/main.js diff --git a/test/function/samples/avoid-variable-be-empty/main.js b/test/function/samples/avoid-variable-be-empty/main.js deleted file mode 100644 index 7f810d3f328..00000000000 --- a/test/function/samples/avoid-variable-be-empty/main.js +++ /dev/null @@ -1 +0,0 @@ -export default 0; From 886583840899ed50ea22d8f26257de76200e5c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E8=85=BE=E9=81=93?= Date: Mon, 5 Aug 2019 19:41:42 +0800 Subject: [PATCH 6/6] Update identifierHelpers.ts --- src/utils/identifierHelpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/identifierHelpers.ts b/src/utils/identifierHelpers.ts index 3b603eb1a31..38463f07be5 100644 --- a/src/utils/identifierHelpers.ts +++ b/src/utils/identifierHelpers.ts @@ -24,5 +24,5 @@ export function makeLegal(str: string): string { if (startsWithDigit(str) || blacklisted[str]) str = `_${str}`; - return str; + return str || '_'; }