@atlaspack/core 2.16.2-canary.56 → 2.16.2-canary.57
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/AssetGraph.js +17 -6
- package/lib/BundleGraph.js +6 -5
- package/lib/Dependency.js +6 -2
- package/lib/Environment.js +4 -3
- package/lib/EnvironmentManager.js +80 -0
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +10 -7
- package/lib/RequestTracker.js +2 -2
- package/lib/UncommittedAsset.js +3 -2
- package/lib/applyRuntimes.js +2 -1
- package/lib/assetUtils.js +2 -1
- package/lib/public/Asset.js +3 -2
- package/lib/public/Bundle.js +2 -1
- package/lib/public/Config.js +2 -1
- package/lib/public/Dependency.js +2 -1
- package/lib/public/MutableBundleGraph.js +2 -1
- package/lib/public/Target.js +2 -1
- package/lib/requests/AssetRequest.js +2 -1
- package/lib/requests/TargetRequest.js +18 -16
- package/lib/requests/WriteBundleRequest.js +4 -2
- package/package.json +17 -17
- package/src/AssetGraph.js +12 -6
- package/src/BundleGraph.js +13 -8
- package/src/Dependency.js +13 -5
- package/src/Environment.js +8 -5
- package/src/EnvironmentManager.js +76 -0
- package/src/InternalConfig.js +5 -4
- package/src/PackagerRunner.js +12 -11
- package/src/RequestTracker.js +2 -2
- package/src/UncommittedAsset.js +7 -2
- package/src/applyRuntimes.js +6 -1
- package/src/assetUtils.js +4 -3
- package/src/public/Asset.js +9 -2
- package/src/public/Bundle.js +2 -1
- package/src/public/Config.js +2 -1
- package/src/public/Dependency.js +2 -1
- package/src/public/MutableBundleGraph.js +2 -1
- package/src/public/Target.js +2 -1
- package/src/requests/AssetRequest.js +2 -1
- package/src/requests/TargetRequest.js +19 -25
- package/src/requests/WriteBundleRequest.js +5 -7
- package/src/types.js +7 -6
- package/test/Environment.test.js +43 -34
- package/test/PublicEnvironment.test.js +10 -7
- package/test/test-utils.js +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.16.2-canary.
|
|
3
|
+
"version": "2.16.2-canary.57+6dd4ccb75",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaspack/build-cache": "2.13.3-canary.
|
|
25
|
-
"@atlaspack/cache": "3.1.1-canary.
|
|
26
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
27
|
-
"@atlaspack/events": "2.14.1-canary.
|
|
28
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
29
|
-
"@atlaspack/fs": "2.14.5-canary.
|
|
30
|
-
"@atlaspack/graph": "3.4.1-canary.
|
|
31
|
-
"@atlaspack/logger": "2.14.5-canary.
|
|
32
|
-
"@atlaspack/package-manager": "2.14.5-canary.
|
|
33
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
34
|
-
"@atlaspack/profiler": "2.14.1-canary.
|
|
35
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
36
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
37
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
38
|
-
"@atlaspack/workers": "2.14.5-canary.
|
|
24
|
+
"@atlaspack/build-cache": "2.13.3-canary.125+6dd4ccb75",
|
|
25
|
+
"@atlaspack/cache": "3.1.1-canary.57+6dd4ccb75",
|
|
26
|
+
"@atlaspack/diagnostic": "2.14.1-canary.125+6dd4ccb75",
|
|
27
|
+
"@atlaspack/events": "2.14.1-canary.125+6dd4ccb75",
|
|
28
|
+
"@atlaspack/feature-flags": "2.14.1-canary.125+6dd4ccb75",
|
|
29
|
+
"@atlaspack/fs": "2.14.5-canary.57+6dd4ccb75",
|
|
30
|
+
"@atlaspack/graph": "3.4.1-canary.125+6dd4ccb75",
|
|
31
|
+
"@atlaspack/logger": "2.14.5-canary.57+6dd4ccb75",
|
|
32
|
+
"@atlaspack/package-manager": "2.14.5-canary.57+6dd4ccb75",
|
|
33
|
+
"@atlaspack/plugin": "2.14.5-canary.57+6dd4ccb75",
|
|
34
|
+
"@atlaspack/profiler": "2.14.1-canary.125+6dd4ccb75",
|
|
35
|
+
"@atlaspack/rust": "3.2.1-canary.57+6dd4ccb75",
|
|
36
|
+
"@atlaspack/types": "2.14.5-canary.57+6dd4ccb75",
|
|
37
|
+
"@atlaspack/utils": "2.14.5-canary.57+6dd4ccb75",
|
|
38
|
+
"@atlaspack/workers": "2.14.5-canary.57+6dd4ccb75",
|
|
39
39
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
40
40
|
"@parcel/source-map": "^2.1.1",
|
|
41
41
|
"base-x": "^3.0.8",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
72
72
|
},
|
|
73
73
|
"type": "commonjs",
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "6dd4ccb753541de32322d881f973d571dd57e4ca"
|
|
75
75
|
}
|
package/src/AssetGraph.js
CHANGED
|
@@ -29,6 +29,8 @@ import nullthrows from 'nullthrows';
|
|
|
29
29
|
import {ContentGraph} from '@atlaspack/graph';
|
|
30
30
|
import {createDependency} from './Dependency';
|
|
31
31
|
import {type ProjectPath, fromProjectPathRelative} from './projectPath';
|
|
32
|
+
import {fromEnvironmentId, toEnvironmentId} from './EnvironmentManager';
|
|
33
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
32
34
|
|
|
33
35
|
type InitOpts = {|
|
|
34
36
|
entries?: Array<ProjectPath>,
|
|
@@ -65,7 +67,7 @@ export function nodeFromAssetGroup(assetGroup: AssetGroup): AssetGroupNode {
|
|
|
65
67
|
return {
|
|
66
68
|
id: hashString(
|
|
67
69
|
fromProjectPathRelative(assetGroup.filePath) +
|
|
68
|
-
assetGroup.env
|
|
70
|
+
toEnvironmentId(assetGroup.env) +
|
|
69
71
|
String(assetGroup.isSource) +
|
|
70
72
|
String(assetGroup.sideEffects) +
|
|
71
73
|
(assetGroup.code ?? '') +
|
|
@@ -149,14 +151,18 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
149
151
|
|
|
150
152
|
// Deduplicates Environments by making them referentially equal
|
|
151
153
|
normalizeEnvironment(input: Asset | Dependency | AssetGroup) {
|
|
152
|
-
|
|
154
|
+
if (getFeatureFlag('environmentDeduplication')) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let {id, context} = fromEnvironmentId(input.env);
|
|
153
159
|
let idAndContext = `${id}-${context}`;
|
|
154
160
|
|
|
155
161
|
let env = this.envCache.get(idAndContext);
|
|
156
162
|
if (env) {
|
|
157
163
|
input.env = env;
|
|
158
164
|
} else {
|
|
159
|
-
this.envCache.set(idAndContext, input.env);
|
|
165
|
+
this.envCache.set(idAndContext, fromEnvironmentId(input.env));
|
|
160
166
|
}
|
|
161
167
|
}
|
|
162
168
|
|
|
@@ -235,13 +241,13 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
235
241
|
env: target.env,
|
|
236
242
|
isEntry: true,
|
|
237
243
|
needsStableName: true,
|
|
238
|
-
symbols: target.env.isLibrary
|
|
244
|
+
symbols: fromEnvironmentId(target.env).isLibrary
|
|
239
245
|
? new Map([['*', {local: '*', isWeak: true, loc: null}]])
|
|
240
246
|
: undefined,
|
|
241
247
|
}),
|
|
242
248
|
);
|
|
243
249
|
|
|
244
|
-
if (node.value.env.isLibrary) {
|
|
250
|
+
if (fromEnvironmentId(node.value.env).isLibrary) {
|
|
245
251
|
// in library mode, all of the entry's symbols are "used"
|
|
246
252
|
node.usedSymbolsDown.add('*');
|
|
247
253
|
node.usedSymbolsUp.set('*', undefined);
|
|
@@ -428,7 +434,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
428
434
|
|
|
429
435
|
let depIsDeferrable =
|
|
430
436
|
d.symbols &&
|
|
431
|
-
!(d.env.isLibrary && d.isEntry) &&
|
|
437
|
+
!(fromEnvironmentId(d.env).isLibrary && d.isEntry) &&
|
|
432
438
|
!d.symbols.has('*') &&
|
|
433
439
|
![...d.symbols.keys()].some((symbol) => {
|
|
434
440
|
let assetSymbol = resolvedAsset.symbols?.get(symbol)?.local;
|
package/src/BundleGraph.js
CHANGED
|
@@ -24,7 +24,6 @@ import type {
|
|
|
24
24
|
BundleNode,
|
|
25
25
|
Dependency,
|
|
26
26
|
DependencyNode,
|
|
27
|
-
Environment,
|
|
28
27
|
InternalSourceLocation,
|
|
29
28
|
Target,
|
|
30
29
|
Condition,
|
|
@@ -49,6 +48,8 @@ import {ISOLATED_ENVS} from './public/Environment';
|
|
|
49
48
|
import {fromProjectPath, fromProjectPathRelative} from './projectPath';
|
|
50
49
|
import {HASH_REF_PREFIX} from './constants';
|
|
51
50
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
51
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
52
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
52
53
|
|
|
53
54
|
export const bundleGraphEdgeTypes = {
|
|
54
55
|
// A lack of an edge type indicates to follow the edge while traversing
|
|
@@ -283,7 +284,7 @@ export default class BundleGraph {
|
|
|
283
284
|
if (
|
|
284
285
|
node.type === 'dependency' &&
|
|
285
286
|
node.value.symbols != null &&
|
|
286
|
-
node.value.env.shouldScopeHoist &&
|
|
287
|
+
fromEnvironmentId(node.value.env).shouldScopeHoist &&
|
|
287
288
|
// Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
|
|
288
289
|
isProduction
|
|
289
290
|
) {
|
|
@@ -555,11 +556,11 @@ export default class BundleGraph {
|
|
|
555
556
|
+needsStableName?: ?boolean,
|
|
556
557
|
+bundleBehavior?: ?IBundleBehavior,
|
|
557
558
|
+shouldContentHash: boolean,
|
|
558
|
-
+env:
|
|
559
|
+
+env: EnvironmentRef,
|
|
559
560
|
|}
|
|
560
561
|
| {|
|
|
561
562
|
+type: string,
|
|
562
|
-
+env:
|
|
563
|
+
+env: EnvironmentRef,
|
|
563
564
|
+uniqueKey: string,
|
|
564
565
|
+target: Target,
|
|
565
566
|
+needsStableName?: ?boolean,
|
|
@@ -1359,7 +1360,8 @@ export default class BundleGraph {
|
|
|
1359
1360
|
|
|
1360
1361
|
if (
|
|
1361
1362
|
descendant.type !== bundle.type ||
|
|
1362
|
-
descendant.env.context !==
|
|
1363
|
+
fromEnvironmentId(descendant.env).context !==
|
|
1364
|
+
fromEnvironmentId(bundle.env).context
|
|
1363
1365
|
) {
|
|
1364
1366
|
actions.skipChildren();
|
|
1365
1367
|
return;
|
|
@@ -1400,7 +1402,7 @@ export default class BundleGraph {
|
|
|
1400
1402
|
// If a bundle's environment is isolated, it can't access assets present
|
|
1401
1403
|
// in any ancestor bundles. Don't consider any assets reachable.
|
|
1402
1404
|
if (
|
|
1403
|
-
ISOLATED_ENVS.has(bundle.env.context) ||
|
|
1405
|
+
ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
|
|
1404
1406
|
!bundle.isSplittable ||
|
|
1405
1407
|
bundle.bundleBehavior === BundleBehavior.isolated ||
|
|
1406
1408
|
bundle.bundleBehavior === BundleBehavior.inline
|
|
@@ -1454,7 +1456,8 @@ export default class BundleGraph {
|
|
|
1454
1456
|
node.type === 'root' ||
|
|
1455
1457
|
(node.type === 'bundle' &&
|
|
1456
1458
|
(node.value.id === bundle.id ||
|
|
1457
|
-
node.value.env.context !==
|
|
1459
|
+
fromEnvironmentId(node.value.env).context !==
|
|
1460
|
+
fromEnvironmentId(bundle.env).context))
|
|
1458
1461
|
) {
|
|
1459
1462
|
isReachable = false;
|
|
1460
1463
|
actions.stop();
|
|
@@ -2128,7 +2131,9 @@ export default class BundleGraph {
|
|
|
2128
2131
|
hash.writeString(referencedBundle.id);
|
|
2129
2132
|
}
|
|
2130
2133
|
|
|
2131
|
-
hash.writeString(
|
|
2134
|
+
hash.writeString(
|
|
2135
|
+
JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
|
|
2136
|
+
);
|
|
2132
2137
|
return hash.finish();
|
|
2133
2138
|
}
|
|
2134
2139
|
|
package/src/Dependency.js
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
BundleBehavior as IBundleBehavior,
|
|
9
9
|
SemverRange,
|
|
10
10
|
} from '@atlaspack/types';
|
|
11
|
-
import type {Dependency,
|
|
11
|
+
import type {Dependency, Target} from './types';
|
|
12
12
|
import {createDependencyId as createDependencyIdRust} from '@atlaspack/rust';
|
|
13
13
|
import {
|
|
14
14
|
SpecifierType,
|
|
@@ -21,6 +21,8 @@ import {toInternalSourceLocation} from './utils';
|
|
|
21
21
|
import {toProjectPath} from './projectPath';
|
|
22
22
|
import assert from 'assert';
|
|
23
23
|
import {identifierRegistry} from './IdentifierRegistry';
|
|
24
|
+
import {fromEnvironmentId, toEnvironmentId} from './EnvironmentManager';
|
|
25
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
24
26
|
|
|
25
27
|
type DependencyOpts = {|
|
|
26
28
|
id?: string,
|
|
@@ -34,7 +36,7 @@ type DependencyOpts = {|
|
|
|
34
36
|
isEntry?: boolean,
|
|
35
37
|
isOptional?: boolean,
|
|
36
38
|
loc?: SourceLocation,
|
|
37
|
-
env:
|
|
39
|
+
env: EnvironmentRef,
|
|
38
40
|
packageConditions?: Array<string>,
|
|
39
41
|
meta?: Meta,
|
|
40
42
|
resolveFrom?: FilePath,
|
|
@@ -60,7 +62,7 @@ export function createDependencyId({
|
|
|
60
62
|
}: {|
|
|
61
63
|
sourceAssetId?: string | void,
|
|
62
64
|
specifier: DependencySpecifier,
|
|
63
|
-
env:
|
|
65
|
+
env: EnvironmentRef,
|
|
64
66
|
target?: Target | void,
|
|
65
67
|
pipeline?: ?string,
|
|
66
68
|
specifierType: $Keys<typeof SpecifierType>,
|
|
@@ -73,8 +75,14 @@ export function createDependencyId({
|
|
|
73
75
|
const params = {
|
|
74
76
|
sourceAssetId,
|
|
75
77
|
specifier,
|
|
76
|
-
environmentId: env
|
|
77
|
-
target
|
|
78
|
+
environmentId: toEnvironmentId(env),
|
|
79
|
+
target:
|
|
80
|
+
target != null
|
|
81
|
+
? {
|
|
82
|
+
...target,
|
|
83
|
+
env: fromEnvironmentId(target.env),
|
|
84
|
+
}
|
|
85
|
+
: null,
|
|
78
86
|
pipeline,
|
|
79
87
|
specifierType: SpecifierType[specifierType],
|
|
80
88
|
bundleBehavior,
|
package/src/Environment.js
CHANGED
|
@@ -10,6 +10,8 @@ import {toInternalSourceLocation} from './utils';
|
|
|
10
10
|
import PublicEnvironment from './public/Environment';
|
|
11
11
|
import {environmentToInternalEnvironment} from './public/Environment';
|
|
12
12
|
import {identifierRegistry} from './IdentifierRegistry';
|
|
13
|
+
import {toEnvironmentRef} from './EnvironmentManager';
|
|
14
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
13
15
|
|
|
14
16
|
const DEFAULT_ENGINES = {
|
|
15
17
|
browsers: ['> 0.25%'],
|
|
@@ -35,7 +37,7 @@ export function createEnvironment({
|
|
|
35
37
|
loc,
|
|
36
38
|
}: EnvironmentOpts = {
|
|
37
39
|
/*::...null*/
|
|
38
|
-
}):
|
|
40
|
+
}): EnvironmentRef {
|
|
39
41
|
if (context == null) {
|
|
40
42
|
if (engines?.node) {
|
|
41
43
|
context = 'node';
|
|
@@ -112,21 +114,22 @@ export function createEnvironment({
|
|
|
112
114
|
};
|
|
113
115
|
|
|
114
116
|
res.id = getEnvironmentHash(res);
|
|
115
|
-
|
|
117
|
+
|
|
118
|
+
return toEnvironmentRef(Object.freeze(res));
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
export function mergeEnvironments(
|
|
119
122
|
projectRoot: FilePath,
|
|
120
123
|
a: Environment,
|
|
121
124
|
b: ?(EnvironmentOptions | IEnvironment),
|
|
122
|
-
):
|
|
125
|
+
): EnvironmentRef {
|
|
123
126
|
// If merging the same object, avoid copying.
|
|
124
127
|
if (a === b || !b) {
|
|
125
|
-
return a;
|
|
128
|
+
return toEnvironmentRef(a);
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
if (b instanceof PublicEnvironment) {
|
|
129
|
-
return environmentToInternalEnvironment(b);
|
|
132
|
+
return toEnvironmentRef(environmentToInternalEnvironment(b));
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
// $FlowFixMe - ignore the `id` that is already on a
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
/*!
|
|
3
|
+
* At the moment we're doing this change for `CoreEnvironment`,
|
|
4
|
+
* but the same change must be made for `TypesEnvironment` in @atlaspack/types.
|
|
5
|
+
*/
|
|
6
|
+
import type {Environment as CoreEnvironment} from './types';
|
|
7
|
+
import {addEnvironment, getEnvironment} from '@atlaspack/rust';
|
|
8
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
9
|
+
|
|
10
|
+
const localEnvironmentCache = new Map<string, CoreEnvironment>();
|
|
11
|
+
|
|
12
|
+
export opaque type EnvironmentId = string;
|
|
13
|
+
/**
|
|
14
|
+
* When deduplication is cleaned-up this will always be a string.
|
|
15
|
+
*/
|
|
16
|
+
export type EnvironmentRef = EnvironmentId | CoreEnvironment;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Convert environment to a ref.
|
|
20
|
+
* This is what we should be using to store environments.
|
|
21
|
+
*/
|
|
22
|
+
export function toEnvironmentRef(env: CoreEnvironment): EnvironmentRef {
|
|
23
|
+
if (!getFeatureFlag('environmentDeduplication')) {
|
|
24
|
+
return env;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const id = toEnvironmentId(env);
|
|
28
|
+
return id;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Convert environment to a string ID
|
|
33
|
+
*/
|
|
34
|
+
export function toEnvironmentId(
|
|
35
|
+
/**
|
|
36
|
+
* Redundant type during roll-out
|
|
37
|
+
*/
|
|
38
|
+
env: CoreEnvironment | EnvironmentRef,
|
|
39
|
+
): string {
|
|
40
|
+
if (!getFeatureFlag('environmentDeduplication')) {
|
|
41
|
+
return typeof env === 'string' ? env : env.id;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typeof env === 'string') {
|
|
45
|
+
return env;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
addEnvironment(env);
|
|
49
|
+
return env.id;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function fromEnvironmentId(id: EnvironmentRef): CoreEnvironment {
|
|
53
|
+
if (!getFeatureFlag('environmentDeduplication')) {
|
|
54
|
+
if (typeof id === 'string') {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'This should never happen when environmentDeduplication feature-flag is off',
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof id !== 'string') {
|
|
64
|
+
return id;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const localEnv = localEnvironmentCache.get(id);
|
|
68
|
+
|
|
69
|
+
if (localEnv) {
|
|
70
|
+
return localEnv;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const env = Object.freeze(getEnvironment(id));
|
|
74
|
+
localEnvironmentCache.set(id, env);
|
|
75
|
+
return env;
|
|
76
|
+
}
|
package/src/InternalConfig.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import type {PackageName, ConfigResult} from '@atlaspack/types';
|
|
4
4
|
import type {
|
|
5
5
|
Config,
|
|
6
|
-
Environment,
|
|
7
6
|
InternalFileCreateInvalidation,
|
|
8
7
|
InternalDevDepOptions,
|
|
9
8
|
} from './types';
|
|
@@ -13,12 +12,14 @@ import {fromProjectPathRelative} from './projectPath';
|
|
|
13
12
|
import {createEnvironment} from './Environment';
|
|
14
13
|
import {hashString} from '@atlaspack/rust';
|
|
15
14
|
import {identifierRegistry} from './IdentifierRegistry';
|
|
15
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
16
|
+
import {toEnvironmentId} from './EnvironmentManager';
|
|
16
17
|
|
|
17
18
|
type ConfigOpts = {|
|
|
18
19
|
plugin: PackageName,
|
|
19
20
|
searchPath: ProjectPath,
|
|
20
21
|
isSource?: boolean,
|
|
21
|
-
env?:
|
|
22
|
+
env?: EnvironmentRef,
|
|
22
23
|
result?: ConfigResult,
|
|
23
24
|
invalidateOnFileChange?: Set<ProjectPath>,
|
|
24
25
|
invalidateOnConfigKeyChange?: Array<{|
|
|
@@ -52,13 +53,13 @@ export function createConfig({
|
|
|
52
53
|
const configId = hashString(
|
|
53
54
|
plugin +
|
|
54
55
|
fromProjectPathRelative(searchPath) +
|
|
55
|
-
environment
|
|
56
|
+
toEnvironmentId(environment) +
|
|
56
57
|
String(isSource),
|
|
57
58
|
);
|
|
58
59
|
identifierRegistry.addIdentifier('config_request', configId, {
|
|
59
60
|
plugin,
|
|
60
61
|
searchPath,
|
|
61
|
-
environmentId: environment
|
|
62
|
+
environmentId: toEnvironmentId(environment),
|
|
62
63
|
isSource,
|
|
63
64
|
});
|
|
64
65
|
return {
|
package/src/PackagerRunner.js
CHANGED
|
@@ -63,6 +63,7 @@ import {getInvalidationId, getInvalidationHash} from './assetUtils';
|
|
|
63
63
|
import {optionsProxy} from './utils';
|
|
64
64
|
import {invalidateDevDeps} from './requests/DevDepRequest';
|
|
65
65
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
66
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
66
67
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
67
68
|
|
|
68
69
|
type Opts = {|
|
|
@@ -578,32 +579,32 @@ export default class PackagerRunner {
|
|
|
578
579
|
);
|
|
579
580
|
let inlineSources = false;
|
|
580
581
|
|
|
582
|
+
const bundleEnv = fromEnvironmentId(bundle.env);
|
|
581
583
|
if (bundle.target) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
sourceRoot = bundle.env.sourceMap.sourceRoot;
|
|
584
|
+
const bundleTargetEnv = fromEnvironmentId(bundle.target.env);
|
|
585
|
+
|
|
586
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
587
|
+
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
587
588
|
} else if (
|
|
588
589
|
this.options.serveOptions &&
|
|
589
|
-
|
|
590
|
+
bundleTargetEnv.context === 'browser'
|
|
590
591
|
) {
|
|
591
592
|
sourceRoot = '/__parcel_source_root';
|
|
592
593
|
}
|
|
593
594
|
|
|
594
595
|
if (
|
|
595
|
-
|
|
596
|
-
|
|
596
|
+
bundleEnv.sourceMap &&
|
|
597
|
+
bundleEnv.sourceMap.inlineSources !== undefined
|
|
597
598
|
) {
|
|
598
|
-
inlineSources =
|
|
599
|
-
} else if (
|
|
599
|
+
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
600
|
+
} else if (bundleTargetEnv.context !== 'node') {
|
|
600
601
|
// inlining should only happen in production for browser targets by default
|
|
601
602
|
inlineSources = this.options.mode === 'production';
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
605
|
|
|
605
606
|
let mapFilename = fullPath + '.map';
|
|
606
|
-
let isInlineMap =
|
|
607
|
+
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
607
608
|
|
|
608
609
|
let stringified = await map.stringify({
|
|
609
610
|
file: path.basename(mapFilename),
|
package/src/RequestTracker.js
CHANGED
|
@@ -714,8 +714,8 @@ export class RequestGraph extends ContentGraph<
|
|
|
714
714
|
env: string,
|
|
715
715
|
value: string | void,
|
|
716
716
|
) {
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
const envNode = nodeFromEnv(env, value);
|
|
718
|
+
const envNodeId = this.addNode(envNode);
|
|
719
719
|
|
|
720
720
|
if (
|
|
721
721
|
!this.hasEdge(
|
package/src/UncommittedAsset.js
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
fromProjectPathRelative,
|
|
37
37
|
} from './projectPath';
|
|
38
38
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
39
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
39
40
|
|
|
40
41
|
type UncommittedAssetOptions = {|
|
|
41
42
|
value: Asset,
|
|
@@ -321,7 +322,11 @@ export default class UncommittedAsset {
|
|
|
321
322
|
...rest,
|
|
322
323
|
// $FlowFixMe "convert" the $ReadOnlyMaps to the interal mutable one
|
|
323
324
|
symbols,
|
|
324
|
-
env: mergeEnvironments(
|
|
325
|
+
env: mergeEnvironments(
|
|
326
|
+
this.options.projectRoot,
|
|
327
|
+
fromEnvironmentId(this.value.env),
|
|
328
|
+
env,
|
|
329
|
+
),
|
|
325
330
|
sourceAssetId: this.value.id,
|
|
326
331
|
sourcePath: fromProjectPath(
|
|
327
332
|
this.options.projectRoot,
|
|
@@ -386,7 +391,7 @@ export default class UncommittedAsset {
|
|
|
386
391
|
isSource: this.value.isSource,
|
|
387
392
|
env: mergeEnvironments(
|
|
388
393
|
this.options.projectRoot,
|
|
389
|
-
this.value.env,
|
|
394
|
+
fromEnvironmentId(this.value.env),
|
|
390
395
|
result.env,
|
|
391
396
|
),
|
|
392
397
|
dependencies:
|
package/src/applyRuntimes.js
CHANGED
|
@@ -34,6 +34,7 @@ import {createDevDependency, runDevDepRequest} from './requests/DevDepRequest';
|
|
|
34
34
|
import {toProjectPath, fromProjectPathRelative} from './projectPath';
|
|
35
35
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
36
36
|
import {DefaultMap} from '@atlaspack/utils';
|
|
37
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
37
38
|
|
|
38
39
|
type RuntimeConnection = {|
|
|
39
40
|
bundle: InternalBundle,
|
|
@@ -159,7 +160,11 @@ export default async function applyRuntimes<TResult: RequestResult>({
|
|
|
159
160
|
let assetGroup = {
|
|
160
161
|
code,
|
|
161
162
|
filePath: toProjectPath(options.projectRoot, sourceName),
|
|
162
|
-
env: mergeEnvironments(
|
|
163
|
+
env: mergeEnvironments(
|
|
164
|
+
options.projectRoot,
|
|
165
|
+
fromEnvironmentId(bundle.env),
|
|
166
|
+
env,
|
|
167
|
+
),
|
|
163
168
|
// Runtime assets should be considered source, as they should be
|
|
164
169
|
// e.g. compiled to run in the target environment
|
|
165
170
|
isSource: true,
|
package/src/assetUtils.js
CHANGED
|
@@ -16,7 +16,6 @@ import type {
|
|
|
16
16
|
Asset,
|
|
17
17
|
RequestInvalidation,
|
|
18
18
|
Dependency,
|
|
19
|
-
Environment,
|
|
20
19
|
AtlaspackOptions,
|
|
21
20
|
} from './types';
|
|
22
21
|
|
|
@@ -40,6 +39,8 @@ import {hashString, createAssetId as createAssetIdRust} from '@atlaspack/rust';
|
|
|
40
39
|
import {BundleBehavior as BundleBehaviorMap} from './types';
|
|
41
40
|
import {PluginTracer} from '@atlaspack/profiler';
|
|
42
41
|
import {identifierRegistry} from './IdentifierRegistry';
|
|
42
|
+
import type {EnvironmentRef} from './EnvironmentManager';
|
|
43
|
+
import {toEnvironmentId} from './EnvironmentManager';
|
|
43
44
|
|
|
44
45
|
export type AssetOptions = {|
|
|
45
46
|
id?: string,
|
|
@@ -56,7 +57,7 @@ export type AssetOptions = {|
|
|
|
56
57
|
bundleBehavior?: ?BundleBehavior,
|
|
57
58
|
isBundleSplittable?: ?boolean,
|
|
58
59
|
isSource: boolean,
|
|
59
|
-
env:
|
|
60
|
+
env: EnvironmentRef,
|
|
60
61
|
meta?: Meta,
|
|
61
62
|
outputHash?: ?string,
|
|
62
63
|
pipeline?: ?string,
|
|
@@ -71,7 +72,7 @@ export type AssetOptions = {|
|
|
|
71
72
|
|
|
72
73
|
export function createAssetIdFromOptions(options: AssetOptions): string {
|
|
73
74
|
const data = {
|
|
74
|
-
environmentId: options.env
|
|
75
|
+
environmentId: toEnvironmentId(options.env),
|
|
75
76
|
filePath: options.filePath,
|
|
76
77
|
code: options.code,
|
|
77
78
|
pipeline: options.pipeline,
|
package/src/public/Asset.js
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
BundleBehaviorNames,
|
|
37
37
|
} from '../types';
|
|
38
38
|
import {toInternalSourceLocation} from '../utils';
|
|
39
|
+
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
39
40
|
|
|
40
41
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
41
42
|
|
|
@@ -101,7 +102,10 @@ class BaseAsset {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
get env(): IEnvironment {
|
|
104
|
-
return new Environment(
|
|
105
|
+
return new Environment(
|
|
106
|
+
fromEnvironmentId(this.#asset.value.env),
|
|
107
|
+
this.#asset.options,
|
|
108
|
+
);
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
get fs(): FileSystem {
|
|
@@ -210,7 +214,10 @@ export class Asset extends BaseAsset implements IAsset {
|
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
get env(): IEnvironment {
|
|
213
|
-
this.#env ??= new Environment(
|
|
217
|
+
this.#env ??= new Environment(
|
|
218
|
+
fromEnvironmentId(this.#asset.value.env),
|
|
219
|
+
this.#asset.options,
|
|
220
|
+
);
|
|
214
221
|
return this.#env;
|
|
215
222
|
}
|
|
216
223
|
|
package/src/public/Bundle.js
CHANGED
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
import Target from './Target';
|
|
35
35
|
import {BundleBehaviorNames} from '../types';
|
|
36
36
|
import {fromProjectPath} from '../projectPath';
|
|
37
|
+
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
37
38
|
|
|
38
39
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
39
40
|
|
|
@@ -123,7 +124,7 @@ export class Bundle implements IBundle {
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
get env(): IEnvironment {
|
|
126
|
-
return new Environment(this.#bundle.env, this.#options);
|
|
127
|
+
return new Environment(fromEnvironmentId(this.#bundle.env), this.#options);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
get needsStableName(): ?boolean {
|
package/src/public/Config.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import Environment from './Environment';
|
|
22
22
|
import {fromProjectPath, toProjectPath} from '../projectPath';
|
|
23
23
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
24
|
+
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
24
25
|
|
|
25
26
|
const internalConfigToConfig: DefaultWeakMap<
|
|
26
27
|
AtlaspackOptions,
|
|
@@ -46,7 +47,7 @@ export default class PublicConfig implements IConfig {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
get env(): Environment {
|
|
49
|
-
return new Environment(this.#config.env, this.#options);
|
|
50
|
+
return new Environment(fromEnvironmentId(this.#config.env), this.#options);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
get searchPath(): FilePath {
|
package/src/public/Dependency.js
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
} from '../types';
|
|
28
28
|
import {fromProjectPath} from '../projectPath';
|
|
29
29
|
import {fromInternalSourceLocation} from '../utils';
|
|
30
|
+
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
30
31
|
|
|
31
32
|
const SpecifierTypeNames = Object.keys(SpecifierTypeMap);
|
|
32
33
|
const PriorityNames = Object.keys(Priority);
|
|
@@ -112,7 +113,7 @@ export default class Dependency implements IDependency {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
get env(): IEnvironment {
|
|
115
|
-
return new Environment(this.#dep.env, this.#options);
|
|
116
|
+
return new Environment(fromEnvironmentId(this.#dep.env), this.#options);
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
get packageConditions(): ?Array<string> {
|
|
@@ -32,6 +32,7 @@ import {BundleBehavior} from '../types';
|
|
|
32
32
|
import BundleGroup, {bundleGroupToInternalBundleGroup} from './BundleGroup';
|
|
33
33
|
import type {ProjectPath} from '../projectPath';
|
|
34
34
|
import {identifierRegistry} from '../IdentifierRegistry';
|
|
35
|
+
import {toEnvironmentRef} from '../EnvironmentManager';
|
|
35
36
|
|
|
36
37
|
function createBundleId(data: {|
|
|
37
38
|
entryAssetId: string | null,
|
|
@@ -236,7 +237,7 @@ export default class MutableBundleGraph
|
|
|
236
237
|
: bundleId.slice(-8),
|
|
237
238
|
type: opts.entryAsset ? opts.entryAsset.type : opts.type,
|
|
238
239
|
env: opts.env
|
|
239
|
-
? environmentToInternalEnvironment(opts.env)
|
|
240
|
+
? toEnvironmentRef(environmentToInternalEnvironment(opts.env))
|
|
240
241
|
: nullthrows(entryAsset).env,
|
|
241
242
|
entryAssetIds: entryAsset ? [entryAsset.id] : [],
|
|
242
243
|
mainEntryId: entryAsset?.id,
|