@atlaspack/core 2.16.2-dev.14 → 2.16.2-dev.1c70d50f9.99

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/lib/AssetGraph.js +27 -7
  3. package/lib/Atlaspack.js +10 -2
  4. package/lib/BundleGraph.js +6 -105
  5. package/lib/Dependency.js +6 -2
  6. package/lib/Environment.js +5 -3
  7. package/lib/EnvironmentManager.js +137 -0
  8. package/lib/InternalConfig.js +3 -2
  9. package/lib/PackagerRunner.js +52 -15
  10. package/lib/RequestTracker.js +313 -94
  11. package/lib/UncommittedAsset.js +20 -2
  12. package/lib/applyRuntimes.js +2 -1
  13. package/lib/assetUtils.js +2 -1
  14. package/lib/atlaspack-v3/worker/worker.js +8 -0
  15. package/lib/index.js +29 -1
  16. package/lib/public/Asset.js +3 -2
  17. package/lib/public/Bundle.js +2 -1
  18. package/lib/public/BundleGraph.js +21 -8
  19. package/lib/public/Config.js +91 -3
  20. package/lib/public/Dependency.js +2 -1
  21. package/lib/public/MutableBundleGraph.js +2 -1
  22. package/lib/public/Target.js +2 -1
  23. package/lib/requests/AssetGraphRequest.js +13 -1
  24. package/lib/requests/AssetGraphRequestRust.js +17 -2
  25. package/lib/requests/AssetRequest.js +2 -1
  26. package/lib/requests/BundleGraphRequest.js +13 -1
  27. package/lib/requests/ConfigRequest.js +27 -4
  28. package/lib/requests/DevDepRequest.js +21 -1
  29. package/lib/requests/PathRequest.js +10 -0
  30. package/lib/requests/TargetRequest.js +18 -16
  31. package/lib/requests/WriteBundleRequest.js +15 -3
  32. package/lib/requests/WriteBundlesRequest.js +1 -0
  33. package/lib/resolveOptions.js +4 -2
  34. package/package.json +18 -25
  35. package/src/AssetGraph.js +30 -7
  36. package/src/Atlaspack.js +13 -5
  37. package/src/BundleGraph.js +13 -175
  38. package/src/Dependency.js +13 -5
  39. package/src/Environment.js +9 -6
  40. package/src/EnvironmentManager.js +145 -0
  41. package/src/InternalConfig.js +6 -5
  42. package/src/PackagerRunner.js +72 -20
  43. package/src/RequestTracker.js +532 -150
  44. package/src/UncommittedAsset.js +23 -3
  45. package/src/applyRuntimes.js +6 -1
  46. package/src/assetUtils.js +4 -3
  47. package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
  48. package/src/atlaspack-v3/worker/worker.js +7 -0
  49. package/src/index.js +5 -1
  50. package/src/public/Asset.js +9 -2
  51. package/src/public/Bundle.js +2 -1
  52. package/src/public/BundleGraph.js +22 -15
  53. package/src/public/Config.js +128 -14
  54. package/src/public/Dependency.js +2 -1
  55. package/src/public/MutableBundleGraph.js +5 -2
  56. package/src/public/Target.js +2 -1
  57. package/src/requests/AssetGraphRequest.js +13 -3
  58. package/src/requests/AssetGraphRequestRust.js +14 -2
  59. package/src/requests/AssetRequest.js +2 -1
  60. package/src/requests/BundleGraphRequest.js +13 -3
  61. package/src/requests/ConfigRequest.js +33 -9
  62. package/src/requests/DevDepRequest.js +44 -12
  63. package/src/requests/PathRequest.js +4 -0
  64. package/src/requests/TargetRequest.js +19 -25
  65. package/src/requests/WriteBundleRequest.js +14 -8
  66. package/src/requests/WriteBundlesRequest.js +1 -0
  67. package/src/resolveOptions.js +4 -2
  68. package/src/types.js +10 -7
  69. package/test/Environment.test.js +43 -34
  70. package/test/EnvironmentManager.test.js +192 -0
  71. package/test/PublicEnvironment.test.js +10 -7
  72. package/test/RequestTracker.test.js +115 -3
  73. package/test/public/Config.test.js +108 -0
  74. package/test/requests/ConfigRequest.test.js +187 -3
  75. package/test/test-utils.js +4 -9
@@ -20,6 +20,7 @@ import invariant from 'assert';
20
20
  import assert from 'assert';
21
21
  import nullthrows from 'nullthrows';
22
22
  import {PluginLogger} from '@atlaspack/logger';
23
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
23
24
  import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
24
25
  import AssetGraph from '../AssetGraph';
25
26
  import BundleGraph from '../public/BundleGraph';
@@ -282,12 +283,21 @@ class BundlerRunner {
282
283
  this.pluginOptions = new PluginOptions(
283
284
  optionsProxy(this.options, api.invalidateOnOptionChange),
284
285
  );
285
- this.cacheKey =
286
- hashString(
286
+ if (getFeatureFlag('cachePerformanceImprovements')) {
287
+ const key = hashString(
287
288
  `${ATLASPACK_VERSION}:BundleGraph:${
288
289
  JSON.stringify(options.entries) ?? ''
289
290
  }${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
290
- ) + '-BundleGraph';
291
+ );
292
+ this.cacheKey = `BundleGraph/${ATLASPACK_VERSION}/${options.mode}/${key}`;
293
+ } else {
294
+ this.cacheKey =
295
+ hashString(
296
+ `${ATLASPACK_VERSION}:BundleGraph:${
297
+ JSON.stringify(options.entries) ?? ''
298
+ }${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
299
+ ) + '-BundleGraph';
300
+ }
291
301
  }
292
302
 
293
303
  async loadConfigs() {
@@ -63,7 +63,7 @@ export type ConfigRequest = {
63
63
  invalidateOnFileChange: Set<ProjectPath>,
64
64
  invalidateOnConfigKeyChange: Array<{|
65
65
  filePath: ProjectPath,
66
- configKey: string,
66
+ configKey: string[],
67
67
  |}>,
68
68
  invalidateOnFileCreate: Array<InternalFileCreateInvalidation>,
69
69
  invalidateOnEnvChange: Set<string>,
@@ -108,34 +108,58 @@ export async function loadPluginConfig<T: PluginWithLoadConfig>(
108
108
  }
109
109
  }
110
110
 
111
+ /**
112
+ * Return value at a given key path within an object.
113
+ *
114
+ * @example
115
+ * const obj = { a: { b: { c: 'd' } } };
116
+ * getValueAtPath(obj, ['a', 'b', 'c']); // 'd'
117
+ * getValueAtPath(obj, ['a', 'b', 'd']); // undefined
118
+ * getValueAtPath(obj, ['a', 'b']); // { c: 'd' }
119
+ * getValueAtPath(obj, ['a', 'b', 'c', 'd']); // undefined
120
+ */
121
+ export function getValueAtPath(obj: Object, key: string[]): any {
122
+ let current = obj;
123
+ for (let part of key) {
124
+ if (current == null) {
125
+ return undefined;
126
+ }
127
+ current = current[part];
128
+ }
129
+ return current;
130
+ }
131
+
111
132
  const configKeyCache = createBuildCache();
112
133
 
113
134
  export async function getConfigKeyContentHash(
114
135
  filePath: ProjectPath,
115
- configKey: string,
136
+ configKey: string[],
116
137
  options: AtlaspackOptions,
117
138
  ): Async<string> {
118
- let cacheKey = `${fromProjectPathRelative(filePath)}:${configKey}`;
139
+ let cacheKey = `${fromProjectPathRelative(filePath)}:${JSON.stringify(
140
+ configKey,
141
+ )}`;
119
142
  let cachedValue = configKeyCache.get(cacheKey);
120
143
 
121
144
  if (cachedValue) {
122
145
  return cachedValue;
123
146
  }
124
147
 
125
- let conf = await readConfig(
148
+ const conf = await readConfig(
126
149
  options.inputFS,
127
150
  fromProjectPath(options.projectRoot, filePath),
128
151
  );
129
152
 
130
- if (conf == null || conf.config[configKey] == null) {
153
+ const value = getValueAtPath(conf?.config, configKey);
154
+ if (conf == null || value == null) {
131
155
  // This can occur when a config key has been removed entirely during `respondToFSEvents`
132
156
  return '';
133
157
  }
134
158
 
135
- let contentHash =
136
- typeof conf.config[configKey] === 'object'
137
- ? hashObject(conf.config[configKey])
138
- : hashString(JSON.stringify(conf.config[configKey]));
159
+ const contentHash =
160
+ typeof value === 'object'
161
+ ? hashObject(value)
162
+ : hashString(JSON.stringify(value));
139
163
 
140
164
  configKeyCache.set(cacheKey, contentHash);
141
165
 
@@ -1,4 +1,5 @@
1
- // @flow
1
+ // @flow strict-local
2
+
2
3
  import type {
3
4
  DependencySpecifier,
4
5
  SemverRange,
@@ -24,6 +25,7 @@ import {
24
25
  toProjectPath,
25
26
  } from '../projectPath';
26
27
  import {requestTypes} from '../RequestTracker';
28
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
27
29
 
28
30
  // A cache of dev dep requests keyed by invalidations.
29
31
  // If the package manager returns the same invalidation object, then
@@ -116,17 +118,47 @@ type DevDepRequests = {|
116
118
  export async function getDevDepRequests<TResult: RequestResult>(
117
119
  api: RunAPI<TResult>,
118
120
  ): Promise<DevDepRequests> {
119
- let previousDevDepRequests: Map<string, DevDepRequestResult> = new Map(
120
- await Promise.all(
121
- api
122
- .getSubRequests()
123
- .filter((req) => req.requestType === requestTypes.dev_dep_request)
124
- .map(async (req) => [
125
- req.id,
126
- nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
127
- ]),
128
- ),
129
- );
121
+ async function getPreviousDevDepRequests() {
122
+ if (getFeatureFlag('fixBuildAbortCorruption')) {
123
+ const allDevDepRequests = await Promise.all(
124
+ api
125
+ .getSubRequests()
126
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
127
+ .map(
128
+ async (
129
+ req,
130
+ ): Promise<[string, DevDepRequestResult | null | void]> => [
131
+ req.id,
132
+ await api.getRequestResult<DevDepRequestResult>(req.id),
133
+ ],
134
+ ),
135
+ );
136
+ const nonNullDevDepRequests = [];
137
+ for (const [id, result] of allDevDepRequests) {
138
+ if (result != null) {
139
+ nonNullDevDepRequests.push([id, result]);
140
+ }
141
+ }
142
+
143
+ return new Map(nonNullDevDepRequests);
144
+ } else {
145
+ return new Map(
146
+ await Promise.all(
147
+ api
148
+ .getSubRequests()
149
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
150
+ .map(async (req) => [
151
+ req.id,
152
+ nullthrows(
153
+ await api.getRequestResult<DevDepRequestResult>(req.id),
154
+ ),
155
+ ]),
156
+ ),
157
+ );
158
+ }
159
+ }
160
+
161
+ const previousDevDepRequests = await getPreviousDevDepRequests();
130
162
 
131
163
  return {
132
164
  devDeps: new Map(
@@ -24,6 +24,7 @@ import ThrowableDiagnostic, {
24
24
  md,
25
25
  } from '@atlaspack/diagnostic';
26
26
  import {PluginLogger} from '@atlaspack/logger';
27
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
27
28
  import nullthrows from 'nullthrows';
28
29
  import path from 'path';
29
30
  import {normalizePath} from '@atlaspack/utils';
@@ -320,6 +321,9 @@ export class ResolverRunner {
320
321
 
321
322
  if (result.priority != null) {
322
323
  dependency.priority = Priority[result.priority];
324
+ if (getFeatureFlag('hmrImprovements')) {
325
+ dependency.resolverPriority = dependency.priority;
326
+ }
323
327
  }
324
328
 
325
329
  if (result.invalidateOnEnvChange) {
@@ -49,6 +49,7 @@ import {BROWSER_ENVS} from '../public/Environment';
49
49
  import {optionsProxy, toInternalSourceLocation} from '../utils';
50
50
  import {fromProjectPath, toProjectPath, joinProjectPath} from '../projectPath';
51
51
  import {requestTypes} from '../RequestTracker';
52
+ import {fromEnvironmentId} from '../EnvironmentManager';
52
53
 
53
54
  type RunOpts<TResult> = {|
54
55
  input: Entry,
@@ -345,7 +346,7 @@ export class TargetResolver {
345
346
  },
346
347
  });
347
348
  }
348
- if (!BROWSER_ENVS.has(targets[0].env.context)) {
349
+ if (!BROWSER_ENVS.has(fromEnvironmentId(targets[0].env).context)) {
349
350
  throw new ThrowableDiagnostic({
350
351
  diagnostic: {
351
352
  message: `Only browser targets are supported in serve mode`,
@@ -1491,21 +1492,22 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1491
1492
 
1492
1493
  // Resolve relevant engines for context.
1493
1494
  let engines;
1494
- switch (target.env.context) {
1495
+ const env = fromEnvironmentId(target.env);
1496
+ switch (env.context) {
1495
1497
  case 'browser':
1496
1498
  case 'web-worker':
1497
1499
  case 'service-worker':
1498
1500
  case 'worklet': {
1499
- let browsers = target.env.engines.browsers;
1501
+ let browsers = env.engines.browsers;
1500
1502
  engines = Array.isArray(browsers) ? browsers.join(', ') : browsers;
1501
1503
  break;
1502
1504
  }
1503
1505
  case 'node':
1504
- engines = target.env.engines.node;
1506
+ engines = env.engines.node;
1505
1507
  break;
1506
1508
  case 'electron-main':
1507
1509
  case 'electron-renderer':
1508
- engines = target.env.engines.electron;
1510
+ engines = env.engines.electron;
1509
1511
  break;
1510
1512
  }
1511
1513
 
@@ -1547,9 +1549,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1547
1549
  }
1548
1550
 
1549
1551
  if (keyInfo.inferred) {
1550
- highlight.inferred.push(
1551
- md`${key} to be ${JSON.stringify(target.env[key])}`,
1552
- );
1552
+ highlight.inferred.push(md`${key} to be ${JSON.stringify(env[key])}`);
1553
1553
  }
1554
1554
  }
1555
1555
 
@@ -1578,22 +1578,20 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1578
1578
 
1579
1579
  // Format includeNodeModules to be human readable.
1580
1580
  let includeNodeModules;
1581
- if (typeof target.env.includeNodeModules === 'boolean') {
1582
- includeNodeModules = String(target.env.includeNodeModules);
1583
- } else if (Array.isArray(target.env.includeNodeModules)) {
1581
+ if (typeof env.includeNodeModules === 'boolean') {
1582
+ includeNodeModules = String(env.includeNodeModules);
1583
+ } else if (Array.isArray(env.includeNodeModules)) {
1584
1584
  includeNodeModules =
1585
1585
  'only ' +
1586
- listFormat.format(
1587
- target.env.includeNodeModules.map((m) => JSON.stringify(m)),
1588
- );
1586
+ listFormat.format(env.includeNodeModules.map((m) => JSON.stringify(m)));
1589
1587
  } else if (
1590
- target.env.includeNodeModules &&
1591
- typeof target.env.includeNodeModules === 'object'
1588
+ env.includeNodeModules &&
1589
+ typeof env.includeNodeModules === 'object'
1592
1590
  ) {
1593
1591
  includeNodeModules =
1594
1592
  'all except ' +
1595
1593
  listFormat.format(
1596
- Object.entries(target.env.includeNodeModules)
1594
+ Object.entries(env.includeNodeModules)
1597
1595
  .filter(([, v]) => v === false)
1598
1596
  .map(([k]) => JSON.stringify(k)),
1599
1597
  );
@@ -1609,18 +1607,14 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1609
1607
  fromProjectPath(options.projectRoot, input.filePath),
1610
1608
  )}
1611
1609
  **Output**: ${path.relative(process.cwd(), output)}
1612
- **Format**: ${target.env.outputFormat} ${format(
1613
- info.outputFormat,
1614
- )}
1615
- **Context**: ${target.env.context} ${format(info.context)}
1610
+ **Format**: ${env.outputFormat} ${format(info.outputFormat)}
1611
+ **Context**: ${env.context} ${format(info.context)}
1616
1612
  **Engines**: ${engines || ''} ${format(info.engines)}
1617
- **Library Mode**: ${String(target.env.isLibrary)} ${format(
1618
- info.isLibrary,
1619
- )}
1613
+ **Library Mode**: ${String(env.isLibrary)} ${format(info.isLibrary)}
1620
1614
  **Include Node Modules**: ${includeNodeModules} ${format(
1621
1615
  info.includeNodeModules,
1622
1616
  )}
1623
- **Optimize**: ${String(target.env.shouldOptimize)} ${format(
1617
+ **Optimize**: ${String(env.shouldOptimize)} ${format(
1624
1618
  info.shouldOptimize,
1625
1619
  )}`,
1626
1620
  codeFrames: target.loc
@@ -40,6 +40,8 @@ import {AtlaspackConfig} from '../AtlaspackConfig';
40
40
  import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
41
41
  import {PluginTracer, tracer} from '@atlaspack/profiler';
42
42
  import {requestTypes} from '../RequestTracker';
43
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
44
+ import {fromEnvironmentId} from '../EnvironmentManager';
43
45
 
44
46
  const HASH_REF_PREFIX_LEN = HASH_REF_PREFIX.length;
45
47
  const BOUNDARY_LENGTH = HASH_REF_PREFIX.length + 32 - 1;
@@ -110,7 +112,9 @@ async function run({input, options, api}) {
110
112
  let cacheKeys = info.cacheKeys;
111
113
  let mapKey = cacheKeys.map;
112
114
  let fullPath = fromProjectPath(options.projectRoot, filePath);
113
- if (mapKey && bundle.env.sourceMap && !bundle.env.sourceMap.inline) {
115
+ const env = fromEnvironmentId(bundle.env);
116
+
117
+ if (mapKey && env.sourceMap && !env.sourceMap.inline) {
114
118
  api.invalidateOnFileDelete(
115
119
  toProjectPath(options.projectRoot, fullPath + '.map'),
116
120
  );
@@ -167,14 +171,15 @@ async function run({input, options, api}) {
167
171
  api,
168
172
  );
169
173
 
170
- if (
171
- mapKey &&
172
- bundle.env.sourceMap &&
173
- !bundle.env.sourceMap.inline &&
174
- (await options.cache.has(mapKey))
175
- ) {
174
+ const hasSourceMap = getFeatureFlag('cachePerformanceImprovements')
175
+ ? await options.cache.hasLargeBlob(mapKey)
176
+ : await options.cache.has(mapKey);
177
+ if (mapKey && env.sourceMap && !env.sourceMap.inline && hasSourceMap) {
178
+ const mapEntry = getFeatureFlag('cachePerformanceImprovements')
179
+ ? await options.cache.getLargeBlob(mapKey)
180
+ : await options.cache.getBlob(mapKey);
176
181
  await writeFiles(
177
- blobToStream(await options.cache.getBlob(mapKey)),
182
+ blobToStream(mapEntry),
178
183
  info,
179
184
  hashRefToNameHash,
180
185
  options,
@@ -189,6 +194,7 @@ async function run({input, options, api}) {
189
194
 
190
195
  let res = {
191
196
  filePath,
197
+ bundleId: bundle.id,
192
198
  type: info.type,
193
199
  stats: {
194
200
  size,
@@ -84,6 +84,7 @@ async function run({input, api, farm, options}) {
84
84
  ).replace(bundle.hashReference, hash);
85
85
  res.set(bundle.id, {
86
86
  filePath: joinProjectPath(bundle.target.distDir, name),
87
+ bundleId: bundle.id,
87
88
  type: bundle.type, // FIXME: this is wrong if the packager changes the type...
88
89
  stats: {
89
90
  time: 0,
@@ -153,8 +153,10 @@ export default async function resolveOptions(
153
153
 
154
154
  const needsRustLmdbCache = getFeatureFlag('atlaspackV3');
155
155
 
156
- if (!needsRustLmdbCache && !(outputFS instanceof NodeFS)) {
157
- return new FSCache(outputFS, cacheDir);
156
+ if (!getFeatureFlag('cachePerformanceImprovements')) {
157
+ if (!needsRustLmdbCache && !(outputFS instanceof NodeFS)) {
158
+ return new FSCache(outputFS, cacheDir);
159
+ }
158
160
  }
159
161
 
160
162
  return new LMDBLiteCache(cacheDir);
package/src/types.js CHANGED
@@ -34,6 +34,7 @@ import type {ProjectPath} from './projectPath';
34
34
  import type {Event} from '@parcel/watcher';
35
35
  import type {FeatureFlags} from '@atlaspack/feature-flags';
36
36
  import type {BackendType} from '@parcel/watcher';
37
+ import type {EnvironmentRef} from './EnvironmentManager';
37
38
 
38
39
  export type AtlaspackPluginNode = {|
39
40
  packageName: PackageName,
@@ -97,7 +98,7 @@ export type InternalSourceLocation = {|
97
98
  export type Target = {|
98
99
  distEntry?: ?FilePath,
99
100
  distDir: ProjectPath,
100
- env: Environment,
101
+ env: EnvironmentRef,
101
102
  name: string,
102
103
  publicUrl: string,
103
104
  loc?: ?InternalSourceLocation,
@@ -139,11 +140,12 @@ export type Dependency = {|
139
140
  isEntry: boolean,
140
141
  isOptional: boolean,
141
142
  loc: ?InternalSourceLocation,
142
- env: Environment,
143
+ env: EnvironmentRef,
143
144
  packageConditions?: number,
144
145
  customPackageConditions?: Array<string>,
145
146
  meta: Meta,
146
147
  resolverMeta?: ?Meta,
148
+ resolverPriority?: $Values<typeof Priority>,
147
149
  target: ?Target,
148
150
  sourceAssetId: ?string,
149
151
  sourcePath: ?ProjectPath,
@@ -180,7 +182,7 @@ export type Asset = {|
180
182
  bundleBehavior: ?$Values<typeof BundleBehavior>,
181
183
  isBundleSplittable: boolean,
182
184
  isSource: boolean,
183
- env: Environment,
185
+ env: EnvironmentRef,
184
186
  meta: Meta,
185
187
  stats: Stats,
186
188
  contentKey: ?string,
@@ -388,7 +390,7 @@ export type RootNode = {|id: ContentKey, +type: 'root', value: string | null|};
388
390
  export type AssetRequestInput = {|
389
391
  name?: string, // AssetGraph name, needed so that different graphs can isolated requests since the results are not stored
390
392
  filePath: ProjectPath,
391
- env: Environment,
393
+ env: EnvironmentRef,
392
394
  isSource?: boolean,
393
395
  canDefer?: boolean,
394
396
  sideEffects?: boolean,
@@ -492,13 +494,13 @@ export type Config = {|
492
494
  id: string,
493
495
  isSource: boolean,
494
496
  searchPath: ProjectPath,
495
- env: Environment,
497
+ env: EnvironmentRef,
496
498
  cacheKey: ?string,
497
499
  result: ConfigResult,
498
500
  invalidateOnFileChange: Set<ProjectPath>,
499
501
  invalidateOnConfigKeyChange: Array<{|
500
502
  filePath: ProjectPath,
501
- configKey: string,
503
+ configKey: string[],
502
504
  |}>,
503
505
  invalidateOnFileCreate: Array<InternalFileCreateInvalidation>,
504
506
  invalidateOnEnvChange: Set<string>,
@@ -539,7 +541,7 @@ export type Bundle = {|
539
541
  publicId: ?string,
540
542
  hashReference: string,
541
543
  type: string,
542
- env: Environment,
544
+ env: EnvironmentRef,
543
545
  entryAssetIds: Array<ContentKey>,
544
546
  mainEntryId: ?ContentKey,
545
547
  needsStableName: ?boolean,
@@ -573,6 +575,7 @@ export type BundleGroupNode = {|
573
575
 
574
576
  export type PackagedBundleInfo = {|
575
577
  filePath: ProjectPath,
578
+ bundleId: ContentKey,
576
579
  type: string,
577
580
  stats: Stats,
578
581
  |};
@@ -5,10 +5,11 @@ import assert from 'assert';
5
5
  import expect from 'expect';
6
6
  import {createEnvironment} from '../src/Environment';
7
7
  import {initializeMonitoring} from '../../rust';
8
+ import {fromEnvironmentId} from '../src/EnvironmentManager';
8
9
 
9
10
  describe('Environment', () => {
10
11
  it('assigns a default environment with nothing passed', () => {
11
- assert.deepEqual(createEnvironment(), {
12
+ assert.deepEqual(fromEnvironmentId(createEnvironment()), {
12
13
  id: 'd821e85f6b50315e',
13
14
  context: 'browser',
14
15
  engines: {
@@ -27,27 +28,32 @@ describe('Environment', () => {
27
28
  });
28
29
 
29
30
  it('assigns a node context if a node engine is given', () => {
30
- assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), {
31
- id: '2320af923a717577',
32
- context: 'node',
33
- engines: {
34
- node: '>= 10.0.0',
31
+ assert.deepEqual(
32
+ fromEnvironmentId(createEnvironment({engines: {node: '>= 10.0.0'}})),
33
+ {
34
+ id: '2320af923a717577',
35
+ context: 'node',
36
+ engines: {
37
+ node: '>= 10.0.0',
38
+ },
39
+ includeNodeModules: false,
40
+ outputFormat: 'commonjs',
41
+ isLibrary: false,
42
+ shouldOptimize: false,
43
+ shouldScopeHoist: false,
44
+ sourceMap: undefined,
45
+ loc: undefined,
46
+ sourceType: 'module',
47
+ unstableSingleFileOutput: false,
35
48
  },
36
- includeNodeModules: false,
37
- outputFormat: 'commonjs',
38
- isLibrary: false,
39
- shouldOptimize: false,
40
- shouldScopeHoist: false,
41
- sourceMap: undefined,
42
- loc: undefined,
43
- sourceType: 'module',
44
- unstableSingleFileOutput: false,
45
- });
49
+ );
46
50
  });
47
51
 
48
52
  it('assigns a browser context if browser engines are given', () => {
49
53
  assert.deepEqual(
50
- createEnvironment({engines: {browsers: ['last 1 version']}}),
54
+ fromEnvironmentId(
55
+ createEnvironment({engines: {browsers: ['last 1 version']}}),
56
+ ),
51
57
  {
52
58
  id: '75603271034eff15',
53
59
  context: 'browser',
@@ -68,7 +74,7 @@ describe('Environment', () => {
68
74
  });
69
75
 
70
76
  it('assigns default engines for node', () => {
71
- assert.deepEqual(createEnvironment({context: 'node'}), {
77
+ assert.deepEqual(fromEnvironmentId(createEnvironment({context: 'node'})), {
72
78
  id: 'e45cc12216f7857d',
73
79
  context: 'node',
74
80
  engines: {
@@ -87,22 +93,25 @@ describe('Environment', () => {
87
93
  });
88
94
 
89
95
  it('assigns default engines for browsers', () => {
90
- assert.deepEqual(createEnvironment({context: 'browser'}), {
91
- id: 'd821e85f6b50315e',
92
- context: 'browser',
93
- engines: {
94
- browsers: ['> 0.25%'],
96
+ assert.deepEqual(
97
+ fromEnvironmentId(createEnvironment({context: 'browser'})),
98
+ {
99
+ id: 'd821e85f6b50315e',
100
+ context: 'browser',
101
+ engines: {
102
+ browsers: ['> 0.25%'],
103
+ },
104
+ includeNodeModules: true,
105
+ outputFormat: 'global',
106
+ isLibrary: false,
107
+ shouldOptimize: false,
108
+ shouldScopeHoist: false,
109
+ sourceMap: undefined,
110
+ loc: undefined,
111
+ sourceType: 'module',
112
+ unstableSingleFileOutput: false,
95
113
  },
96
- includeNodeModules: true,
97
- outputFormat: 'global',
98
- isLibrary: false,
99
- shouldOptimize: false,
100
- shouldScopeHoist: false,
101
- sourceMap: undefined,
102
- loc: undefined,
103
- sourceType: 'module',
104
- unstableSingleFileOutput: false,
105
- });
114
+ );
106
115
  });
107
116
  });
108
117
 
@@ -114,6 +123,6 @@ describe('createEnvironment', function () {
114
123
  /* ignore */
115
124
  }
116
125
  const environment = createEnvironment({});
117
- expect(environment.id).toEqual('d821e85f6b50315e');
126
+ expect(fromEnvironmentId(environment).id).toEqual('d821e85f6b50315e');
118
127
  });
119
128
  });