@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.
- package/lib/AssetGraph.js +1 -2
- package/lib/Atlaspack.js +25 -3
- package/lib/AtlaspackConfig.schema.js +10 -36
- package/lib/BundleGraph.js +59 -5
- package/lib/Dependency.js +46 -1
- package/lib/Environment.js +12 -2
- package/lib/PackagerRunner.js +3 -45
- package/lib/RequestTracker.js +112 -30
- package/lib/SymbolPropagation.js +1 -1
- package/lib/Transformation.js +1 -15
- package/lib/UncommittedAsset.js +4 -4
- package/lib/Validation.js +1 -13
- package/lib/applyRuntimes.js +96 -20
- package/lib/assetUtils.js +9 -3
- package/lib/atlaspack-v3/AtlaspackV3.js +6 -8
- package/lib/atlaspack-v3/fs.js +8 -1
- package/lib/atlaspack-v3/worker/compat.js +57 -0
- package/lib/atlaspack-v3/worker/worker.js +247 -1
- package/lib/public/BundleGraph.js +68 -0
- package/lib/requests/AssetGraphRequestRust.js +79 -12
- package/lib/requests/BundleGraphRequest.js +19 -0
- package/lib/requests/WriteBundleRequest.js +15 -15
- package/lib/requests/asset-graph-diff.js +128 -0
- package/lib/resolveOptions.js +15 -8
- package/lib/types.js +2 -1
- package/package.json +19 -17
- package/src/AssetGraph.js +1 -1
- package/src/Atlaspack.js +28 -6
- package/src/AtlaspackConfig.schema.js +13 -36
- package/src/BundleGraph.js +77 -1
- package/src/CommittedAsset.js +1 -1
- package/src/Dependency.js +50 -12
- package/src/Environment.js +13 -15
- package/src/PackagerRunner.js +5 -53
- package/src/RequestTracker.js +144 -38
- package/src/SymbolPropagation.js +5 -2
- package/src/Transformation.js +1 -9
- package/src/UncommittedAsset.js +6 -6
- package/src/Validation.js +1 -7
- package/src/applyRuntimes.js +86 -22
- package/src/assetUtils.js +12 -19
- package/src/atlaspack-v3/AtlaspackV3.js +8 -11
- package/src/atlaspack-v3/fs.js +8 -3
- package/src/atlaspack-v3/jsCallable.js +4 -0
- package/src/atlaspack-v3/worker/compat.js +82 -0
- package/src/atlaspack-v3/worker/worker.js +300 -2
- package/src/public/BundleGraph.js +106 -0
- package/src/requests/AssetGraphRequestRust.js +105 -17
- package/src/requests/BundleGraphRequest.js +18 -0
- package/src/requests/WriteBundleRequest.js +17 -23
- package/src/requests/asset-graph-diff.js +145 -0
- package/src/resolveOptions.js +12 -2
- package/src/types.js +10 -0
- package/test/AssetGraph.test.js +23 -9
- package/test/AtlaspackConfigRequest.test.js +0 -161
- package/test/BundleGraph.test.js +8 -3
- package/test/Dependency.test.js +21 -0
- package/test/Environment.test.js +16 -5
- package/test/InternalAsset.test.js +8 -2
- package/test/PublicAsset.test.js +6 -2
- package/test/PublicBundle.test.js +1 -0
- package/test/PublicMutableBundleGraph.test.js +9 -4
- package/test/RequestTracker.test.js +139 -2
- package/test/SymbolPropagation.test.js +1 -0
- package/test/TargetRequest.test.js +25 -25
- package/test/requests/WriteBundleRequest.test.js +132 -0
- package/lib/atlaspack-v3/plugins/Resolver.js +0 -12
- package/lib/atlaspack-v3/plugins/index.js +0 -16
- package/src/atlaspack-v3/plugins/Resolver.js +0 -9
- 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,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
|
-
});
|