Skip to content

Commit

Permalink
Throw error if no files were found
Browse files Browse the repository at this point in the history
BREAKING CHANGES: The plugin now throws an error for dynamic variable
imports if the directory that they are loading from is empty.
  • Loading branch information
koddsson committed Oct 13, 2023
1 parent a0ceb4a commit d41a503
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/dynamic-import-vars/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
r.startsWith('./') || r.startsWith('../') ? r : `./${r}`
);

if (paths.length === 0) {
this.error(
new Error('No files found when trying to dynamically load concatted string')
);
}

// create magic string if it wasn't created already
ms = ms || new MagicString(code);
// unpack variable dynamic import into a function with import statements per file, rollup
Expand Down

0 comments on commit d41a503

Please sign in to comment.