MCPcopy Index your code
hub / github.com/adobe/react-spectrum / package

Function package

packages/dev/parcel-packager-ssg/SSGPackager.js:29–284  ·  view source on GitHub ↗
({bundle, bundleGraph, getInlineBundleContents})

Source from the content-addressed store, hash-verified

27 moduleCache.clear();
28 },
29 async package({bundle, bundleGraph, getInlineBundleContents}) {
30 let queue = new PromiseQueue({maxConcurrent: 32});
31 bundle.traverse(node => {
32 if (node.type === 'dependency') {
33 let dep = node.value;
34 let entryBundle = bundleGraph.getReferencedBundle(dep, bundle);
35 if (entryBundle?.bundleBehavior === 'inline') {
36 queue.add(async () => {
37 if (!packagingBundles.has(entryBundle)) {
38 packagingBundles.set(entryBundle, getInlineBundleContents(entryBundle, bundleGraph));
39 }
40
41 let packagedBundle = await packagingBundles.get(entryBundle);
42 let contents = await blobToString(packagedBundle.contents);
43 contents = `module.exports = ${contents}`;
44 return [entryBundle.id, [entryBundle.getMainEntry(), contents]];
45 });
46 }
47 } else if (node.type === 'asset') {
48 let asset = node.value;
49 queue.add(async () => [asset.id, [asset, await asset.getCode()]]);
50 }
51 });
52
53 let assets = new Map(await queue.run());
54 let load = id => {
55 const cachedModule = moduleCache.get(id);
56 if (cachedModule) {
57 return cachedModule.exports;
58 }
59
60 let [asset, code] = assets.get(id);
61 let moduleFunction = vm.compileFunction(
62 code,
63 ['exports', 'require', 'module', '__dirname', '__filename', 'parcelRequire'],
64 {
65 filename: asset.filePath
66 }
67 );
68
69 let deps = new Map();
70 for (let dep of bundleGraph.getDependencies(asset)) {
71 if (bundleGraph.isDependencySkipped(dep)) {
72 deps.set(getSpecifier(dep), {skipped: true});
73 continue;
74 }
75
76 let entryBundle = bundleGraph.getReferencedBundle(dep, bundle);
77 if (entryBundle?.bundleBehavior === 'inline') {
78 deps.set(getSpecifier(dep), {id: entryBundle.id});
79 continue;
80 }
81
82 let resolved = bundleGraph.getResolvedAsset(dep, bundle);
83 if (resolved) {
84 if (resolved.type !== 'js') {
85 deps.set(getSpecifier(dep), {skipped: true});
86 } else {

Callers

nothing calls this directly

Calls 12

blobToStringFunction · 0.85
renameFunction · 0.85
getImageURLFunction · 0.85
traverseMethod · 0.80
runMethod · 0.80
pushMethod · 0.80
createElementMethod · 0.80
loadFunction · 0.70
addMethod · 0.65
hasMethod · 0.65
filterMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected