@atlaspack/core 2.12.1-dev.3401 → 2.12.1-dev.3450

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 (70) hide show
  1. package/lib/AssetGraph.js +1 -2
  2. package/lib/Atlaspack.js +25 -3
  3. package/lib/AtlaspackConfig.schema.js +10 -36
  4. package/lib/BundleGraph.js +59 -5
  5. package/lib/Dependency.js +46 -1
  6. package/lib/Environment.js +12 -2
  7. package/lib/PackagerRunner.js +3 -45
  8. package/lib/RequestTracker.js +112 -30
  9. package/lib/SymbolPropagation.js +1 -1
  10. package/lib/Transformation.js +1 -15
  11. package/lib/UncommittedAsset.js +4 -4
  12. package/lib/Validation.js +1 -13
  13. package/lib/applyRuntimes.js +96 -20
  14. package/lib/assetUtils.js +9 -3
  15. package/lib/atlaspack-v3/AtlaspackV3.js +6 -8
  16. package/lib/atlaspack-v3/fs.js +8 -1
  17. package/lib/atlaspack-v3/worker/compat.js +57 -0
  18. package/lib/atlaspack-v3/worker/worker.js +247 -1
  19. package/lib/public/BundleGraph.js +68 -0
  20. package/lib/requests/AssetGraphRequestRust.js +79 -12
  21. package/lib/requests/BundleGraphRequest.js +19 -0
  22. package/lib/requests/WriteBundleRequest.js +15 -15
  23. package/lib/requests/asset-graph-diff.js +128 -0
  24. package/lib/resolveOptions.js +15 -8
  25. package/lib/types.js +2 -1
  26. package/package.json +19 -17
  27. package/src/AssetGraph.js +1 -1
  28. package/src/Atlaspack.js +28 -6
  29. package/src/AtlaspackConfig.schema.js +13 -36
  30. package/src/BundleGraph.js +77 -1
  31. package/src/CommittedAsset.js +1 -1
  32. package/src/Dependency.js +50 -12
  33. package/src/Environment.js +13 -15
  34. package/src/PackagerRunner.js +5 -53
  35. package/src/RequestTracker.js +144 -38
  36. package/src/SymbolPropagation.js +5 -2
  37. package/src/Transformation.js +1 -9
  38. package/src/UncommittedAsset.js +6 -6
  39. package/src/Validation.js +1 -7
  40. package/src/applyRuntimes.js +86 -22
  41. package/src/assetUtils.js +12 -19
  42. package/src/atlaspack-v3/AtlaspackV3.js +8 -11
  43. package/src/atlaspack-v3/fs.js +8 -3
  44. package/src/atlaspack-v3/jsCallable.js +4 -0
  45. package/src/atlaspack-v3/worker/compat.js +82 -0
  46. package/src/atlaspack-v3/worker/worker.js +300 -2
  47. package/src/public/BundleGraph.js +106 -0
  48. package/src/requests/AssetGraphRequestRust.js +105 -17
  49. package/src/requests/BundleGraphRequest.js +18 -0
  50. package/src/requests/WriteBundleRequest.js +17 -23
  51. package/src/requests/asset-graph-diff.js +145 -0
  52. package/src/resolveOptions.js +12 -2
  53. package/src/types.js +10 -0
  54. package/test/AssetGraph.test.js +23 -9
  55. package/test/AtlaspackConfigRequest.test.js +0 -161
  56. package/test/BundleGraph.test.js +8 -3
  57. package/test/Dependency.test.js +21 -0
  58. package/test/Environment.test.js +16 -5
  59. package/test/InternalAsset.test.js +8 -2
  60. package/test/PublicAsset.test.js +6 -2
  61. package/test/PublicBundle.test.js +1 -0
  62. package/test/PublicMutableBundleGraph.test.js +9 -4
  63. package/test/RequestTracker.test.js +139 -2
  64. package/test/SymbolPropagation.test.js +1 -0
  65. package/test/TargetRequest.test.js +25 -25
  66. package/test/requests/WriteBundleRequest.test.js +132 -0
  67. package/lib/atlaspack-v3/plugins/Resolver.js +0 -12
  68. package/lib/atlaspack-v3/plugins/index.js +0 -16
  69. package/src/atlaspack-v3/plugins/Resolver.js +0 -9
  70. package/src/atlaspack-v3/plugins/index.js +0 -3
