@rollup/plugin-commonjs 22.0.0-5 → 22.0.0-6
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 +40 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +40 -11
- package/dist/es/index.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -16,9 +16,9 @@ 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.0-
|
|
19
|
+
var version = "22.0.0-6";
|
|
20
20
|
var peerDependencies = {
|
|
21
|
-
rollup: "^2.
|
|
21
|
+
rollup: "^2.66.1"
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
function tryParse(parse, code, id) {
|
|
@@ -337,7 +337,8 @@ const WRAPPED_SUFFIX = '?commonjs-wrapped';
|
|
|
337
337
|
const EXTERNAL_SUFFIX = '?commonjs-external';
|
|
338
338
|
const EXPORTS_SUFFIX = '?commonjs-exports';
|
|
339
339
|
const MODULE_SUFFIX = '?commonjs-module';
|
|
340
|
-
const
|
|
340
|
+
const ENTRY_SUFFIX = '?commonjs-entry';
|
|
341
|
+
const ES_IMPORT_SUFFIX = '?commonjs-es-import';
|
|
341
342
|
|
|
342
343
|
const DYNAMIC_MODULES_ID = '\0commonjs-dynamic-modules';
|
|
343
344
|
const HELPERS_ID = '\0commonjsHelpers.js';
|
|
@@ -429,6 +430,22 @@ async function getStaticRequireProxy(id, requireReturnsDefault, loadModule) {
|
|
|
429
430
|
return `export { default } from ${JSON.stringify(id)};`;
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
async function getEntryProxy(id, defaultIsModuleExports, loadModule) {
|
|
434
|
+
const {
|
|
435
|
+
meta: { commonjs: commonjsMeta },
|
|
436
|
+
hasDefaultExport
|
|
437
|
+
} = await loadModule({ id, moduleSideEffects: true });
|
|
438
|
+
if (!commonjsMeta || commonjsMeta.isCommonJS !== IS_WRAPPED_COMMONJS) {
|
|
439
|
+
const stringifiedId = JSON.stringify(id);
|
|
440
|
+
let code = `export * from ${stringifiedId};`;
|
|
441
|
+
if (hasDefaultExport) {
|
|
442
|
+
code += `export { default } from ${stringifiedId};`;
|
|
443
|
+
}
|
|
444
|
+
return code;
|
|
445
|
+
}
|
|
446
|
+
return getEsImportProxy(id, defaultIsModuleExports);
|
|
447
|
+
}
|
|
448
|
+
|
|
432
449
|
function getEsImportProxy(id, defaultIsModuleExports) {
|
|
433
450
|
const name = getName(id);
|
|
434
451
|
const exportsName = `${name}Exports`;
|
|
@@ -497,13 +514,15 @@ function getResolveId(extensions) {
|
|
|
497
514
|
}
|
|
498
515
|
|
|
499
516
|
if (
|
|
500
|
-
|
|
501
|
-
isWrappedId(importee,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
517
|
+
importee.startsWith('\0') &&
|
|
518
|
+
(isWrappedId(importee, MODULE_SUFFIX) ||
|
|
519
|
+
isWrappedId(importee, EXPORTS_SUFFIX) ||
|
|
520
|
+
isWrappedId(importee, PROXY_SUFFIX) ||
|
|
521
|
+
isWrappedId(importee, ES_IMPORT_SUFFIX) ||
|
|
522
|
+
importee.endsWith(ENTRY_SUFFIX) ||
|
|
523
|
+
isWrappedId(importee, EXTERNAL_SUFFIX) ||
|
|
524
|
+
importee.startsWith(HELPERS_ID) ||
|
|
525
|
+
importee === DYNAMIC_MODULES_ID)
|
|
507
526
|
) {
|
|
508
527
|
return importee;
|
|
509
528
|
}
|
|
@@ -513,7 +532,8 @@ function getResolveId(extensions) {
|
|
|
513
532
|
importer === DYNAMIC_MODULES_ID ||
|
|
514
533
|
// Proxies are only importing resolved ids, no need to resolve again
|
|
515
534
|
isWrappedId(importer, PROXY_SUFFIX) ||
|
|
516
|
-
isWrappedId(importer, ES_IMPORT_SUFFIX)
|
|
535
|
+
isWrappedId(importer, ES_IMPORT_SUFFIX) ||
|
|
536
|
+
importer.endsWith(ENTRY_SUFFIX)
|
|
517
537
|
) {
|
|
518
538
|
return importee;
|
|
519
539
|
}
|
|
@@ -546,6 +566,10 @@ function getResolveId(extensions) {
|
|
|
546
566
|
if (!resolved || resolved.external) {
|
|
547
567
|
return resolved;
|
|
548
568
|
}
|
|
569
|
+
if (resolveOptions.isEntry) {
|
|
570
|
+
// We must not precede entry proxies with a `\0` as that will mess up relative external resolution
|
|
571
|
+
return resolved.id + ENTRY_SUFFIX;
|
|
572
|
+
}
|
|
549
573
|
const {
|
|
550
574
|
meta: { commonjs: commonjsMeta }
|
|
551
575
|
} = await this.load(resolved);
|
|
@@ -2026,6 +2050,11 @@ function commonjs(options = {}) {
|
|
|
2026
2050
|
);
|
|
2027
2051
|
}
|
|
2028
2052
|
|
|
2053
|
+
// entry suffix is just appended to not mess up relative external resolution
|
|
2054
|
+
if (id.endsWith(ENTRY_SUFFIX)) {
|
|
2055
|
+
return getEntryProxy(id.slice(0, -ENTRY_SUFFIX.length), defaultIsModuleExports, this.load);
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2029
2058
|
if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
|
|
2030
2059
|
return getEsImportProxy(unwrapId(id, ES_IMPORT_SUFFIX), defaultIsModuleExports);
|
|
2031
2060
|
}
|