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

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 +156 -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 +209 -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
@@ -9,13 +9,16 @@ import AssetGraph, {
9
9
  nodeFromAsset,
10
10
  } from '../src/AssetGraph';
11
11
  import {createDependency as _createDependency} from '../src/Dependency';
12
- import {createAsset as _createAsset} from '../src/assetUtils';
12
+ import {
13
+ createAsset as _createAsset,
14
+ type AssetOptions,
15
+ } from '../src/assetUtils';
13
16
  import {DEFAULT_ENV, DEFAULT_TARGETS} from './test-utils';
14
17
  import {toProjectPath as _toProjectPath} from '../src/projectPath';
15
18
 
16
19
  const stats = {size: 0, time: 0};
17
20
 
18
- function createAsset(opts) {
21
+ function createAsset(opts: AssetOptions) {
19
22
  return _createAsset('/', opts);
20
23
  }
21
24
 
@@ -134,7 +137,7 @@ describe('AssetGraph', () => {
134
137
  graph.hasContentKey(
135
138
  createDependency({
136
139
  specifier: 'path/to/index1/src/main.js',
137
- specifierType: 'esm',
140
+ specifierType: 'url',
138
141
  target: DEFAULT_TARGETS[0],
139
142
  env: DEFAULT_ENV,
140
143
  }).id,
@@ -144,7 +147,7 @@ describe('AssetGraph', () => {
144
147
  graph.hasContentKey(
145
148
  createDependency({
146
149
  specifier: 'path/to/index2/src/main.js',
147
- specifierType: 'esm',
150
+ specifierType: 'url',
148
151
  target: DEFAULT_TARGETS[0],
149
152
  env: DEFAULT_ENV,
150
153
  }).id,
@@ -191,7 +194,7 @@ describe('AssetGraph', () => {
191
194
  to: graph.getNodeIdByContentKey(
192
195
  createDependency({
193
196
  specifier: 'path/to/index1/src/main.js',
194
- specifierType: 'esm',
197
+ specifierType: 'url',
195
198
  target: DEFAULT_TARGETS[0],
196
199
  env: DEFAULT_ENV,
197
200
  }).id,
@@ -208,7 +211,7 @@ describe('AssetGraph', () => {
208
211
  to: graph.getNodeIdByContentKey(
209
212
  createDependency({
210
213
  specifier: 'path/to/index2/src/main.js',
211
- specifierType: 'esm',
214
+ specifierType: 'url',
212
215
  target: DEFAULT_TARGETS[0],
213
216
  env: DEFAULT_ENV,
214
217
  }).id,
@@ -246,7 +249,7 @@ describe('AssetGraph', () => {
246
249
 
247
250
  let dep = createDependency({
248
251
  specifier: 'path/to/index/src/main.js',
249
- specifierType: 'esm',
252
+ specifierType: 'url',
250
253
  target: DEFAULT_TARGETS[0],
251
254
  env: DEFAULT_ENV,
252
255
  });
@@ -310,7 +313,7 @@ describe('AssetGraph', () => {
310
313
 
311
314
  let dep = createDependency({
312
315
  specifier: 'path/to/index/src/main.js',
313
- specifierType: 'esm',
316
+ specifierType: 'url',
314
317
  target: DEFAULT_TARGETS[0],
315
318
  env: DEFAULT_ENV,
316
319
  sourcePath: '',
@@ -322,6 +325,7 @@ describe('AssetGraph', () => {
322
325
  let assets = [
323
326
  createAsset({
324
327
  id: '1',
328
+ code: null,
325
329
  filePath,
326
330
  type: 'js',
327
331
  isSource: true,
@@ -341,6 +345,7 @@ describe('AssetGraph', () => {
341
345
  }),
342
346
  createAsset({
343
347
  id: '2',
348
+ code: null,
344
349
  filePath,
345
350
  type: 'js',
346
351
  isSource: true,
@@ -360,6 +365,7 @@ describe('AssetGraph', () => {
360
365
  }),
361
366
  createAsset({
362
367
  id: '3',
368
+ code: null,
363
369
  filePath,
364
370
  type: 'js',
365
371
  isSource: true,
@@ -400,6 +406,7 @@ describe('AssetGraph', () => {
400
406
  let assets2 = [
401
407
  createAsset({
402
408
  id: '1',
409
+ code: null,
403
410
  filePath,
404
411
  type: 'js',
405
412
  isSource: true,
@@ -419,6 +426,7 @@ describe('AssetGraph', () => {
419
426
  }),
420
427
  createAsset({
421
428
  id: '2',
429
+ code: null,
422
430
  filePath,
423
431
  type: 'js',
424
432
  isSource: true,
@@ -473,7 +481,7 @@ describe('AssetGraph', () => {
473
481
 
474
482
  let dep = createDependency({
475
483
  specifier: 'path/to/index/src/main.js',
476
- specifierType: 'esm',
484
+ specifierType: 'url',
477
485
  env: DEFAULT_ENV,
478
486
  target: DEFAULT_TARGETS[0],
479
487
  });
@@ -496,6 +504,7 @@ describe('AssetGraph', () => {
496
504
  let assets = [
497
505
  createAsset({
498
506
  id: '1',
507
+ code: null,
499
508
  filePath,
500
509
  type: 'js',
501
510
  isSource: true,
@@ -505,6 +514,7 @@ describe('AssetGraph', () => {
505
514
  }),
506
515
  createAsset({
507
516
  id: '2',
517
+ code: null,
508
518
  uniqueKey: 'dependent-asset-1',
509
519
  filePath,
510
520
  type: 'js',
@@ -515,6 +525,7 @@ describe('AssetGraph', () => {
515
525
  }),
516
526
  createAsset({
517
527
  id: '3',
528
+ code: null,
518
529
  uniqueKey: 'dependent-asset-2',
519
530
  filePath,
520
531
  type: 'js',
@@ -572,6 +583,7 @@ describe('AssetGraph', () => {
572
583
  });
573
584
  let indexAsset = createAsset({
574
585
  id: 'assetIndex',
586
+ code: null,
575
587
  filePath: toProjectPath('/index.js'),
576
588
  type: 'js',
577
589
  isSource: true,
@@ -600,6 +612,7 @@ describe('AssetGraph', () => {
600
612
  let fooUtilsDepNode = nodeFromDep(fooUtilsDep);
601
613
  let fooAsset = createAsset({
602
614
  id: 'assetFoo',
615
+ code: null,
603
616
  filePath: toProjectPath('/foo.js'),
604
617
  type: 'js',
605
618
  isSource: true,
@@ -642,6 +655,7 @@ describe('AssetGraph', () => {
642
655
  });
643
656
  let barAsset = createAsset({
644
657
  id: 'assetBar',
658
+ code: null,
645
659
  filePath: toProjectPath('/bar.js'),
646
660
  type: 'js',
647
661
  isSource: true,
@@ -13,107 +13,11 @@ import {
13
13
  resolveAtlaspackConfig,
14
14
  processConfig,
15
15
  } from '../src/requests/AtlaspackConfigRequest';
16
- import {validatePackageName} from '../src/AtlaspackConfig.schema';
17
16
  import {DEFAULT_OPTIONS, relative} from './test-utils';
18
17
  import {toProjectPath} from '../src/projectPath';
19
18
 
20
19
  describe('AtlaspackConfigRequest', () => {
21
- describe('validatePackageName', () => {
22
- it('should error on an invalid official package', () => {
23
- assert.throws(() => {
24
- validatePackageName('@atlaspack/foo-bar', 'transform', 'transformers');
25
- }, /Official atlaspack transform packages must be named according to "@atlaspack\/transform-{name}"/);
26
-
27
- assert.throws(() => {
28
- validatePackageName(
29
- '@atlaspack/transformer',
30
- 'transform',
31
- 'transformers',
32
- );
33
- }, /Official atlaspack transform packages must be named according to "@atlaspack\/transform-{name}"/);
34
- });
35
-
36
- it('should succeed on a valid official package', () => {
37
- validatePackageName(
38
- '@atlaspack/transform-bar',
39
- 'transform',
40
- 'transformers',
41
- );
42
- });
43
-
44
- it('should error on an invalid community package', () => {
45
- assert.throws(() => {
46
- validatePackageName('foo-bar', 'transform', 'transformers');
47
- }, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
48
-
49
- assert.throws(() => {
50
- validatePackageName('parcel-foo-bar', 'transform', 'transformers');
51
- }, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
52
-
53
- assert.throws(() => {
54
- validatePackageName('parcel-transform', 'transform', 'transformers');
55
- }, /Atlaspack transform packages must be named according to "parcel-transform-{name}"/);
56
- });
57
-
58
- it('should succeed on a valid community package', () => {
59
- validatePackageName('parcel-transform-bar', 'transform', 'transformers');
60
- });
61
-
62
- // Skipping this while the migration to parcel occurs
63
- it.skip('should error on an invalid scoped package', () => {
64
- assert.throws(() => {
65
- validatePackageName('@test/foo-bar', 'transform', 'transformers');
66
- }, /Scoped atlaspack transform packages must be named according to "@test\/parcel-transform\[-{name}\]"/);
67
-
68
- assert.throws(() => {
69
- validatePackageName(
70
- '@test/atlaspack-foo-bar',
71
- 'transform',
72
- 'transformers',
73
- );
74
- }, /Scoped atlaspack transform packages must be named according to "@test\/parcel-transform\[-{name}\]"/);
75
- });
76
-
77
- it('should succeed on a valid scoped package', () => {
78
- validatePackageName(
79
- '@test/atlaspack-transform-bar',
80
- 'transform',
81
- 'transformers',
82
- );
83
-
84
- validatePackageName(
85
- '@test/atlaspack-transform',
86
- 'transform',
87
- 'transformers',
88
- );
89
- });
90
-
91
- it('should succeed on a local package', () => {
92
- validatePackageName(
93
- './atlaspack-transform-bar',
94
- 'transform',
95
- 'transformers',
96
- );
97
- validatePackageName('./bar', 'transform', 'transformers');
98
- });
99
- });
100
-
101
20
  describe('validateConfigFile', () => {
102
- it('should throw on invalid config', () => {
103
- assert.throws(() => {
104
- validateConfigFile(
105
- {
106
- filePath: '.parcelrc',
107
- extends: 'parcel-config-foo',
108
- transformers: {
109
- '*.js': ['parcel-invalid-plugin'],
110
- },
111
- },
112
- '.parcelrc',
113
- );
114
- });
115
- });
116
-
117
21
  it('should require pipeline to be an array', () => {
118
22
  assert.throws(() => {
119
23
  validateConfigFile(
@@ -140,18 +44,6 @@ describe('AtlaspackConfigRequest', () => {
140
44
  });
141
45
  });
142
46
 
143
- it('should require package names to be valid', () => {
144
- assert.throws(() => {
145
- validateConfigFile(
146
- {
147
- filePath: '.parcelrc',
148
- resolvers: ['parcel-foo-bar'],
149
- },
150
- '.parcelrc',
151
- );
152
- });
153
- });
154
-
155
47
  it('should succeed with an array of valid package names', () => {
156
48
  validateConfigFile(
157
49
  {
@@ -185,21 +77,6 @@ describe('AtlaspackConfigRequest', () => {
185
77
  });
186
78
  });
187
79
 
188
- it('should trigger the validator function for each key', () => {
189
- assert.throws(() => {
190
- validateConfigFile(
191
- {
192
- filePath: '.parcelrc',
193
- transformers: {
194
- 'types:*.{ts,tsx}': ['@atlaspack/transformer-typescript-types'],
195
- 'bundle-text:*': ['-inline-string', '...'],
196
- },
197
- },
198
- '.parcelrc',
199
- );
200
- });
201
- });
202
-
203
80
  it('should require extends to be a string or array of strings', () => {
204
81
  assert.throws(() => {
205
82
  validateConfigFile(
@@ -242,44 +119,6 @@ describe('AtlaspackConfigRequest', () => {
242
119
  );
243
120
  });
244
121
 
245
- it('should validate package names', () => {
246
- assert.throws(() => {
247
- validateConfigFile(
248
- {
249
- filePath: '.parcelrc',
250
- extends: 'foo',
251
- },
252
- '.parcelrc',
253
- );
254
- });
255
-
256
- assert.throws(() => {
257
- validateConfigFile(
258
- {
259
- filePath: '.parcelrc',
260
- extends: ['foo', 'bar'],
261
- },
262
- '.parcelrc',
263
- );
264
- });
265
-
266
- validateConfigFile(
267
- {
268
- filePath: '.parcelrc',
269
- extends: 'parcel-config-foo',
270
- },
271
- '.parcelrc',
272
- );
273
-
274
- validateConfigFile(
275
- {
276
- filePath: '.parcelrc',
277
- extends: ['parcel-config-foo', 'parcel-config-bar'],
278
- },
279
- '.parcelrc',
280
- );
281
- });
282
-
283
122
  it('should throw for invalid top level keys', () => {
284
123
  assert.throws(
285
124
  () => {
@@ -4,11 +4,14 @@ import assert from 'assert';
4
4
  import BundleGraph from '../src/BundleGraph';
5
5
  import {DEFAULT_ENV, DEFAULT_TARGETS} from './test-utils';
6
6
  import AssetGraph, {nodeFromAssetGroup} from '../src/AssetGraph';
7
- import {createAsset as _createAsset} from '../src/assetUtils';
7
+ import {
8
+ createAsset as _createAsset,
9
+ type AssetOptions,
10
+ } from '../src/assetUtils';
8
11
  import {createDependency as _createDependency} from '../src/Dependency';
9
12
  import {toProjectPath} from '../src/projectPath';
10
13
 
11
- function createAsset(opts) {
14
+ function createAsset(opts: AssetOptions) {
12
15
  return _createAsset('/', opts);
13
16
  }
14
17
 
@@ -79,7 +82,7 @@ function createMockAssetGraph(ids: [string, string]) {
79
82
 
80
83
  let dep = createDependency({
81
84
  specifier: 'path/to/index/src/main.js',
82
- specifierType: 'esm',
85
+ specifierType: 'url',
83
86
  env: DEFAULT_ENV,
84
87
  target: DEFAULT_TARGETS[0],
85
88
  });
@@ -98,6 +101,7 @@ function createMockAssetGraph(ids: [string, string]) {
98
101
  let assets = [
99
102
  createAsset({
100
103
  id: ids[0],
104
+ code: null,
101
105
  filePath,
102
106
  type: 'js',
103
107
  isSource: true,
@@ -107,6 +111,7 @@ function createMockAssetGraph(ids: [string, string]) {
107
111
  }),
108
112
  createAsset({
109
113
  id: ids[1],
114
+ code: null,
110
115
  filePath,
111
116
  type: 'js',
112
117
  isSource: true,
@@ -0,0 +1,21 @@
1
+ import expect from 'expect';
2
+ import {createDependencyId} from '../src/Dependency';
3
+ import {createEnvironment} from '../src/Environment';
4
+
5
+ describe('Dependency', () => {
6
+ describe('createDependencyId', () => {
7
+ it('should create a stable id for a dependency', () => {
8
+ let id1 = createDependencyId({
9
+ specifier: 'foo',
10
+ env: createEnvironment(),
11
+ specifierType: 'esm',
12
+ });
13
+ let id2 = createDependencyId({
14
+ specifier: 'foo',
15
+ env: createEnvironment(),
16
+ specifierType: 'esm',
17
+ });
18
+ expect(id1).toEqual(id2);
19
+ });
20
+ });
21
+ });
@@ -1,12 +1,15 @@
1
1
  // @flow strict-local
2
2
 
3
3
  import assert from 'assert';
4
+ // $FlowFixMe
5
+ import expect from 'expect';
4
6
  import {createEnvironment} from '../src/Environment';
7
+ import {initializeMonitoring} from '../../rust';
5
8
 
6
9
  describe('Environment', () => {
7
10
  it('assigns a default environment with nothing passed', () => {
8
11
  assert.deepEqual(createEnvironment(), {
9
- id: 'c242f987e3544367',
12
+ id: 'd821e85f6b50315e',
10
13
  context: 'browser',
11
14
  engines: {
12
15
  browsers: ['> 0.25%'],
@@ -24,7 +27,7 @@ describe('Environment', () => {
24
27
 
25
28
  it('assigns a node context if a node engine is given', () => {
26
29
  assert.deepEqual(createEnvironment({engines: {node: '>= 10.0.0'}}), {
27
- id: '69e0ab7220ee8f7a',
30
+ id: '2320af923a717577',
28
31
  context: 'node',
29
32
  engines: {
30
33
  node: '>= 10.0.0',
@@ -44,7 +47,7 @@ describe('Environment', () => {
44
47
  assert.deepEqual(
45
48
  createEnvironment({engines: {browsers: ['last 1 version']}}),
46
49
  {
47
- id: '4b5c9005af8c5b19',
50
+ id: '75603271034eff15',
48
51
  context: 'browser',
49
52
  engines: {
50
53
  browsers: ['last 1 version'],
@@ -63,7 +66,7 @@ describe('Environment', () => {
63
66
 
64
67
  it('assigns default engines for node', () => {
65
68
  assert.deepEqual(createEnvironment({context: 'node'}), {
66
- id: 'f7c9644283a8698f',
69
+ id: 'e45cc12216f7857d',
67
70
  context: 'node',
68
71
  engines: {
69
72
  node: '>= 8.0.0',
@@ -81,7 +84,7 @@ describe('Environment', () => {
81
84
 
82
85
  it('assigns default engines for browsers', () => {
83
86
  assert.deepEqual(createEnvironment({context: 'browser'}), {
84
- id: 'c242f987e3544367',
87
+ id: 'd821e85f6b50315e',
85
88
  context: 'browser',
86
89
  engines: {
87
90
  browsers: ['> 0.25%'],
@@ -97,3 +100,11 @@ describe('Environment', () => {
97
100
  });
98
101
  });
99
102
  });
103
+
104
+ describe('createEnvironment', function () {
105
+ it('returns a stable hash', () => {
106
+ initializeMonitoring();
107
+ const environment = createEnvironment({});
108
+ expect(environment.id).toEqual('d821e85f6b50315e');
109
+ });
110
+ });
@@ -2,12 +2,15 @@
2
2
 
3
3
  import assert from 'assert';
4
4
  import UncommittedAsset from '../src/UncommittedAsset';
5
- import {createAsset as _createAsset} from '../src/assetUtils';
5
+ import {
6
+ createAsset as _createAsset,
7
+ type AssetOptions,
8
+ } from '../src/assetUtils';
6
9
  import {createEnvironment} from '../src/Environment';
7
10
  import {DEFAULT_OPTIONS} from './test-utils';
8
11
  import {toProjectPath} from '../src/projectPath';
9
12
 
10
- function createAsset(opts) {
13
+ function createAsset(opts: AssetOptions) {
11
14
  return _createAsset('/', opts);
12
15
  }
13
16
 
@@ -18,6 +21,7 @@ describe('InternalAsset', () => {
18
21
  let asset = new UncommittedAsset({
19
22
  value: createAsset({
20
23
  filePath: toProjectPath('/', '/foo/asset.js'),
24
+ code: null,
21
25
  env: createEnvironment(),
22
26
  stats,
23
27
  type: 'js',
@@ -37,6 +41,7 @@ describe('InternalAsset', () => {
37
41
  let asset = new UncommittedAsset({
38
42
  value: createAsset({
39
43
  filePath: toProjectPath('/', '/foo/asset.js'),
44
+ code: null,
40
45
  env: createEnvironment(),
41
46
  stats,
42
47
  type: 'js',
@@ -56,6 +61,7 @@ describe('InternalAsset', () => {
56
61
  let asset = new UncommittedAsset({
57
62
  value: createAsset({
58
63
  filePath: toProjectPath('/', '/foo/asset.js'),
64
+ code: null,
59
65
  env: createEnvironment(),
60
66
  stats,
61
67
  type: 'js',
@@ -3,12 +3,15 @@
3
3
  import assert from 'assert';
4
4
  import {Asset, MutableAsset} from '../src/public/Asset';
5
5
  import UncommittedAsset from '../src/UncommittedAsset';
6
- import {createAsset as _createAsset} from '../src/assetUtils';
6
+ import {
7
+ createAsset as _createAsset,
8
+ type AssetOptions,
9
+ } from '../src/assetUtils';
7
10
  import {createEnvironment} from '../src/Environment';
8
11
  import {DEFAULT_OPTIONS} from './test-utils';
9
12
  import {toProjectPath} from '../src/projectPath';
10
13
 
11
- function createAsset(opts) {
14
+ function createAsset(opts: AssetOptions) {
12
15
  return _createAsset('/', opts);
13
16
  }
14
17
 
@@ -19,6 +22,7 @@ describe('Public Asset', () => {
19
22
  options: DEFAULT_OPTIONS,
20
23
  value: createAsset({
21
24
  filePath: toProjectPath('/', '/does/not/exist'),
25
+ code: null,
22
26
  type: 'js',
23
27
  env: createEnvironment({}),
24
28
  isSource: true,
@@ -42,6 +42,7 @@ describe('Public Bundle', () => {
42
42
  assetPublicIds: new Set(),
43
43
  publicIdByAssetId: new Map(),
44
44
  bundleContentHashes: new Map(),
45
+ conditions: new Map(),
45
46
  });
46
47
  });
47
48
 
@@ -8,12 +8,15 @@ import InternalBundleGraph from '../src/BundleGraph';
8
8
  import MutableBundleGraph from '../src/public/MutableBundleGraph';
9
9
  import {DEFAULT_ENV, DEFAULT_TARGETS, DEFAULT_OPTIONS} from './test-utils';
10
10
  import AssetGraph, {nodeFromAssetGroup} from '../src/AssetGraph';
11
- import {createAsset as _createAsset} from '../src/assetUtils';
11
+ import {
12
+ createAsset as _createAsset,
13
+ type AssetOptions,
14
+ } from '../src/assetUtils';
12
15
  import {createDependency as _createDependency} from '../src/Dependency';
13
16
  import nullthrows from 'nullthrows';
14
17
  import {toProjectPath} from '../src/projectPath';
15
18
 
16
- function createAsset(opts) {
19
+ function createAsset(opts: AssetOptions) {
17
20
  return _createAsset('/', opts);
18
21
  }
19
22
 
@@ -139,14 +142,14 @@ function createMockAssetGraph() {
139
142
 
140
143
  let dep1 = createDependency({
141
144
  specifier: 'path/to/index/src/main.js',
142
- specifierType: 'esm',
145
+ specifierType: 'url',
143
146
  needsStableName: true,
144
147
  env: DEFAULT_ENV,
145
148
  target: DEFAULT_TARGETS[0],
146
149
  });
147
150
  let dep2 = createDependency({
148
151
  specifier: 'path/to/index/src/main2.js',
149
- specifierType: 'esm',
152
+ specifierType: 'url',
150
153
  needsStableName: true,
151
154
  env: DEFAULT_ENV,
152
155
  target: DEFAULT_TARGETS[0],
@@ -160,6 +163,7 @@ function createMockAssetGraph() {
160
163
  [
161
164
  createAsset({
162
165
  id: id1,
166
+ code: null,
163
167
  filePath,
164
168
  type: 'js',
165
169
  isSource: true,
@@ -178,6 +182,7 @@ function createMockAssetGraph() {
178
182
  [
179
183
  createAsset({
180
184
  id: id2,
185
+ code: null,
181
186
  filePath,
182
187
  type: 'js',
183
188
  isSource: true,