@@ -1,14 +1,312 @@
1
1
  // @flow
2
+ import assert from 'assert';
2
3
  import * as napi from '@atlaspack/rust';
4
+ import {NodeFS} from '@atlaspack/fs';
5
+ import {NodePackageManager} from '@atlaspack/package-manager';
6
+ import type {
7
+ Resolver,
8
+ Transformer,
9
+ PluginOptions,
10
+ Dependency,
11
+ FilePath,
12
+ FileSystem,
13
+ ConfigResultWithFilePath,
14
+ PackageJSON,
15
+ } from '@atlaspack/types';
3
16
  import {workerData} from 'worker_threads';
4
- import type {ResolverNapi} from '../plugins/Resolver';
17
+ import * as module from 'module';
18
+
19
+ import {AssetCompat} from './compat';
20
+ import type {InnerAsset} from './compat';
21
+ import {jsCallable} from '../jsCallable';
22
+ import type {JsCallable} from '../jsCallable';
23
+ import Environment from '../../public/Environment';
24
+
25
+ const CONFIG = Symbol.for('parcel-plugin-config');
5
26
 
6
27
  export class AtlaspackWorker {
7
- #resolvers: Map<string, ResolverNapi>;
28
+ #resolvers: Map<string, ResolverState<any>>;
29
+ #fs: FileSystem;
30
+
31
+ constructor() {
32
+ this.#resolvers = new Map();
33
+ this.#fs = new NodeFS();
34
+ }
35
+
36
+ loadPlugin: JsCallable<[LoadPluginOptions], Promise<void>> = jsCallable(
37
+ async ({kind, specifier, resolveFrom}) => {
38
+ let customRequire = module.createRequire(resolveFrom);
39
+ let resolvedPath = customRequire.resolve(specifier);
40
+ // $FlowFixMe
41
+ let resolvedModule = await import(resolvedPath);
42
+
43
+ let instance = undefined;
44
+ if (resolvedModule.default && resolvedModule.default[CONFIG]) {
45
+ instance = resolvedModule.default[CONFIG];
46
+ } else if (
47
+ resolvedModule.default &&
48
+ resolvedModule.default.default &&
49
+ resolvedModule.default.default[CONFIG]
50
+ ) {
51
+ instance = resolvedModule.default.default[CONFIG];
52
+ } else {
53
+ throw new Error(
54
+ `Plugin could not be resolved\n\t${kind}\n\t${resolveFrom}\n\t${specifier}`,
55
+ );
56
+ }
57
+
58
+ switch (kind) {
59
+ case 'resolver':
60
+ this.#resolvers.set(specifier, {resolver: instance});
61
+ break;
62
+ }
63
+ },
64
+ );
65
+
66
+ runResolverResolve: JsCallable<
67
+ [RunResolverResolveOptions],
68
+ Promise<RunResolverResolveResult>,
69
+ > = jsCallable(
70
+ async ({key, dependency, specifier, pipeline, projectRoot}) => {
71
+ const state = this.#resolvers.get(key);
72
+ if (!state) {
73
+ throw new Error(`Resolver not found: ${key}`);
74
+ }
75
+
76
+ let packageManager = state.packageManager;
77
+ if (!packageManager) {
78
+ packageManager = new NodePackageManager(this.#fs, projectRoot);
79
+ state.packageManager = packageManager;
80
+ }
81
+
82
+ const defaultOptions = {
83
+ get logger() {
84
+ // $FlowFixMe
85
+ return globalThis.console;
86
+ },
87
+ tracer: {
88
+ enabled: false,
89
+ createMeasurement: () => null,
90
+ },
91
+ options: {
92
+ get mode() {
93
+ throw new Error('Resolver.resolve.options.mode');
94
+ },
95
+ parcelVersion: 'TODO',
96
+ packageManager,
97
+ env: process.env,
98
+ get hmrOptions() {
99
+ throw new Error('Resolver.resolve.options.hmrOptions');
100
+ },
101
+ get serveOptions() {
102
+ throw new Error('Resolver.resolve.options.serveOptions');
103
+ },
104
+ get shouldBuildLazily() {
105
+ throw new Error('Resolver.resolve.options.shouldBuildLazily');
106
+ },
107
+ shouldAutoInstall: false,
108
+ get logLevel() {
109
+ throw new Error('Resolver.resolve.options.logLevel');
110
+ },
111
+ projectRoot,
112
+ get cacheDir() {
113
+ throw new Error('Resolver.resolve.options.cacheDir');
114
+ },
115
+ inputFS: this.#fs,
116
+ outputFS: this.#fs,
117
+ get instanceId() {
118
+ throw new Error('Resolver.resolve.options.instanceId');
119
+ },
120
+ get detailedReport() {
121
+ throw new Error('Resolver.resolve.options.detailedReport');
122
+ },
123
+ get featureFlags() {
124
+ throw new Error('Resolver.resolve.options.featureFlags');
125
+ },
126
+ },
127
+ };
128
+
129
+ if (!('config' in state)) {
130
+ state.config = await state.resolver.loadConfig?.({
131
+ config: {
132
+ isSource: true,
133
+ searchPath: '',
134
+ // $FlowFixMe This isn't correct to flow but is enough to satisfy the runtime checks
135
+ env: new Environment(dependency.env, {
136
+ projectRoot,
137
+ hmrOptions: undefined,
138
+ }),
139
+ invalidateOnFileChange(): void {},
140
+ invalidateOnFileCreate(): void {},
141
+ invalidateOnEnvChange(): void {},
142
+ invalidateOnStartup(): void {},
143
+ invalidateOnBuild(): void {},
144
+ addDevDependency(): void {},
145
+ setCacheKey(): void {},
146
+ getConfig<T>(): Promise<?ConfigResultWithFilePath<T>> {
147
+ throw new Error('Resolver.loadConfig.config.getConfig');
148
+ },
149
+ getConfigFrom<T>(): Promise<?ConfigResultWithFilePath<T>> {
150
+ throw new Error('Resolver.loadConfig.config.getConfigFrom');
151
+ },
152
+ getPackage(): Promise<?PackageJSON> {
153
+ throw new Error('Resolver.loadConfig.config.getPackage');
154
+ },
155
+ },
156
+ ...defaultOptions,
157
+ });
158
+ }
159
+
160
+ const result = await state.resolver.resolve({
161
+ specifier,
162
+ dependency,
163
+ pipeline,
164
+ config: state.config,
165
+ ...defaultOptions,
166
+ });
167
+
168
+ if (!result) {
169
+ return {
170
+ invalidations: [],
171
+ resolution: {type: 'unresolved'},
172
+ };
173
+ }
174
+
175
+ return {
176
+ invalidations: [],
177
+ resolution: {
178
+ type: 'resolved',
179
+ filePath: result.filePath || '',
180
+ canDefer: result.canDefer || false,
181
+ sideEffects: result.sideEffects || false,
182
+ code: result.code || undefined,
183
+ meta: result.meta || undefined,
184
+ pipeline: result.pipeline || undefined,
185
+ priority: result.priority && PriorityMap[result.priority],
186
+ query: result.query && result.query.toString(),
187
+ },
188
+ };
189
+ },
190
+ );
8
191
 
9
192
  ping() {
10
193
  // console.log('Hi');
11
194
  }
195
+
196
+ async runTransformer({
197
+ resolveFrom,
198
+ specifier,
199
+ options,
200
+ asset,
201
+ }: {|
202
+ resolveFrom: string,
203
+ specifier: string,
204
+ options: PluginOptions,
205
+ asset: InnerAsset,
206
+ |}): any {
207
+ const customRequire = module.createRequire(resolveFrom);
208
+ const resolvedPath = customRequire.resolve(specifier);
209
+ // $FlowFixMe
210
+ const transformerModule = await import(resolvedPath);
211
+ const transformer: Transformer<*> =
212
+ transformerModule.default.default[CONFIG];
213
+
214
+ let assetCompat = new AssetCompat(asset, options);
215
+
216
+ try {
217
+ if (transformer.parse) {
218
+ // $FlowFixMe
219
+ const ast = await transformer.parse({asset: assetCompat}); // missing "config"
220
+ // $FlowFixMe
221
+ assetCompat.setAST(ast);
222
+ }
223
+
224
+ // $FlowFixMe
225
+ const result = await transformer.transform({
226
+ // $FlowFixMe
227
+ asset: assetCompat,
228
+ options,
229
+ config: null,
230
+ });
231
+
232
+ if (transformer.generate) {
233
+ // $FlowFixMe
234
+ let output = await transformer.generate({
235
+ // $FlowFixMe
236
+ asset: assetCompat,
237
+ // $FlowFixMe
238
+ ast: assetCompat.getAST(),
239
+ });
240
+ // $FlowFixMe
241
+ assetCompat.setCode(output.content);
242
+ }
243
+
244
+ assert(
245
+ result.length === 1,
246
+ '[V3] Unimplemented: Multiple asset return from Node transformer',
247
+ );
248
+ assert(
249
+ result[0] === assetCompat,
250
+ '[V3] Unimplemented: New asset returned from Node transformer',
251
+ );
252
+
253
+ return {
254
+ asset,
255
+ dependencies: assetCompat._dependencies,
256
+ };
257
+ } catch (e) {
258
+ // TODO: Improve error logging from JS plugins. Without this you currently
259
+ // only see the error message, no stack trace.
260
+ // eslint-disable-next-line no-console
261
+ console.error(e);
262
+ throw e;
263
+ }
264
+ }
12
265
  }
13
266
 
14
267
  napi.registerWorker(workerData.tx_worker, new AtlaspackWorker());
268
+
269
+ type ResolverState<T> = {|
270
+ resolver: Resolver<T>,
271
+ config?: T,
272
+ packageManager?: NodePackageManager,
273
+ |};
274
+
275
+ type LoadPluginOptions = {|
276
+ kind: 'resolver',
277
+ specifier: string,
278
+ resolveFrom: string,
279
+ |};
280
+
281
+ type RunResolverResolveOptions = {|
282
+ key: string,
283
+ dependency: Dependency,
284
+ specifier: FilePath,
285
+ pipeline: ?string,
286
+ projectRoot: string,
287
+ |};
288
+
289
+ type RunResolverResolveResult = {|
290
+ invalidations: Array<*>,
291
+ resolution:
292
+ | {|type: 'unresolved'|}
293
+ | {|type: 'excluded'|}
294
+ | {|
295
+ type: 'resolved',
296
+ canDefer: boolean,
297
+ filePath: string,
298
+ sideEffects: boolean,
299
+ code?: string,
300
+ meta?: mixed,
301
+ pipeline?: string,
302
+ priority?: number,
303
+ query?: string,
304
+ |},
305
+ |};
306
+
307
+ const PriorityMap = {
308
+ sync: 0,
309
+ parallel: 1,
310
+ lazy: 2,
311
+ conditional: 3,
312
+ };
@@ -332,4 +332,110 @@ export default class BundleGraph<TBundle: IBundle>
332
332
  targetToInternalTarget(target),
333
333
  );
334
334
  }
335
+
336
+ // Given a set of dependencies, return any conditions where those dependencies are either
337
+ // the true or false dependency for those conditions. This is currently used to work out which
338
+ // conditions belong to a bundle in packaging.
339
+ getConditionsForDependencies(deps: Array<IDependency>): Set<{|
340
+ publicId: string,
341
+ key: string,
342
+ ifTrueDependency: IDependency,
343
+ ifFalseDependency: IDependency,
344
+ ifTrueAssetId: string,
345
+ ifFalseAssetId: string,
346
+ |}> {
347
+ const conditions = new Set();
348
+ const depIds = deps.map(dep => dep.id);
349
+ for (const condition of this.#graph._conditions.values()) {
350
+ if (
351
+ depIds.includes(condition.ifTrueDependency.id) ||
352
+ depIds.includes(condition.ifFalseDependency.id)
353
+ ) {
354
+ const [trueAsset, falseAsset] = [
355
+ condition.ifTrueDependency,
356
+ condition.ifFalseDependency,
357
+ ].map(dep => {
358
+ const resolved = nullthrows(this.#graph.resolveAsyncDependency(dep));
359
+ if (resolved.type === 'asset') {
360
+ return resolved.value;
361
+ } else {
362
+ return this.#graph.getAssetById(resolved.value.entryAssetId);
363
+ }
364
+ });
365
+
366
+ conditions.add({
367
+ publicId: condition.publicId,
368
+ key: condition.key,
369
+ ifTrueDependency: nullthrows(
370
+ deps.find(dep => dep.id === condition.ifTrueDependency.id),
371
+ 'ifTrueDependency was null',
372
+ ),
373
+ ifFalseDependency: nullthrows(
374
+ deps.find(dep => dep.id === condition.ifFalseDependency.id),
375
+ 'ifFalseDependency was null',
376
+ ),
377
+ ifTrueAssetId: this.#graph.getAssetPublicId(trueAsset),
378
+ ifFalseAssetId: this.#graph.getAssetPublicId(falseAsset),
379
+ });
380
+ }
381
+ }
382
+
383
+ return conditions;
384
+ }
385
+
386
+ // This is used to generate information for building a manifest that can
387
+ // be used by a webserver to understand which conditions are used by which bundles,
388
+ // and which bundles those conditions require depending on what they evaluate to.
389
+ getConditionalBundleMapping(): Map<
390
+ TBundle,
391
+ Map<
392
+ string,
393
+ {|
394
+ ifTrueBundles: Array<TBundle>,
395
+ ifFalseBundles: Array<TBundle>,
396
+ |},
397
+ >,
398
+ > {
399
+ let bundleConditions = new Map();
400
+
401
+ // Convert the internal references in conditions to public API references
402
+ for (const cond of this.#graph._conditions.values()) {
403
+ let assets = Array.from(cond.assets).map(asset =>
404
+ nullthrows(this.getAssetById(asset.id)),
405
+ );
406
+ let bundles = new Set<TBundle>();
407
+ let ifTrueBundles = [];
408
+ let ifFalseBundles = [];
409
+ for (const asset of assets) {
410
+ const bundlesWithAsset = this.getBundlesWithAsset(asset);
411
+ for (const bundle of bundlesWithAsset) {
412
+ bundles.add(bundle);
413
+ }
414
+ const assetDeps = this.getDependencies(asset);
415
+ const depToBundles = dep => {
416
+ const publicDep = nullthrows(
417
+ assetDeps.find(assetDep => dep.id === assetDep.id),
418
+ );
419
+ const resolved = nullthrows(this.resolveAsyncDependency(publicDep));
420
+ invariant(resolved.type === 'bundle_group');
421
+ return this.getBundlesInBundleGroup(resolved.value);
422
+ };
423
+ ifTrueBundles.push(...depToBundles(cond.ifTrueDependency));
424
+ ifFalseBundles.push(...depToBundles(cond.ifFalseDependency));
425
+ }
426
+
427
+ for (let bundle of bundles) {
428
+ const conditions = bundleConditions.get(bundle) ?? new Map();
429
+
430
+ conditions.set(cond.key, {
431
+ ifTrueBundles,
432
+ ifFalseBundles,
433
+ });
434
+
435
+ bundleConditions.set(bundle, conditions);
436
+ }
437
+ }
438
+
439
+ return bundleConditions;
440
+ }
335
441
  }
