Skip to content

Commit 321a9a3

Browse files
committed
Throw error if no files were found
1 parent 42b17cc commit 321a9a3

File tree

1 file changed

+7
-1
lines changed
  • packages/dynamic-import-vars/src

1 file changed

+7
-1
lines changed

packages/dynamic-import-vars/src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createFilter } from '@rollup/pluginutils';
99

1010
import { dynamicImportToGlob, VariableDynamicImportError } from './dynamic-import-to-glob';
1111

12-
function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
12+
function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFilesFound } = {}) {
1313
const filter = createFilter(include, exclude);
1414

1515
return {
@@ -55,6 +55,12 @@ function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
5555
r.startsWith('./') || r.startsWith('../') ? r : `./${r}`
5656
);
5757

58+
if (errorWhenNoFilesFound && paths.length === 0) {
59+
this.error(
60+
new Error('No files found when trying to dynamically load concatted string')
61+
);
62+
}
63+
5864
// create magic string if it wasn't created already
5965
ms = ms || new MagicString(code);
6066
// unpack variable dynamic import into a function with import statements per file, rollup

0 commit comments

Comments
 (0)