Skip to content

Commit 7cedfae

Browse files
authored
fix(commonjs): change dynamicRequireRoot to normalizedDynamicRequireRoot && tweak related tests (#1508)
1 parent 8af989a commit 7cedfae

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/commonjs/src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ export default function commonjs(options = {}) {
140140
!isEsModule && (dynamicRequireModules.has(normalizedId) || strictRequiresFilter(id));
141141

142142
const checkDynamicRequire = (position) => {
143-
const normalizedRequireRoot = normalizePathSlashes(dynamicRequireRoot);
143+
const normalizedDynamicRequireRoot = normalizePathSlashes(dynamicRequireRoot);
144144

145-
if (normalizedId.indexOf(normalizedRequireRoot) !== 0) {
145+
if (normalizedId.indexOf(normalizedDynamicRequireRoot) !== 0) {
146146
this.error(
147147
{
148148
code: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT',
149149
normalizedId,
150-
dynamicRequireRoot,
151-
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedRequireRoot}". You should set dynamicRequireRoot to "${dirname(
150+
normalizedDynamicRequireRoot,
151+
message: `"${normalizedId}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${normalizedDynamicRequireRoot}". You should set dynamicRequireRoot to "${dirname(
152152
normalizedId
153153
)}" or one of its parent directories.`
154154
},

packages/commonjs/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ test('throws when there is a dynamic require from outside dynamicRequireRoot', a
733733
t.like(error, {
734734
message: `"${id}" contains dynamic require statements but it is not within the current dynamicRequireRoot "${dynamicRequireRoot}". You should set dynamicRequireRoot to "${minimalDynamicRequireRoot}" or one of its parent directories.`,
735735
pluginCode: 'DYNAMIC_REQUIRE_OUTSIDE_ROOT',
736-
id,
737-
dynamicRequireRoot
736+
normalizedId: id,
737+
normalizedDynamicRequireRoot: dynamicRequireRoot
738738
});
739739
});
740740

0 commit comments

Comments
 (0)