From 880d7fb003cd07001c373231971be6cc7a2b1f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Wed, 18 Oct 2023 09:59:55 +0200 Subject: [PATCH] update error message with more context --- packages/dynamic-import-vars/src/index.js | 4 +++- .../test/rollup-plugin-dynamic-import-vars.test.js | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/dynamic-import-vars/src/index.js b/packages/dynamic-import-vars/src/index.js index b0d60df96..3d631b729 100644 --- a/packages/dynamic-import-vars/src/index.js +++ b/packages/dynamic-import-vars/src/index.js @@ -57,7 +57,9 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile if (errorWhenNoFilesFound && paths.length === 0) { this.error( - new Error('No files found when trying to dynamically load concatted string') + new Error( + `No files found in ${glob} when trying to dynamically load concatted string from ${id}` + ) ); } diff --git a/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js b/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js index 68be487af..6a0ae9448 100644 --- a/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js +++ b/packages/dynamic-import-vars/test/rollup-plugin-dynamic-import-vars.test.js @@ -225,7 +225,13 @@ test('throws if no files in dir when option is set', async (t) => { input: 'fixture-no-files.js', plugins: [dynamicImportVars({ errorWhenNoFilesFound: true })] }); - } catch (_) { + } catch (error) { + t.deepEqual( + error.message, + `No files found in ./module-dir-c/*.js when trying to dynamically load concatted string from ${require.resolve( + './fixtures/fixture-no-files.js' + )}` + ); thrown = true; } t.true(thrown);