@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
@@ -0,0 +1,132 @@
1
+ // @flow strict-local
2
+
3
+ import {replaceStream} from '../../src/requests/WriteBundleRequest';
4
+ import {Writable, pipeline} from 'stream';
5
+ import {replaceHashReferences} from '@atlaspack/rust';
6
+ import assert from 'assert';
7
+ import {blobToStream} from '@atlaspack/utils';
8
+
9
+ class BufferWritable extends Writable {
10
+ buffers: Buffer[];
11
+
12
+ constructor() {
13
+ super();
14
+ this.buffers = [];
15
+ }
16
+
17
+ getBuffer(): Buffer {
18
+ return Buffer.concat(this.buffers);
19
+ }
20
+
21
+ _write(chunk: string | Buffer, encoding: string, callback) {
22
+ let buffer =
23
+ typeof chunk === 'string'
24
+ ? // $FlowFixMe
25
+ Buffer.from(chunk, encoding)
26
+ : chunk;
27
+ this.buffers.push(buffer);
28
+ callback();
29
+ }
30
+ }
31
+
32
+ function generateSampleInput(
33
+ hashReferences: Map<string, string>,
34
+ inputSize: number,
35
+ ): Buffe {
36
+ let output = '';
37
+
38
+ while (output.length < inputSize) {
39
+ if (Math.random() < 0.1) {
40
+ output += 'HASH_REF_1234567890123456';
41
+ } else {
42
+ for (let i = 0; i < 16; i++) {
43
+ output += String.fromCharCode(97 + Math.floor(Math.random() * 26));
44
+ }
45
+ }
46
+ }
47
+
48
+ return Buffer.from(output);
49
+ }
50
+
51
+ async function javascriptReplaceHashReferences(
52
+ buffer: Buffer,
53
+ hashReferences: Map<string, string>,
54
+ ): Promise<Buffer> {
55
+ const writable = new BufferWritable();
56
+ const transform = replaceStream(hashReferences);
57
+
58
+ await new Promise((resolve, reject) => {
59
+ pipeline(blobToStream(buffer), transform, writable, err => {
60
+ if (err) reject(err);
61
+ else resolve(null);
62
+ });
63
+ });
64
+
65
+ const output = writable.getBuffer();
66
+ return output;
67
+ }
68
+
69
+ describe('replaceStream', () => {
70
+ const hashReferences = new Map([
71
+ ['HASH_REF_1234567890123456', 'HASH_REF_replacedwithstri'],
72
+ ]);
73
+ const buffer = Buffer.from(
74
+ 'Hello HASH_REF_1234567890123456 more stuff here HASH_REF_1234567890123456',
75
+ );
76
+ const expectedOutput =
77
+ 'Hello HASH_REF_replacedwithstri more stuff here HASH_REF_replacedwithstri';
78
+
79
+ it('javascript - replaces hash references in buffers', async () => {
80
+ const output = await javascriptReplaceHashReferences(
81
+ buffer,
82
+ hashReferences,
83
+ );
84
+ const outputString = output.toString();
85
+ assert.equal(outputString, expectedOutput);
86
+ });
87
+
88
+ it('rust - replaces hash references in buffers', () => {
89
+ const output = replaceHashReferences(
90
+ buffer,
91
+ Object.fromEntries(hashReferences.entries()),
92
+ );
93
+
94
+ const outputString = output.toString();
95
+ assert.equal(outputString, expectedOutput);
96
+ });
97
+
98
+ let currentInputSize = 1024 * 1024; // Start at 1MB and grow to 40MB
99
+ const inputSizes = [];
100
+ while (currentInputSize < 40 * 1024 * 1024) {
101
+ inputSizes.push(currentInputSize);
102
+ currentInputSize *= 2;
103
+ }
104
+
105
+ inputSizes.forEach(inputSize => {
106
+ describe('input size ' + inputSize / 1024 / 1024 + 'MB', () => {
107
+ const buffer = generateSampleInput(hashReferences, inputSize);
108
+ const expectedOutput = buffer
109
+ .toString()
110
+ .replace(/HASH_REF_1234567890123456/g, 'HASH_REF_replacedwithstri');
111
+
112
+ it('javascript - works on huge buffer', async () => {
113
+ const output = await javascriptReplaceHashReferences(
114
+ buffer,
115
+ hashReferences,
116
+ );
117
+ const outputString = output.toString();
118
+ assert.equal(outputString, expectedOutput);
119
+ });
120
+
121
+ it('rust - works on huge buffer', () => {
122
+ const output = replaceHashReferences(
123
+ buffer,
124
+ Object.fromEntries(hashReferences.entries()),
125
+ );
126
+
127
+ const outputString = output.toString();
128
+ assert.equal(outputString, expectedOutput);
129
+ });
130
+ });
131
+ });
132
+ });
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ResolverNapi = void 0;
7
- class ResolverNapi {
8
- constructor() {}
9
- loadConfig() {}
10
- resolve() {}
11
- }
12
- exports.ResolverNapi = ResolverNapi;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _Resolver = require("./Resolver");
7
- Object.keys(_Resolver).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _Resolver[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _Resolver[key];
14
- }
15
- });
16
- });
@@ -1,9 +0,0 @@
1
- // @flow
2
-
3
- export class ResolverNapi {
4
- constructor() {}
5
-
6
- loadConfig() {}
7
-
8
- resolve() {}
9
- }
@@ -1,3 +0,0 @@
1
- // @flow
2
-
3
- export * from './Resolver';