From df5e118da4a58f1472826654e8b6baf777d7c08f Mon Sep 17 00:00:00 2001 From: alreadyExisted Date: Thu, 25 Apr 2019 18:58:20 +0300 Subject: [PATCH 1/2] fix(mjs): remove unused namespace build errors --- .../HarmonyExportImportedSpecifierDependency.js | 5 ++--- lib/dependencies/HarmonyImportSpecifierDependency.js | 5 ++--- test/cases/mjs/cjs-import-default/errors.js | 9 --------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 19642ddff24..1183dc54256 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -355,12 +355,11 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { // It's not an harmony module if ( this.originModule.buildMeta.strictHarmonyModule && + this._id && this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = this._id - ? `the named export '${this._id}'` - : "the namespace object"; + const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( `Can't reexport ${exportName} from non EcmaScript module (only default export is available)` diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 9f681a6f312..76b9e2410bc 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -80,12 +80,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { // It's not an harmony module if ( this.originModule.buildMeta.strictHarmonyModule && + this._id && this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = this._id - ? `the named export '${this._id}'` - : "the namespace object"; + const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( `Can't import ${exportName} from non EcmaScript module (only default export is available)` diff --git a/test/cases/mjs/cjs-import-default/errors.js b/test/cases/mjs/cjs-import-default/errors.js index 5e0f6e01254..49b98a34e6a 100644 --- a/test/cases/mjs/cjs-import-default/errors.js +++ b/test/cases/mjs/cjs-import-default/errors.js @@ -1,19 +1,10 @@ module.exports = [ - [ - /Can't import the namespace object from non EcmaScript module \(only default export is available\)/ - ], - [ - /Can't import the namespace object from non EcmaScript module \(only default export is available\)/ - ], [ /Can't import the named export 'data' from non EcmaScript module \(only default export is available\)/ ], [ /Can't import the named export 'data' from non EcmaScript module \(only default export is available\)/ ], - [ - /Can't reexport the namespace object from non EcmaScript module \(only default export is available\)/ - ], [ /Can't reexport the named export 'data' from non EcmaScript module \(only default export is available\)/ ] From 8d5ad83b3274029e37386dbd5d0c64d8102bcd6f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 20 May 2019 09:45:56 +0200 Subject: [PATCH 2/2] simplify code --- lib/dependencies/HarmonyExportImportedSpecifierDependency.js | 3 +-- lib/dependencies/HarmonyImportSpecifierDependency.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 1183dc54256..15429b6ed75 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -359,10 +359,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( - `Can't reexport ${exportName} from non EcmaScript module (only default export is available)` + `Can't reexport the named export '${this._id}' from non EcmaScript module (only default export is available)` ) ]; } diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 76b9e2410bc..d07fbf1cadc 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -84,10 +84,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { this._id !== "default" ) { // In strict harmony modules we only support the default export - const exportName = `the named export '${this._id}'`; return [ new HarmonyLinkingError( - `Can't import ${exportName} from non EcmaScript module (only default export is available)` + `Can't import the named export '${this._id}' from non EcmaScript module (only default export is available)` ) ]; }