From ac1782e36814837cb5c78bf66fa9337ece96d966 Mon Sep 17 00:00:00 2001 From: Timothy Asquith Date: Tue, 25 Feb 2020 10:52:55 +1100 Subject: [PATCH 1/4] Missing exports errors now print the importing module Prior to this change, we only printed the imported module that failed, with no context on which module was attempting the import. This could be difficult to debug in large codebases, especially when importing commonly-used modules. --- src/Module.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Module.ts b/src/Module.ts index 2e194f552e9..0b0bc181840 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -157,7 +157,9 @@ function handleMissingExport( return importingModule.error( { code: 'MISSING_EXPORT', - message: `'${exportName}' is not exported by ${relativeId(importedModule)}`, + message: `'${exportName}' is not exported by ${relativeId( + importedModule + )}, importing module: ${importingModule.id}`, url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` }, importerStart! From 3d081e53c9ebec81d82cdf5f4a208cb6b302bbca Mon Sep 17 00:00:00 2001 From: Timothy Asquith Date: Fri, 28 Feb 2020 17:19:40 +1100 Subject: [PATCH 2/4] rephrase missing export message The phrasing attempts to match the "imported by" style elsewhere in the codebase --- src/Module.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module.ts b/src/Module.ts index 0b0bc181840..fb4fb654987 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -157,9 +157,9 @@ function handleMissingExport( return importingModule.error( { code: 'MISSING_EXPORT', - message: `'${exportName}' is not exported by ${relativeId( - importedModule - )}, importing module: ${importingModule.id}`, + message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${ + importingModule.id + }`, url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` }, importerStart! From 532610c7b309b96cd580fb016fae6074f292323c Mon Sep 17 00:00:00 2001 From: Timothy Asquith Date: Sat, 29 Feb 2020 09:40:41 +1100 Subject: [PATCH 3/4] Tests now expect new missing export message format --- test/function/samples/circular-missed-reexports-2/_config.js | 2 +- test/function/samples/default-not-reexported/_config.js | 2 +- .../_config.js | 2 +- test/function/samples/import-of-unexported-fails/_config.js | 2 +- test/function/samples/reexport-missing-error/_config.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/function/samples/circular-missed-reexports-2/_config.js b/test/function/samples/circular-missed-reexports-2/_config.js index df2bf9004dd..e17a190410c 100644 --- a/test/function/samples/circular-missed-reexports-2/_config.js +++ b/test/function/samples/circular-missed-reexports-2/_config.js @@ -16,7 +16,7 @@ module.exports = { file: path.resolve(__dirname, 'dep2.js'), line: 1 }, - message: "'doesNotExist' is not exported by dep1.js", + message: "'doesNotExist' is not exported by dep1.js, imported by dep2.js", pos: 9, url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module', watchFiles: [ diff --git a/test/function/samples/default-not-reexported/_config.js b/test/function/samples/default-not-reexported/_config.js index 947141dbbbb..be866dd0b30 100644 --- a/test/function/samples/default-not-reexported/_config.js +++ b/test/function/samples/default-not-reexported/_config.js @@ -4,7 +4,7 @@ module.exports = { description: 'default export is not re-exported with export *', error: { code: 'MISSING_EXPORT', - message: `'default' is not exported by foo.js`, + message: `'default' is not exported by foo.js, imported by main.js`, pos: 7, watchFiles: [ path.resolve(__dirname, 'main.js'), diff --git a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js index 23001b3ba56..58c2caa9550 100644 --- a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js +++ b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js @@ -20,7 +20,7 @@ module.exports = { }, error: { code: 'MISSING_EXPORT', - message: `'default' is not exported by empty.js`, + message: `'default' is not exported by empty.js, imported by main.js`, pos: 44, watchFiles: [path.resolve(__dirname, 'main.js'), path.resolve(__dirname, 'empty.js')], loc: { diff --git a/test/function/samples/import-of-unexported-fails/_config.js b/test/function/samples/import-of-unexported-fails/_config.js index 0db25ac0ad5..6f5fa5552b2 100644 --- a/test/function/samples/import-of-unexported-fails/_config.js +++ b/test/function/samples/import-of-unexported-fails/_config.js @@ -4,7 +4,7 @@ module.exports = { description: 'marking an imported, but unexported, identifier should throw', error: { code: 'MISSING_EXPORT', - message: `'default' is not exported by empty.js`, + message: `'default' is not exported by empty.js, imported by main.js`, pos: 7, watchFiles: [path.resolve(__dirname, 'main.js'), path.resolve(__dirname, 'empty.js')], loc: { diff --git a/test/function/samples/reexport-missing-error/_config.js b/test/function/samples/reexport-missing-error/_config.js index 032dc7b3c7e..5a17f6c2bd5 100644 --- a/test/function/samples/reexport-missing-error/_config.js +++ b/test/function/samples/reexport-missing-error/_config.js @@ -4,7 +4,7 @@ module.exports = { description: 'reexporting a missing identifier should print an error', error: { code: 'MISSING_EXPORT', - message: `'foo' is not exported by empty.js`, + message: `'foo' is not exported by empty.js, imported by main.js`, pos: 9, watchFiles: [path.resolve(__dirname, 'main.js'), path.resolve(__dirname, 'empty.js')], loc: { From 9c8764c1ef1eb42584c3c3fa0c2da5f70ef9eaf1 Mon Sep 17 00:00:00 2001 From: Timothy Asquith Date: Sat, 29 Feb 2020 09:40:58 +1100 Subject: [PATCH 4/4] Use relative module id when displaying missing export message --- src/Module.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module.ts b/src/Module.ts index fb4fb654987..c7dd98a9d4e 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -157,9 +157,9 @@ function handleMissingExport( return importingModule.error( { code: 'MISSING_EXPORT', - message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${ - importingModule.id - }`, + message: `'${exportName}' is not exported by ${relativeId( + importedModule + )}, imported by ${relativeId(importingModule.id)}`, url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module` }, importerStart!