@parcel/utils 2.0.0-canary.1770 → 2.0.0-canary.1775
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 +22 -0
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/import-map.js +47 -0
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.0.0-canary.
|
|
3
|
+
"version": "2.0.0-canary.1775+735a635f7",
|
|
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.0.0-canary.
|
|
37
|
-
"@parcel/diagnostic": "2.0.0-canary.
|
|
38
|
-
"@parcel/logger": "2.0.0-canary.
|
|
39
|
-
"@parcel/markdown-ansi": "2.0.0-canary.
|
|
40
|
-
"@parcel/rust": "2.13.4-canary.
|
|
36
|
+
"@parcel/codeframe": "2.0.0-canary.1775+735a635f7",
|
|
37
|
+
"@parcel/diagnostic": "2.0.0-canary.1775+735a635f7",
|
|
38
|
+
"@parcel/logger": "2.0.0-canary.1775+735a635f7",
|
|
39
|
+
"@parcel/markdown-ansi": "2.0.0-canary.1775+735a635f7",
|
|
40
|
+
"@parcel/rust": "2.13.4-canary.3398+735a635f7",
|
|
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": "735a635f7eed538c449f37517b26247e0b19c1a4"
|
|
70
70
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import type {BundleGraph, NamedBundle} from '@parcel/types';
|
|
3
|
+
import {normalizeSeparators} from './path';
|
|
4
|
+
|
|
5
|
+
export function getImportMap(
|
|
6
|
+
bundleGraph: BundleGraph<NamedBundle>,
|
|
7
|
+
entryBundle: NamedBundle,
|
|
8
|
+
): {[string]: string} {
|
|
9
|
+
let mappings = {};
|
|
10
|
+
for (let childBundle of bundleGraph.getChildBundles(entryBundle)) {
|
|
11
|
+
bundleGraph.traverseBundles((bundle, _, actions) => {
|
|
12
|
+
if (bundle.bundleBehavior === 'inline') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mappings[bundle.publicId] = normalizeSeparators(bundle.name);
|
|
17
|
+
|
|
18
|
+
if (bundle !== entryBundle && isNewContext(bundle, bundleGraph)) {
|
|
19
|
+
for (let referenced of bundleGraph.getReferencedBundles(bundle)) {
|
|
20
|
+
mappings[referenced.publicId] = normalizeSeparators(referenced.name);
|
|
21
|
+
}
|
|
22
|
+
// New contexts have their own manifests, so there's no need to continue.
|
|
23
|
+
actions.skipChildren();
|
|
24
|
+
}
|
|
25
|
+
}, childBundle);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return mappings;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isNewContext(
|
|
32
|
+
bundle: NamedBundle,
|
|
33
|
+
bundleGraph: BundleGraph<NamedBundle>,
|
|
34
|
+
): boolean {
|
|
35
|
+
let parents = bundleGraph.getParentBundles(bundle);
|
|
36
|
+
let isInEntryBundleGroup = bundleGraph
|
|
37
|
+
.getBundleGroupsContainingBundle(bundle)
|
|
38
|
+
.some(g => bundleGraph.isEntryBundleGroup(g));
|
|
39
|
+
return (
|
|
40
|
+
isInEntryBundleGroup ||
|
|
41
|
+
parents.length === 0 ||
|
|
42
|
+
parents.some(
|
|
43
|
+
parent =>
|
|
44
|
+
parent.env.context !== bundle.env.context || parent.type !== 'js',
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/index.js
CHANGED