Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commonjs): Improve error message for unsupported dynamic requires
- Loading branch information
1 parent
800667b
commit 627f801
Showing
5 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/function/unsupported-dynamic-require/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'throws for unsupported dynamic require calls' | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/commonjs/test/fixtures/function/unsupported-dynamic-require/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
t.throws(() => require(getRequireTarget()), { | ||
message: | ||
'Could not dynamically require "foo-bar". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.' | ||
}); | ||
|
||
function getRequireTarget() { | ||
return 'foo-bar'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.