@@ -10,6 +10,7 @@ import type {AtlaspackV3} from '../atlaspack-v3';
10
10
  import {toProjectPath} from '../projectPath';
11
11
  import {requestTypes, type StaticRunOpts} from '../RequestTracker';
12
12
  import {propagateSymbols} from '../SymbolPropagation';
13
+ import type {Environment} from '../types';
13
14
 
14
15
  import type {
15
16
  AssetGraphRequestInput,
@@ -95,9 +96,58 @@ function getAssetGraph(serializedGraph, options) {
95
96
 
96
97
  graph.safeToIncrementallyBundle = false;
97
98
 
99
+ function mapSymbols({exported, ...symbol}) {
100
+ let jsSymbol = {
101
+ local: symbol.local ?? undefined,
102
+ loc: symbol.loc ?? undefined,
103
+ meta: undefined,
104
+ isWeak: symbol.isWeak,
105
+ };
106
+
107
+ if (symbol.exported) {
108
+ // $FlowFixMe
109
+ jsSymbol.exported = symbol.exported;
110
+ }
111
+
112
+ if (symbol.isEsmExport) {
113
+ // $FlowFixMe
114
+ jsSymbol.meta = {
115
+ isEsm: true,
116
+ };
117
+ }
118
+ return [exported, jsSymbol];
119
+ }
120
+
121
+ // See crates/atlaspack_core/src/types/environment.rs
98
122
  let cachedAssets = new Map();
99
123
  let changedAssets = new Map();
100
124
  let entry = 0;
125
+
126
+ let envs = new Map();
127
+ let getEnvId = (env: Environment) => {
128
+ let envKey = [
129
+ env.context,
130
+ env.engines.atlaspack,
131
+ env.engines.browsers,
132
+ env.engines.electron,
133
+ env.engines.node,
134
+ env.includeNodeModules,
135
+ env.isLibrary,
136
+ env.outputFormat,
137
+ env.shouldScopeHoist,
138
+ env.shouldOptimize,
139
+ env.sourceType,
140
+ ].join(':');
141
+
142
+ let envId = envs.get(envKey);
143
+ if (envId == null) {
144
+ envId = envs.size;
145
+ envs.set(envKey, envId);
146
+ }
147
+
148
+ return envId;
149
+ };
150
+
101
151
  for (let node of serializedGraph.nodes) {
102
152
  if (node.type === 'root') {
103
153
  let index = graph.addNodeByContentKey('@@root', {
@@ -116,20 +166,38 @@ function getAssetGraph(serializedGraph, options) {
116
166
  value: null,
117
167
  });
118
168
  } else if (node.type === 'asset') {
119
- let id = node.value.id;
120
- let asset = node.value.asset;
169
+ let asset = node.value;
170
+ let id = asset.id;
171
+
172
+ asset.meta.id = id;
121
173
 
122
174
  asset = {
123
175
  ...asset,
124
- id,
176
+ uniqueKey: asset.uniqueKey ?? undefined,
177
+ pipeline: asset.pipeline ?? undefined,
178
+ range: asset.range ?? undefined,
179
+ resolveFrom: asset.resolveFrom ?? undefined,
180
+ target: asset.target ?? undefined,
181
+ plugin: asset.plugin ?? undefined,
182
+ query: asset.query ?? undefined,
183
+ configPath: asset.configPath ?? undefined,
184
+ configKeyPath: asset.configKeyPath ?? undefined,
185
+ isLargeBlob: asset.isLargeBlob ?? false,
186
+ isSource: asset.isSource ?? false,
187
+ sourcePath: asset.sourcePath ?? undefined,
188
+ env: {
189
+ ...asset.env,
190
+ loc: asset.env.loc ?? undefined,
191
+ id: getEnvId(asset.env),
192
+ sourceType: asset.env.sourceType,
193
+ },
194
+ bundleBehavior:
195
+ asset.bundleBehavior === 255 ? null : asset.bundleBehavior,
125
196
  committed: true,
126
197
  contentKey: id,
127
198
  filePath: toProjectPath(options.projectRoot, asset.filePath),
128
- symbols: asset.hasSymbols
129
- ? new Map(
130
- asset.symbols.map(({exported, ...symbol}) => [exported, symbol]),
131
- )
132
- : null,
199
+ symbols:
200
+ asset.symbols != null ? new Map(asset.symbols.map(mapSymbols)) : null,
133
201
  };
134
202
 
135
203
  cachedAssets.set(id, asset.code);
@@ -150,18 +218,38 @@ function getAssetGraph(serializedGraph, options) {
150
218
  dependency = {
151
219
  ...dependency,
152
220
  id,
221
+ env: {
222
+ ...dependency.env,
223
+ id: getEnvId(dependency.env),
224
+ sourceType: dependency.env.sourceType,
225
+ loc: dependency.env.loc ?? undefined,
226
+ },
227
+ pipeline: dependency.pipeline ?? undefined,
228
+ range: dependency.range ?? undefined,
229
+ resolveFrom: dependency.resolveFrom ?? undefined,
230
+ target: dependency.target ?? undefined,
231
+ bundleBehavior:
232
+ dependency.bundleBehavior === 255 ? null : dependency.bundleBehavior,
153
233
  contentKey: id,
234
+ loc: dependency.loc
235
+ ? {
236
+ ...dependency.loc,
237
+ filePath: toProjectPath(
238
+ options.projectRoot,
239
+ dependency.loc.filePath,
240
+ ),
241
+ }
242
+ : undefined,
154
243
  sourcePath: dependency.sourcePath
155
244
  ? toProjectPath(options.projectRoot, dependency.sourcePath)
156
- : null,
157
- symbols: dependency.hasSymbols
158
- ? new Map(
159
- dependency.symbols.map(({exported, ...symbol}) => [
160
- exported,
161
- symbol,
162
- ]),
163
- )
164
- : null,
245
+ : undefined,
246
+ symbols:
247
+ // Dependency.symbols are always set to an empty map when scope hoisting
248
+ // is enabled. Some tests will fail if this is not the case. We should
249
+ // make this consistant when we re-visit packaging.
250
+ dependency.symbols != null || dependency.env.shouldScopeHoist
251
+ ? new Map(dependency.symbols?.map(mapSymbols))
252
+ : undefined,
165
253
  };
166
254
  let usedSymbolsDown = new Set();
167
255
  let usedSymbolsUp = new Map();
@@ -118,6 +118,24 @@ export default function createBundleGraphRequest(
118
118
  },
119
119
  );
120
120
 
121
+ // if (input.rustAtlaspack && process.env.NATIVE_COMPARE === 'true') {
122
+ // let {assetGraph: jsAssetGraph} = await api.runRequest(
123
+ // createAssetGraphRequestJS({
124
+ // name: 'Main',
125
+ // entries: options.entries,
126
+ // optionsRef,
127
+ // shouldBuildLazily: options.shouldBuildLazily,
128
+ // lazyIncludes: options.lazyIncludes,
129
+ // lazyExcludes: options.lazyExcludes,
130
+ // requestedAssetIds,
131
+ // }),
132
+ // {
133
+ // force: true,
134
+ // },
135
+ // );
136
+ // require('./asset-graph-diff.js')(jsAssetGraph, assetGraph);
137
+ // }
138
+
121
139
  measurement && measurement.end();
122
140
  assertSignalNotAborted(signal);
123
141