@rollup/plugin-commonjs 21.0.0 → 21.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.es.js +12 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +15 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -455,7 +455,7 @@ function getDynamicRequirePaths(patterns) {
|
|
|
455
455
|
for (const pattern of !patterns || Array.isArray(patterns) ? patterns || [] : [patterns]) {
|
|
456
456
|
const isNegated = pattern.startsWith('!');
|
|
457
457
|
const modifySet = Set.prototype[isNegated ? 'delete' : 'add'].bind(dynamicRequireModuleSet);
|
|
458
|
-
for (const path$1 of glob__default[
|
|
458
|
+
for (const path$1 of glob__default["default"].sync(isNegated ? pattern.substr(1) : pattern)) {
|
|
459
459
|
modifySet(normalizePathSlashes(path.resolve(path$1)));
|
|
460
460
|
if (isDirectory(path$1)) {
|
|
461
461
|
modifySet(normalizePathSlashes(path.resolve(path.join(path$1, getPackageEntryPoint(path$1)))));
|
|
@@ -595,7 +595,7 @@ function getResolveId(extensions) {
|
|
|
595
595
|
return undefined;
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
return function resolveId(importee, rawImporter) {
|
|
598
|
+
return function resolveId(importee, rawImporter, resolveOptions) {
|
|
599
599
|
if (isWrappedId(importee, MODULE_SUFFIX) || isWrappedId(importee, EXPORTS_SUFFIX)) {
|
|
600
600
|
return importee;
|
|
601
601
|
}
|
|
@@ -638,10 +638,16 @@ function getResolveId(extensions) {
|
|
|
638
638
|
return null;
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
-
return this.resolve(
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
641
|
+
return this.resolve(
|
|
642
|
+
importee,
|
|
643
|
+
importer,
|
|
644
|
+
Object.assign({}, resolveOptions, {
|
|
645
|
+
skipSelf: true,
|
|
646
|
+
custom: Object.assign({}, resolveOptions.custom, {
|
|
647
|
+
'node-resolve': { isRequire: isProxyModule || isRequiredModule }
|
|
648
|
+
})
|
|
649
|
+
})
|
|
650
|
+
).then((resolved) => {
|
|
645
651
|
if (!resolved) {
|
|
646
652
|
resolved = resolveExtensions(importee, importer);
|
|
647
653
|
}
|
|
@@ -1187,7 +1193,7 @@ function transformCommonjs(
|
|
|
1187
1193
|
defaultIsModuleExports
|
|
1188
1194
|
) {
|
|
1189
1195
|
const ast = astCache || tryParse(parse, code, id);
|
|
1190
|
-
const magicString = new MagicString__default[
|
|
1196
|
+
const magicString = new MagicString__default["default"](code);
|
|
1191
1197
|
const uses = {
|
|
1192
1198
|
module: false,
|
|
1193
1199
|
exports: false,
|
|
@@ -1446,7 +1452,7 @@ function transformCommonjs(
|
|
|
1446
1452
|
return;
|
|
1447
1453
|
case 'Identifier': {
|
|
1448
1454
|
const { name } = node;
|
|
1449
|
-
if (!(isReference__default[
|
|
1455
|
+
if (!(isReference__default["default"](node, parent) && !scope.contains(name))) return;
|
|
1450
1456
|
switch (name) {
|
|
1451
1457
|
case 'require':
|
|
1452
1458
|
if (isNodeRequirePropertyAccess(parent)) {
|
|
@@ -1692,7 +1698,7 @@ function commonjs(options = {}) {
|
|
|
1692
1698
|
);
|
|
1693
1699
|
const isDynamicRequireModulesEnabled = dynamicRequireModuleSet.size > 0;
|
|
1694
1700
|
const commonDir = isDynamicRequireModulesEnabled
|
|
1695
|
-
? getCommonDir__default[
|
|
1701
|
+
? getCommonDir__default["default"](null, Array.from(dynamicRequireModuleSet).concat(process.cwd()))
|
|
1696
1702
|
: null;
|
|
1697
1703
|
|
|
1698
1704
|
const esModulesWithDefaultExport = new Set();
|