@rollup/plugin-commonjs 22.0.0 → 22.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/dist/cjs/index.js +23 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +23 -15
- package/dist/es/index.js.map +1 -1
- package/package.json +1 -1
- package/CHANGELOG.md +0 -652
package/dist/cjs/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
|
|
|
16
16
|
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
|
17
17
|
var isReference__default = /*#__PURE__*/_interopDefaultLegacy(isReference);
|
|
18
18
|
|
|
19
|
-
var version = "22.0.
|
|
19
|
+
var version = "22.0.1";
|
|
20
20
|
var peerDependencies = {
|
|
21
21
|
rollup: "^2.68.0"
|
|
22
22
|
};
|
|
@@ -498,7 +498,7 @@ function resolveExtensions(importee, importer, extensions) {
|
|
|
498
498
|
return undefined;
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
function getResolveId(extensions) {
|
|
501
|
+
function getResolveId(extensions, isPossibleCjsId) {
|
|
502
502
|
const currentlyResolving = new Map();
|
|
503
503
|
|
|
504
504
|
return {
|
|
@@ -590,21 +590,27 @@ function getResolveId(extensions) {
|
|
|
590
590
|
!resolved ||
|
|
591
591
|
resolved.external ||
|
|
592
592
|
resolved.id.endsWith(ENTRY_SUFFIX) ||
|
|
593
|
-
isWrappedId(resolved.id, ES_IMPORT_SUFFIX)
|
|
593
|
+
isWrappedId(resolved.id, ES_IMPORT_SUFFIX) ||
|
|
594
|
+
!isPossibleCjsId(resolved.id)
|
|
594
595
|
) {
|
|
595
596
|
return resolved;
|
|
596
597
|
}
|
|
597
598
|
const moduleInfo = await this.load(resolved);
|
|
598
|
-
if (resolveOptions.isEntry) {
|
|
599
|
-
moduleInfo.moduleSideEffects = true;
|
|
600
|
-
// We must not precede entry proxies with a `\0` as that will mess up relative external resolution
|
|
601
|
-
return resolved.id + ENTRY_SUFFIX;
|
|
602
|
-
}
|
|
603
599
|
const {
|
|
604
600
|
meta: { commonjs: commonjsMeta }
|
|
605
601
|
} = moduleInfo;
|
|
606
|
-
if (commonjsMeta
|
|
607
|
-
|
|
602
|
+
if (commonjsMeta) {
|
|
603
|
+
const { isCommonJS } = commonjsMeta;
|
|
604
|
+
if (isCommonJS) {
|
|
605
|
+
if (resolveOptions.isEntry) {
|
|
606
|
+
moduleInfo.moduleSideEffects = true;
|
|
607
|
+
// We must not precede entry proxies with a `\0` as that will mess up relative external resolution
|
|
608
|
+
return resolved.id + ENTRY_SUFFIX;
|
|
609
|
+
}
|
|
610
|
+
if (isCommonJS === IS_WRAPPED_COMMONJS) {
|
|
611
|
+
return { id: wrapId(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
|
|
612
|
+
}
|
|
613
|
+
}
|
|
608
614
|
}
|
|
609
615
|
return resolved;
|
|
610
616
|
}
|
|
@@ -1954,6 +1960,11 @@ function commonjs(options = {}) {
|
|
|
1954
1960
|
} = options;
|
|
1955
1961
|
const extensions = options.extensions || ['.js'];
|
|
1956
1962
|
const filter = pluginutils.createFilter(options.include, options.exclude);
|
|
1963
|
+
const isPossibleCjsId = (id) => {
|
|
1964
|
+
const extName = path.extname(id);
|
|
1965
|
+
return extName === '.cjs' || (extensions.includes(extName) && filter(id));
|
|
1966
|
+
};
|
|
1967
|
+
|
|
1957
1968
|
const { strictRequiresFilter, detectCyclesAndConditional } = getStrictRequiresFilter(options);
|
|
1958
1969
|
|
|
1959
1970
|
const getRequireReturnsDefault =
|
|
@@ -2008,7 +2019,7 @@ function commonjs(options = {}) {
|
|
|
2008
2019
|
};
|
|
2009
2020
|
};
|
|
2010
2021
|
|
|
2011
|
-
const { currentlyResolving, resolveId } = getResolveId(extensions);
|
|
2022
|
+
const { currentlyResolving, resolveId } = getResolveId(extensions, isPossibleCjsId);
|
|
2012
2023
|
|
|
2013
2024
|
const sourceMap = options.sourceMap !== false;
|
|
2014
2025
|
|
|
@@ -2204,10 +2215,7 @@ function commonjs(options = {}) {
|
|
|
2204
2215
|
},
|
|
2205
2216
|
|
|
2206
2217
|
transform(code, id) {
|
|
2207
|
-
|
|
2208
|
-
if (extName !== '.cjs' && (!filter(id) || !extensions.includes(extName))) {
|
|
2209
|
-
return null;
|
|
2210
|
-
}
|
|
2218
|
+
if (!isPossibleCjsId(id)) return null;
|
|
2211
2219
|
|
|
2212
2220
|
try {
|
|
2213
2221
|
return transformAndCheckExports.call(this, code, id);
|