@parcel/utils 2.15.4 → 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.
- package/lib/index.js +10 -2
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/import-map.js +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.1",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@parcel/codeframe": "2.
|
|
37
|
-
"@parcel/diagnostic": "2.
|
|
38
|
-
"@parcel/logger": "2.
|
|
39
|
-
"@parcel/markdown-ansi": "2.
|
|
40
|
-
"@parcel/rust": "2.
|
|
36
|
+
"@parcel/codeframe": "2.16.1",
|
|
37
|
+
"@parcel/diagnostic": "2.16.1",
|
|
38
|
+
"@parcel/logger": "2.16.1",
|
|
39
|
+
"@parcel/markdown-ansi": "2.16.1",
|
|
40
|
+
"@parcel/rust": "2.16.1",
|
|
41
41
|
"@parcel/source-map": "^2.1.1",
|
|
42
42
|
"chalk": "^4.1.2",
|
|
43
43
|
"nullthrows": "^1.1.1"
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"./src/openInBrowser.js": false,
|
|
67
67
|
"@parcel/markdown-ansi": false
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "9f01c02f8d766cc8735df31f1ec96f6cf1fb9973"
|
|
70
70
|
}
|
package/src/import-map.js
CHANGED
|
@@ -2,10 +2,23 @@
|
|
|
2
2
|
import type {BundleGraph, NamedBundle} from '@parcel/types';
|
|
3
3
|
import {normalizeSeparators} from './path';
|
|
4
4
|
|
|
5
|
+
let importMapCache = new WeakMap();
|
|
6
|
+
|
|
5
7
|
export function getImportMap(
|
|
6
8
|
bundleGraph: BundleGraph<NamedBundle>,
|
|
7
9
|
entryBundle: NamedBundle,
|
|
8
10
|
): {[string]: string} {
|
|
11
|
+
let cache = importMapCache.get(bundleGraph);
|
|
12
|
+
if (!cache) {
|
|
13
|
+
cache = new WeakMap();
|
|
14
|
+
importMapCache.set(bundleGraph, cache);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let cached = cache.get(entryBundle);
|
|
18
|
+
if (cached) {
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
let mappings = {};
|
|
10
23
|
for (let childBundle of bundleGraph.getChildBundles(entryBundle)) {
|
|
11
24
|
bundleGraph.traverseBundles((bundle, _, actions) => {
|
|
@@ -25,6 +38,7 @@ export function getImportMap(
|
|
|
25
38
|
}, childBundle);
|
|
26
39
|
}
|
|
27
40
|
|
|
41
|
+
cache.set(entryBundle, mappings);
|
|
28
42
|
return mappings;
|
|
29
43
|
}
|
|
30
44
|
|
|
@@ -33,11 +47,7 @@ function isNewContext(
|
|
|
33
47
|
bundleGraph: BundleGraph<NamedBundle>,
|
|
34
48
|
): boolean {
|
|
35
49
|
let parents = bundleGraph.getParentBundles(bundle);
|
|
36
|
-
let isInEntryBundleGroup = bundleGraph
|
|
37
|
-
.getBundleGroupsContainingBundle(bundle)
|
|
38
|
-
.some(g => bundleGraph.isEntryBundleGroup(g));
|
|
39
50
|
return (
|
|
40
|
-
isInEntryBundleGroup ||
|
|
41
51
|
parents.length === 0 ||
|
|
42
52
|
parents.some(
|
|
43
53
|
parent =>
|