@parcel/packager-react-static 2.16.1-canary.3487 → 2.16.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.
@@ -89,6 +89,7 @@ let packagingBundles = new Map();
89
89
  let moduleCache = new Map();
90
90
  let loadedBundles = new Map();
91
91
  let context = _vm().default.createContext();
92
+ let bundleLookupCache = new WeakMap();
92
93
  var _default = exports.default = new (_plugin().Packager)({
93
94
  async loadConfig({
94
95
  options,
@@ -139,7 +140,9 @@ var _default = exports.default = new (_plugin().Packager)({
139
140
  includeInline: false,
140
141
  includeIsolated: false
141
142
  })) {
142
- referencedBundles.push(b.getContentHash());
143
+ if (b.type === 'js') {
144
+ referencedBundles.push(b.getContentHash());
145
+ }
143
146
  }
144
147
  return {
145
148
  pages,
@@ -292,7 +295,7 @@ async function loadBundleUncached(bundle, bundleGraph, getInlineBundleContents)
292
295
  contents = `module.exports = ${contents}`;
293
296
  return [[entryBundle.id, [entryBundle, (0, _nullthrows().default)(entryBundle.getMainEntry()), contents]]];
294
297
  });
295
- } else if (entryBundle) {
298
+ } else if ((entryBundle === null || entryBundle === void 0 ? void 0 : entryBundle.type) === 'js') {
296
299
  queue.add(async () => {
297
300
  let {
298
301
  assets: subAssets
@@ -306,12 +309,14 @@ async function loadBundleUncached(bundle, bundleGraph, getInlineBundleContents)
306
309
  }
307
310
  });
308
311
  for (let b of bundleGraph.getReferencedBundles(bundle)) {
309
- queue.add(async () => {
310
- let {
311
- assets: subAssets
312
- } = await loadBundle(b, bundleGraph, getInlineBundleContents);
313
- return Array.from(subAssets);
314
- });
312
+ if (b.type === 'js') {
313
+ queue.add(async () => {
314
+ let {
315
+ assets: subAssets
316
+ } = await loadBundle(b, bundleGraph, getInlineBundleContents);
317
+ return Array.from(subAssets);
318
+ });
319
+ }
315
320
  }
316
321
  let assets = new Map((await queue.run()).flatMap(v => v));
317
322
  let assetsByFilePath = new Map();
@@ -460,8 +465,18 @@ async function loadBundleUncached(bundle, bundleGraph, getInlineBundleContents)
460
465
  distDir: bundle.target.distDir,
461
466
  publicUrl
462
467
  };
468
+ let bundleLookup = bundleLookupCache.get(bundleGraph);
469
+ if (!bundleLookup) {
470
+ bundleLookup = new Map();
471
+ for (let bundle of bundleGraph.getBundles()) {
472
+ bundleLookup.set(bundle.publicId, bundle);
473
+ bundleLookup.set(bundle.name, bundle);
474
+ }
475
+ bundleLookupCache.set(bundleGraph, bundleLookup);
476
+ }
463
477
  parcelRequire.load = async filePath => {
464
- let bundle = bundleGraph.getBundles().find(b => b.publicId === filePath || b.name === filePath);
478
+ var _bundleLookup;
479
+ let bundle = (_bundleLookup = bundleLookup) === null || _bundleLookup === void 0 ? void 0 : _bundleLookup.get(filePath);
465
480
  if (bundle) {
466
481
  let {
467
482
  assets: subAssets
@@ -478,7 +493,8 @@ async function loadBundleUncached(bundle, bundleGraph, getInlineBundleContents)
478
493
  }
479
494
  };
480
495
  parcelRequire.resolve = url => {
481
- let bundle = bundleGraph.getBundles().find(b => b.publicId === url || b.name === url);
496
+ var _bundleLookup2;
497
+ let bundle = (_bundleLookup2 = bundleLookup) === null || _bundleLookup2 === void 0 ? void 0 : _bundleLookup2.get(url);
482
498
  if (bundle) {
483
499
  return (0, _utils().urlJoin)(bundle.target.publicUrl, bundle.name);
484
500
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/packager-react-static",
3
- "version": "2.16.1-canary.3487+4b8189162",
3
+ "version": "2.16.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,16 +17,16 @@
17
17
  "source": "src/ReactStaticPackager.js",
18
18
  "engines": {
19
19
  "node": ">= 16.0.0",
20
- "parcel": "^2.0.0-canary.1862+4b8189162"
20
+ "parcel": "^2.16.1"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/node-resolver-core": "3.7.1-canary.3487+4b8189162",
24
- "@parcel/plugin": "2.0.0-canary.1864+4b8189162",
25
- "@parcel/rust": "2.16.1-canary.3487+4b8189162",
26
- "@parcel/types": "2.0.0-canary.1864+4b8189162",
27
- "@parcel/utils": "2.0.0-canary.1864+4b8189162",
23
+ "@parcel/node-resolver-core": "3.7.1",
24
+ "@parcel/plugin": "2.16.1",
25
+ "@parcel/rust": "2.16.1",
26
+ "@parcel/types": "2.16.1",
27
+ "@parcel/utils": "2.16.1",
28
28
  "nullthrows": "^1.1.1",
29
29
  "rsc-html-stream": "^0.0.6"
30
30
  },
31
- "gitHead": "4b81891623a6ebfee8eaed3721580c04976f56bf"
31
+ "gitHead": "9f01c02f8d766cc8735df31f1ec96f6cf1fb9973"
32
32
  }
@@ -45,6 +45,7 @@ let packagingBundles = new Map<NamedBundle, Async<{|contents: Blob|}>>();
45
45
  let moduleCache = new Map<string, ParcelModule>();
46
46
  let loadedBundles = new Map<NamedBundle, any>();
47
47
  let context: any = vm.createContext();
48
+ let bundleLookupCache = new WeakMap();
48
49
 
49
50
  export default (new Packager({
50
51
  async loadConfig({options, config}) {
@@ -97,7 +98,9 @@ export default (new Packager({
97
98
  includeInline: false,
98
99
  includeIsolated: false,
99
100
  })) {
100
- referencedBundles.push(b.getContentHash());
101
+ if (b.type === 'js') {
102
+ referencedBundles.push(b.getContentHash());
103
+ }
101
104
  }
102
105
 
103
106
  return {pages, referencedBundles};
@@ -308,7 +311,7 @@ async function loadBundleUncached(
308
311
  ],
309
312
  ];
310
313
  });
311
- } else if (entryBundle) {
314
+ } else if (entryBundle?.type === 'js') {
312
315
  queue.add(async () => {
313
316
  let {assets: subAssets} = await loadBundle(
314
317
  entryBundle,
@@ -327,14 +330,16 @@ async function loadBundleUncached(
327
330
  });
328
331
 
329
332
  for (let b of bundleGraph.getReferencedBundles(bundle)) {
330
- queue.add(async () => {
331
- let {assets: subAssets} = await loadBundle(
332
- b,
333
- bundleGraph,
334
- getInlineBundleContents,
335
- );
336
- return Array.from(subAssets);
337
- });
333
+ if (b.type === 'js') {
334
+ queue.add(async () => {
335
+ let {assets: subAssets} = await loadBundle(
336
+ b,
337
+ bundleGraph,
338
+ getInlineBundleContents,
339
+ );
340
+ return Array.from(subAssets);
341
+ });
342
+ }
338
343
  }
339
344
 
340
345
  let assets = new Map<string, [NamedBundle, Asset, string]>(
@@ -491,10 +496,18 @@ async function loadBundleUncached(
491
496
  publicUrl,
492
497
  };
493
498
 
499
+ let bundleLookup = bundleLookupCache.get(bundleGraph);
500
+ if (!bundleLookup) {
501
+ bundleLookup = new Map();
502
+ for (let bundle of bundleGraph.getBundles()) {
503
+ bundleLookup.set(bundle.publicId, bundle);
504
+ bundleLookup.set(bundle.name, bundle);
505
+ }
506
+ bundleLookupCache.set(bundleGraph, bundleLookup);
507
+ }
508
+
494
509
  parcelRequire.load = async (filePath: string) => {
495
- let bundle = bundleGraph
496
- .getBundles()
497
- .find(b => b.publicId === filePath || b.name === filePath);
510
+ let bundle = bundleLookup?.get(filePath);
498
511
  if (bundle) {
499
512
  let {assets: subAssets} = await loadBundle(
500
513
  bundle,
@@ -514,9 +527,7 @@ async function loadBundleUncached(
514
527
  };
515
528
 
516
529
  parcelRequire.resolve = (url: string) => {
517
- let bundle = bundleGraph
518
- .getBundles()
519
- .find(b => b.publicId === url || b.name === url);
530
+ let bundle = bundleLookup?.get(url);
520
531
  if (bundle) {
521
532
  return urlJoin(bundle.target.publicUrl, bundle.name);
522
533
  } else {