@atlaspack/core 2.36.0 → 2.38.2
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/CHANGELOG.md +121 -0
- package/dist/Atlaspack.js +41 -6
- package/dist/atlaspack-v3/AtlaspackV3.js +7 -4
- package/dist/atlaspack-v3/NapiWorkerPool.js +33 -0
- package/dist/atlaspack-v3/fs.js +1 -0
- package/dist/atlaspack-v3/worker/compat/index.js +0 -1
- package/dist/atlaspack-v3/worker/worker.js +21 -5
- package/dist/requests/AssetGraphRequestRust.js +5 -1
- package/dist/requests/AtlaspackBuildRequest.js +3 -0
- package/dist/requests/BundleGraphRequestRust.js +5 -1
- package/lib/Atlaspack.js +47 -15
- package/lib/atlaspack-v3/AtlaspackV3.js +7 -4
- package/lib/atlaspack-v3/NapiWorkerPool.js +35 -0
- package/lib/atlaspack-v3/fs.js +1 -0
- package/lib/atlaspack-v3/worker/compat/index.js +0 -11
- package/lib/atlaspack-v3/worker/worker.js +39 -6
- package/lib/requests/AssetGraphRequestRust.js +5 -1
- package/lib/requests/AtlaspackBuildRequest.js +9 -0
- package/lib/requests/BundleGraphRequestRust.js +5 -1
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -2
- package/lib/types/atlaspack-v3/fs.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/compat/index.d.ts +0 -1
- package/package.json +15 -15
- package/src/Atlaspack.ts +54 -12
- package/src/atlaspack-v3/AtlaspackV3.ts +22 -4
- package/src/atlaspack-v3/NapiWorkerPool.ts +38 -0
- package/src/atlaspack-v3/fs.ts +5 -0
- package/src/atlaspack-v3/worker/compat/index.ts +0 -1
- package/src/atlaspack-v3/worker/worker.ts +22 -6
- package/src/requests/AssetGraphRequestRust.ts +5 -1
- package/src/requests/AtlaspackBuildRequest.ts +4 -0
- package/src/requests/BundleGraphRequestRust.ts +5 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +0 -26
- package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
- package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +0 -9
- package/src/atlaspack-v3/worker/compat/plugin-logger.ts +0 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,126 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.38.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`7d1839c`](https://github.com/atlassian-labs/atlaspack/commit/7d1839cc7cf0225dd35afecb68109a11fd931f2b)]:
|
|
8
|
+
- @atlaspack/rust@3.28.0
|
|
9
|
+
- @atlaspack/cache@3.2.55
|
|
10
|
+
- @atlaspack/fs@2.15.55
|
|
11
|
+
- @atlaspack/logger@2.14.52
|
|
12
|
+
- @atlaspack/source-map@3.3.4
|
|
13
|
+
- @atlaspack/utils@3.4.2
|
|
14
|
+
- @atlaspack/package-manager@2.14.60
|
|
15
|
+
- @atlaspack/profiler@2.15.21
|
|
16
|
+
- @atlaspack/workers@2.14.60
|
|
17
|
+
- @atlaspack/types@2.15.50
|
|
18
|
+
- @atlaspack/graph@3.6.22
|
|
19
|
+
- @atlaspack/plugin@2.14.60
|
|
20
|
+
|
|
21
|
+
## 2.38.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [#1059](https://github.com/atlassian-labs/atlaspack/pull/1059) [`1c767e4`](https://github.com/atlassian-labs/atlaspack/commit/1c767e4907664dd490a56276d6562f79dbeea3fb) Thanks [@OscarCookeAbbott](https://github.com/OscarCookeAbbott)! - Improve multithreaded logging
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`a958853`](https://github.com/atlassian-labs/atlaspack/commit/a958853ae3de2812bfd032357e9fa7cab6a1ddb6), [`0f5c1ef`](https://github.com/atlassian-labs/atlaspack/commit/0f5c1eff9138728168231efa66202a8d844c33ef)]:
|
|
28
|
+
- @atlaspack/rust@3.27.0
|
|
29
|
+
- @atlaspack/cache@3.2.54
|
|
30
|
+
- @atlaspack/fs@2.15.54
|
|
31
|
+
- @atlaspack/logger@2.14.51
|
|
32
|
+
- @atlaspack/source-map@3.3.3
|
|
33
|
+
- @atlaspack/utils@3.4.1
|
|
34
|
+
- @atlaspack/package-manager@2.14.59
|
|
35
|
+
- @atlaspack/profiler@2.15.20
|
|
36
|
+
- @atlaspack/workers@2.14.59
|
|
37
|
+
- @atlaspack/types@2.15.49
|
|
38
|
+
- @atlaspack/graph@3.6.21
|
|
39
|
+
- @atlaspack/plugin@2.14.59
|
|
40
|
+
|
|
41
|
+
## 2.38.0
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- [#1054](https://github.com/atlassian-labs/atlaspack/pull/1054) [`ffa1e42`](https://github.com/atlassian-labs/atlaspack/commit/ffa1e4276c22cc48b6be45ac81df8adde85f2237) Thanks [@marcins](https://github.com/marcins)! - - Implement plumbing to ensure data flows back out of build request that JS expects
|
|
46
|
+
- Implement a temporary namer to get an end-to-end test working
|
|
47
|
+
|
|
48
|
+
- [#1057](https://github.com/atlassian-labs/atlaspack/pull/1057) [`939d5bd`](https://github.com/atlassian-labs/atlaspack/commit/939d5bd41b3bcb5508f58ca41165d48122762e26) Thanks [@marcins](https://github.com/marcins)! - Set `SyntaxError` as the diagnostic name for parse/syntax errors from the JS and Tokens transformers.
|
|
49
|
+
|
|
50
|
+
Parse and syntax errors from the JS Transformer and Tokens Transformer now set `diagnostic.name` to `"SyntaxError"`, so consumers can reliably detect syntax/parse failures (e.g. for reporting or error handling). The Rust diagnostic type and NAPI `JsDiagnostic` include an optional `name` field; `error_buffer_to_diagnostics` sets it to `"SyntaxError"` for SWC parse errors, and both transformers pass it through to the thrown diagnostic. Integration tests assert that the first diagnostic has `name === 'SyntaxError'` for tokens and JS parse-error cases.
|
|
51
|
+
|
|
52
|
+
- [#1053](https://github.com/atlassian-labs/atlaspack/pull/1053) [`71981ea`](https://github.com/atlassian-labs/atlaspack/commit/71981eac258f7e6dfb40ec4b202d194f71c64ff1) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add native build progress reporting.
|
|
53
|
+
|
|
54
|
+
Fires `BuildProgressEvent` from Rust requests back to JS reporters via a fire-and-forget
|
|
55
|
+
`ThreadsafeFunction` callback. Works in both `atlaspackV3` and `fullNative` build paths.
|
|
56
|
+
|
|
57
|
+
Events:
|
|
58
|
+
- `building` — per-asset progress from AssetGraphRequest (completeAssets / totalAssets)
|
|
59
|
+
- `bundling` — once from BuildRequest before bundle graph creation
|
|
60
|
+
- `packagingAndOptimizing` — ready for when native packaging is wired up
|
|
61
|
+
|
|
62
|
+
Adds `BuildingProgressEvent` type and CLI reporter handling.
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- [#1056](https://github.com/atlassian-labs/atlaspack/pull/1056) [`0bb5830`](https://github.com/atlassian-labs/atlaspack/commit/0bb5830d1a7800e673f21ab020cd86bef873df9c) Thanks [@marcins](https://github.com/marcins)! - Fix native config loader rejecting TypeScript entry points in package.json.
|
|
67
|
+
|
|
68
|
+
The Rust package.json deserializer rejected `.ts` and `.tsx` extensions in builtin target fields
|
|
69
|
+
(`main`, `browser`, `module`), causing builds to fail with "Unexpected file type" errors when a
|
|
70
|
+
package.json uses TypeScript source entry points (e.g. `"main": "index.ts"`).
|
|
71
|
+
|
|
72
|
+
Additionally fixes EntryRequest to resolve the package path using `cwd()` instead of `project_root`,
|
|
73
|
+
matching the JS-side behavior for correct target resolution in monorepo setups.
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [[`ffa1e42`](https://github.com/atlassian-labs/atlaspack/commit/ffa1e4276c22cc48b6be45ac81df8adde85f2237), [`ea9730d`](https://github.com/atlassian-labs/atlaspack/commit/ea9730dd953d0512c2ab97cbba810e7a297a29a6), [`939d5bd`](https://github.com/atlassian-labs/atlaspack/commit/939d5bd41b3bcb5508f58ca41165d48122762e26), [`71981ea`](https://github.com/atlassian-labs/atlaspack/commit/71981eac258f7e6dfb40ec4b202d194f71c64ff1), [`0bb5830`](https://github.com/atlassian-labs/atlaspack/commit/0bb5830d1a7800e673f21ab020cd86bef873df9c), [`cba96b1`](https://github.com/atlassian-labs/atlaspack/commit/cba96b1a15c07703ee104bf2a2888cc715575cbd)]:
|
|
76
|
+
- @atlaspack/rust@3.26.0
|
|
77
|
+
- @atlaspack/utils@3.4.0
|
|
78
|
+
- @atlaspack/cache@3.2.53
|
|
79
|
+
- @atlaspack/fs@2.15.53
|
|
80
|
+
- @atlaspack/logger@2.14.50
|
|
81
|
+
- @atlaspack/source-map@3.3.2
|
|
82
|
+
- @atlaspack/graph@3.6.20
|
|
83
|
+
- @atlaspack/plugin@2.14.58
|
|
84
|
+
- @atlaspack/profiler@2.15.19
|
|
85
|
+
- @atlaspack/types@2.15.48
|
|
86
|
+
- @atlaspack/workers@2.14.58
|
|
87
|
+
- @atlaspack/package-manager@2.14.58
|
|
88
|
+
|
|
89
|
+
## 2.37.0
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- [#1050](https://github.com/atlassian-labs/atlaspack/pull/1050) [`c80be61`](https://github.com/atlassian-labs/atlaspack/commit/c80be618e42014208fed60b7a2dccc2e47d53aed) Thanks [@marcins](https://github.com/marcins)! - Add native PackagingRequest, implement temporary JS version for testing.
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- [#1051](https://github.com/atlassian-labs/atlaspack/pull/1051) [`2d3c616`](https://github.com/atlassian-labs/atlaspack/commit/2d3c616bb2ebef55d6850e8ca9eedf13c72f5386) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add native end-to-end build pipeline via BuildRequest.
|
|
98
|
+
|
|
99
|
+
When the `fullNative` feature flag is enabled, the entire build pipeline (asset graph, bundle graph,
|
|
100
|
+
packaging) runs natively in Rust via a single NAPI call, bypassing the JS request tracker.
|
|
101
|
+
|
|
102
|
+
Key changes:
|
|
103
|
+
- Add `BuildRequest` composing `AssetGraphRequest` and `BundleGraphRequest` with a packaging stub
|
|
104
|
+
- Add `Atlaspack::build()` method and `atlaspack_napi_build` NAPI binding
|
|
105
|
+
- Add `fullNative` feature flag gating the native path in `Atlaspack.ts._build()`
|
|
106
|
+
- Packaging step is a no-op pending PackagingRequest implementation
|
|
107
|
+
|
|
108
|
+
- Updated dependencies [[`c80be61`](https://github.com/atlassian-labs/atlaspack/commit/c80be618e42014208fed60b7a2dccc2e47d53aed), [`2d3c616`](https://github.com/atlassian-labs/atlaspack/commit/2d3c616bb2ebef55d6850e8ca9eedf13c72f5386)]:
|
|
109
|
+
- @atlaspack/feature-flags@2.31.0
|
|
110
|
+
- @atlaspack/rust@3.25.0
|
|
111
|
+
- @atlaspack/build-cache@2.13.14
|
|
112
|
+
- @atlaspack/cache@3.2.52
|
|
113
|
+
- @atlaspack/fs@2.15.52
|
|
114
|
+
- @atlaspack/graph@3.6.19
|
|
115
|
+
- @atlaspack/utils@3.3.9
|
|
116
|
+
- @atlaspack/logger@2.14.49
|
|
117
|
+
- @atlaspack/source-map@3.3.1
|
|
118
|
+
- @atlaspack/package-manager@2.14.57
|
|
119
|
+
- @atlaspack/workers@2.14.57
|
|
120
|
+
- @atlaspack/plugin@2.14.57
|
|
121
|
+
- @atlaspack/profiler@2.15.18
|
|
122
|
+
- @atlaspack/types@2.15.47
|
|
123
|
+
|
|
3
124
|
## 2.36.0
|
|
4
125
|
|
|
5
126
|
### Minor Changes
|
package/dist/Atlaspack.js
CHANGED
|
@@ -85,6 +85,7 @@ const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
|
85
85
|
const atlaspack_v3_1 = require("./atlaspack-v3");
|
|
86
86
|
const AssetGraphRequest_1 = __importDefault(require("./requests/AssetGraphRequest"));
|
|
87
87
|
const AssetGraphRequestRust_1 = require("./requests/AssetGraphRequestRust");
|
|
88
|
+
const BundleGraphRequestRust_1 = require("./requests/BundleGraphRequestRust");
|
|
88
89
|
const rustWorkerThreadDylibHack_1 = require("./rustWorkerThreadDylibHack");
|
|
89
90
|
(0, registerCoreWithSerializer_1.registerCoreWithSerializer)();
|
|
90
91
|
exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
|
|
@@ -158,6 +159,7 @@ class Atlaspack {
|
|
|
158
159
|
__classPrivateFieldSet(this, _Atlaspack_resolvedOptions, resolvedOptions, "f");
|
|
159
160
|
let rustAtlaspack;
|
|
160
161
|
if (resolvedOptions.featureFlags.atlaspackV3 ||
|
|
162
|
+
resolvedOptions.featureFlags.fullNative ||
|
|
161
163
|
resolvedOptions.featureFlags.nativePackager) {
|
|
162
164
|
// eslint-disable-next-line no-unused-vars
|
|
163
165
|
let { entries, inputFS, outputFS, ...options } = __classPrivateFieldGet(this, _Atlaspack_initialOptions, "f");
|
|
@@ -374,12 +376,45 @@ class Atlaspack {
|
|
|
374
376
|
type: 'buildStart',
|
|
375
377
|
});
|
|
376
378
|
__classPrivateFieldGet(this, _Atlaspack_requestTracker, "f").graph.invalidateOnBuildNodes();
|
|
377
|
-
let
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
let bundleGraph;
|
|
380
|
+
let bundleInfo;
|
|
381
|
+
let changedAssets;
|
|
382
|
+
let assetRequests;
|
|
383
|
+
let scopeHoistingStats;
|
|
384
|
+
if ((0, feature_flags_1.getFeatureFlag)('fullNative') && this.rustAtlaspack) {
|
|
385
|
+
let [result, error] = await this.rustAtlaspack.build((eventJson) => {
|
|
386
|
+
let event = JSON.parse(eventJson);
|
|
387
|
+
__classPrivateFieldGet(this, _Atlaspack_reporterRunner, "f").report(event);
|
|
388
|
+
});
|
|
389
|
+
if (error) {
|
|
390
|
+
throw new diagnostic_1.default({ diagnostic: error });
|
|
391
|
+
}
|
|
392
|
+
({ bundleGraph, changedAssets } = (0, BundleGraphRequestRust_1.getBundleGraph)(result));
|
|
393
|
+
bundleInfo = new Map((result.bundleInfo ?? []).map((info) => [
|
|
394
|
+
info.bundleId,
|
|
395
|
+
{
|
|
396
|
+
filePath: (0, projectPath_1.toProjectPath)(options.projectRoot, info.filePath),
|
|
397
|
+
bundleId: info.bundleId,
|
|
398
|
+
type: info.type,
|
|
399
|
+
stats: { size: info.size, time: info.time },
|
|
400
|
+
},
|
|
401
|
+
]));
|
|
402
|
+
assetRequests = result.assetRequests ?? [];
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
let request = (0, AtlaspackBuildRequest_1.default)({
|
|
406
|
+
optionsRef: __classPrivateFieldGet(this, _Atlaspack_optionsRef, "f"),
|
|
407
|
+
requestedAssetIds: __classPrivateFieldGet(this, _Atlaspack_requestedAssetIds, "f"),
|
|
408
|
+
signal,
|
|
409
|
+
});
|
|
410
|
+
({
|
|
411
|
+
bundleGraph,
|
|
412
|
+
bundleInfo,
|
|
413
|
+
changedAssets,
|
|
414
|
+
assetRequests,
|
|
415
|
+
scopeHoistingStats,
|
|
416
|
+
} = await __classPrivateFieldGet(this, _Atlaspack_requestTracker, "f").runRequest(request, { force: true }));
|
|
417
|
+
}
|
|
383
418
|
__classPrivateFieldGet(this, _Atlaspack_requestedAssetIds, "f").clear();
|
|
384
419
|
await (0, dumpGraphToGraphViz_1.default)(
|
|
385
420
|
// @ts-expect-error TS2345
|
|
@@ -48,11 +48,14 @@ class AtlaspackV3 {
|
|
|
48
48
|
this._napiWorkerPool.shutdown();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
buildAssetGraph() {
|
|
52
|
-
return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
51
|
+
buildAssetGraph(progressCallback) {
|
|
52
|
+
return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi, progressCallback);
|
|
53
53
|
}
|
|
54
|
-
buildBundleGraph() {
|
|
55
|
-
return (0, rust_1.atlaspackNapiBuildBundleGraph)(this._atlaspack_napi);
|
|
54
|
+
buildBundleGraph(progressCallback) {
|
|
55
|
+
return (0, rust_1.atlaspackNapiBuildBundleGraph)(this._atlaspack_napi, progressCallback);
|
|
56
|
+
}
|
|
57
|
+
build(progressCallback) {
|
|
58
|
+
return (0, rust_1.atlaspackNapiBuild)(this._atlaspack_napi, progressCallback);
|
|
56
59
|
}
|
|
57
60
|
loadBundleGraph(bundleGraph) {
|
|
58
61
|
const { nodesJson, edges, publicIdByAssetId, environmentsJson } = bundleGraph.serializeForNative();
|
|
@@ -20,6 +20,7 @@ const worker_threads_1 = require("worker_threads");
|
|
|
20
20
|
const path_1 = __importDefault(require("path"));
|
|
21
21
|
const process_1 = __importDefault(require("process"));
|
|
22
22
|
const rust_1 = require("@atlaspack/rust");
|
|
23
|
+
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
23
24
|
const WORKER_PATH = path_1.default.join(__dirname, 'worker', 'index.js');
|
|
24
25
|
const ATLASPACK_NAPI_WORKERS = process_1.default.env.ATLASPACK_NAPI_WORKERS &&
|
|
25
26
|
parseInt(process_1.default.env.ATLASPACK_NAPI_WORKERS, 10);
|
|
@@ -43,6 +44,32 @@ class NapiWorkerPool {
|
|
|
43
44
|
let worker = new worker_threads_1.Worker(WORKER_PATH);
|
|
44
45
|
__classPrivateFieldGet(this, _NapiWorkerPool_workers, "f").push(worker);
|
|
45
46
|
__classPrivateFieldGet(this, _NapiWorkerPool_napiWorkers, "f").push(new Promise((res) => worker.once('message', res)));
|
|
47
|
+
// Re-emit log events from the worker thread into the main-thread logger
|
|
48
|
+
// so they reach reporters and are subject to log-level filtering.
|
|
49
|
+
worker.on('message', (message) => {
|
|
50
|
+
if (message != null &&
|
|
51
|
+
typeof message === 'object' &&
|
|
52
|
+
message.type === 'logEvent') {
|
|
53
|
+
const event = message.event;
|
|
54
|
+
switch (event.level) {
|
|
55
|
+
case 'verbose':
|
|
56
|
+
logger_1.default.verbose(event.diagnostics);
|
|
57
|
+
break;
|
|
58
|
+
case 'info':
|
|
59
|
+
logger_1.default.info(event.diagnostics);
|
|
60
|
+
break;
|
|
61
|
+
case 'warn':
|
|
62
|
+
logger_1.default.warn(event.diagnostics);
|
|
63
|
+
break;
|
|
64
|
+
case 'error':
|
|
65
|
+
logger_1.default.error(event.diagnostics);
|
|
66
|
+
break;
|
|
67
|
+
case 'progress':
|
|
68
|
+
logger_1.default.progress(event.message);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
46
73
|
}
|
|
47
74
|
}
|
|
48
75
|
clearAllWorkerState() {
|
|
@@ -55,6 +82,12 @@ class NapiWorkerPool {
|
|
|
55
82
|
worker.removeListener('message', messageHandler);
|
|
56
83
|
res();
|
|
57
84
|
}
|
|
85
|
+
else if (message != null &&
|
|
86
|
+
typeof message === 'object' &&
|
|
87
|
+
message.type === 'logEvent') {
|
|
88
|
+
// logEvent messages are forwarded asynchronously from the worker
|
|
89
|
+
// logger bridge and are expected at any time; ignore them here.
|
|
90
|
+
}
|
|
58
91
|
else {
|
|
59
92
|
// Log unexpected messages for debugging
|
|
60
93
|
// eslint-disable-next-line no-console
|
package/dist/atlaspack-v3/fs.js
CHANGED
|
@@ -45,6 +45,7 @@ class FileSystemV3 {
|
|
|
45
45
|
return __classPrivateFieldGet(this, _FileSystemV3_fs, "f").readFileSync(path, encoding);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
+
this.writeFile = (0, jsCallable_1.jsCallable)((path, contents) => __classPrivateFieldGet(this, _FileSystemV3_fs, "f").writeFile(path, Buffer.from(contents)));
|
|
48
49
|
__classPrivateFieldSet(this, _FileSystemV3_fs, fs, "f");
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -20,6 +20,5 @@ __exportStar(require("./environment"), exports);
|
|
|
20
20
|
__exportStar(require("./target"), exports);
|
|
21
21
|
__exportStar(require("./plugin-config"), exports);
|
|
22
22
|
__exportStar(require("./plugin-tracer"), exports);
|
|
23
|
-
__exportStar(require("./plugin-logger"), exports);
|
|
24
23
|
__exportStar(require("./plugin-options"), exports);
|
|
25
24
|
__exportStar(require("./mutable-asset"), exports);
|
|
@@ -59,8 +59,10 @@ const napi = __importStar(require("@atlaspack/rust"));
|
|
|
59
59
|
const fs_1 = require("@atlaspack/fs");
|
|
60
60
|
const package_manager_1 = require("@atlaspack/package-manager");
|
|
61
61
|
const worker_threads_1 = require("worker_threads");
|
|
62
|
+
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
62
63
|
const module = __importStar(require("module"));
|
|
63
64
|
const jsCallable_1 = require("../jsCallable");
|
|
65
|
+
const logger_2 = require("@atlaspack/logger");
|
|
64
66
|
const compat_1 = require("./compat");
|
|
65
67
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
66
68
|
class AtlaspackWorker {
|
|
@@ -121,7 +123,7 @@ class AtlaspackWorker {
|
|
|
121
123
|
const env = new compat_1.Environment(napiDependency.env);
|
|
122
124
|
const dependency = new compat_1.Dependency(napiDependency, env);
|
|
123
125
|
const defaultOptions = {
|
|
124
|
-
logger: new
|
|
126
|
+
logger: new logger_2.PluginLogger({ origin: key }),
|
|
125
127
|
tracer: new compat_1.PluginTracer(),
|
|
126
128
|
options: new compat_1.PluginOptions(this.options),
|
|
127
129
|
};
|
|
@@ -157,14 +159,23 @@ class AtlaspackWorker {
|
|
|
157
159
|
resolution: { type: 'excluded' },
|
|
158
160
|
};
|
|
159
161
|
}
|
|
162
|
+
// A resolver may return a result without filePath to indicate it didn't
|
|
163
|
+
// resolve the dependency (equivalent to returning null). The JS-side
|
|
164
|
+
// PathRequest treats this as "try the next resolver".
|
|
165
|
+
if (!result.filePath) {
|
|
166
|
+
return {
|
|
167
|
+
invalidations: [],
|
|
168
|
+
resolution: { type: 'unresolved' },
|
|
169
|
+
};
|
|
170
|
+
}
|
|
160
171
|
return {
|
|
161
172
|
invalidations: [],
|
|
162
173
|
resolution: {
|
|
163
174
|
type: 'resolved',
|
|
164
|
-
filePath: result.filePath
|
|
175
|
+
filePath: result.filePath,
|
|
165
176
|
canDefer: result.canDefer || false,
|
|
166
177
|
sideEffects: result.sideEffects ?? true,
|
|
167
|
-
code: result.code
|
|
178
|
+
code: result.code ?? undefined,
|
|
168
179
|
meta: result.meta || undefined,
|
|
169
180
|
pipeline: result.pipeline || undefined,
|
|
170
181
|
priority: compat_1.dependencyPriorityMap.intoNullable(result.priority),
|
|
@@ -192,7 +203,7 @@ class AtlaspackWorker {
|
|
|
192
203
|
contents, env, __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), map, this.options.projectRoot);
|
|
193
204
|
const pluginOptions = new compat_1.PluginOptions(this.options);
|
|
194
205
|
const defaultOptions = {
|
|
195
|
-
logger: new
|
|
206
|
+
logger: new logger_2.PluginLogger({ origin: key }),
|
|
196
207
|
tracer: new compat_1.PluginTracer(),
|
|
197
208
|
options: pluginOptions,
|
|
198
209
|
};
|
|
@@ -332,7 +343,7 @@ class AtlaspackWorker {
|
|
|
332
343
|
let packageManager = new package_manager_1.NodePackageManager(__classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), this.options.projectRoot);
|
|
333
344
|
if (transformer.setup) {
|
|
334
345
|
let setupResult = await transformer.setup({
|
|
335
|
-
logger: new
|
|
346
|
+
logger: new logger_2.PluginLogger({ origin: specifier }),
|
|
336
347
|
options: new compat_1.PluginOptions({
|
|
337
348
|
...this.options,
|
|
338
349
|
shouldAutoInstall: false,
|
|
@@ -369,6 +380,11 @@ class AtlaspackWorker {
|
|
|
369
380
|
}
|
|
370
381
|
exports.AtlaspackWorker = AtlaspackWorker;
|
|
371
382
|
_AtlaspackWorker_resolvers = new WeakMap(), _AtlaspackWorker_transformers = new WeakMap(), _AtlaspackWorker_fs = new WeakMap(), _AtlaspackWorker_packageManager = new WeakMap(), _AtlaspackWorker_options = new WeakMap(), _AtlaspackWorker_sideEffectDetector = new WeakMap();
|
|
383
|
+
// Forward all logger events from this worker thread to the main thread so
|
|
384
|
+
// they are re-emitted into the main-thread logger and reach reporters.
|
|
385
|
+
logger_1.default.onLog((event) => {
|
|
386
|
+
worker_threads_1.parentPort?.postMessage({ type: 'logEvent', event });
|
|
387
|
+
});
|
|
372
388
|
// Create napi worker and send it back to main thread
|
|
373
389
|
const worker = new AtlaspackWorker();
|
|
374
390
|
const napiWorker = napi.newNodejsWorker(worker);
|
|
@@ -43,6 +43,7 @@ const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
|
|
|
43
43
|
const logger_1 = __importStar(require("@atlaspack/logger"));
|
|
44
44
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
45
45
|
const AssetGraph_1 = __importDefault(require("../AssetGraph"));
|
|
46
|
+
const ReporterRunner_1 = require("../ReporterRunner");
|
|
46
47
|
const RequestTracker_1 = require("../RequestTracker");
|
|
47
48
|
const SymbolPropagation_1 = require("../SymbolPropagation");
|
|
48
49
|
const EnvironmentManager_1 = require("../EnvironmentManager");
|
|
@@ -55,7 +56,10 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
55
56
|
id: input.name,
|
|
56
57
|
run: async (runInput) => {
|
|
57
58
|
let options = runInput.options;
|
|
58
|
-
let { assetGraphPromise, commitPromise } = await rustAtlaspack.buildAssetGraph()
|
|
59
|
+
let { assetGraphPromise, commitPromise } = await rustAtlaspack.buildAssetGraph((eventJson) => {
|
|
60
|
+
let event = JSON.parse(eventJson);
|
|
61
|
+
(0, ReporterRunner_1.report)(event);
|
|
62
|
+
});
|
|
59
63
|
let [serializedAssetGraph, assetGraphError] = (await assetGraphPromise);
|
|
60
64
|
if (assetGraphError) {
|
|
61
65
|
throw new diagnostic_1.default({
|
|
@@ -18,6 +18,7 @@ const profiler_1 = require("@atlaspack/profiler");
|
|
|
18
18
|
const RequestTracker_1 = require("../RequestTracker");
|
|
19
19
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
20
20
|
const EnvironmentManager_1 = require("../EnvironmentManager");
|
|
21
|
+
const logger_1 = require("@atlaspack/logger");
|
|
21
22
|
function createAtlaspackBuildRequest(input) {
|
|
22
23
|
return {
|
|
23
24
|
type: RequestTracker_1.requestTypes.atlaspack_build_request,
|
|
@@ -78,12 +79,14 @@ async function run({ input, api, options, rustAtlaspack, }) {
|
|
|
78
79
|
])),
|
|
79
80
|
});
|
|
80
81
|
let packagingMeasurement = profiler_1.tracer.createMeasurement('packaging');
|
|
82
|
+
const span = logger_1.tracer.enter('writeBundles');
|
|
81
83
|
let writeBundlesRequest = (0, WriteBundlesRequest_1.default)({
|
|
82
84
|
bundleGraph,
|
|
83
85
|
optionsRef,
|
|
84
86
|
});
|
|
85
87
|
let { bundleInfo, scopeHoistingStats } = await api.runRequest(writeBundlesRequest);
|
|
86
88
|
packagingMeasurement && packagingMeasurement.end();
|
|
89
|
+
logger_1.tracer.exit(span);
|
|
87
90
|
(0, utils_1.assertSignalNotAborted)(signal);
|
|
88
91
|
return {
|
|
89
92
|
bundleGraph,
|
|
@@ -44,6 +44,7 @@ const graph_1 = require("@atlaspack/graph");
|
|
|
44
44
|
const logger_1 = require("@atlaspack/logger");
|
|
45
45
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
46
46
|
const BundleGraph_1 = __importStar(require("../BundleGraph"));
|
|
47
|
+
const ReporterRunner_1 = require("../ReporterRunner");
|
|
47
48
|
const dumpGraphToGraphViz_1 = __importDefault(require("../dumpGraphToGraphViz"));
|
|
48
49
|
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
49
50
|
const rust_1 = require("@atlaspack/rust");
|
|
@@ -64,7 +65,10 @@ function createBundleGraphRequestRust(input) {
|
|
|
64
65
|
run: async (runInput) => {
|
|
65
66
|
const { api, options, rustAtlaspack } = runInput;
|
|
66
67
|
(0, assert_1.default)(rustAtlaspack, 'BundleGraphRequestRust requires rustAtlaspack');
|
|
67
|
-
let { bundleGraphPromise, commitPromise } = await rustAtlaspack.buildBundleGraph()
|
|
68
|
+
let { bundleGraphPromise, commitPromise } = await rustAtlaspack.buildBundleGraph((eventJson) => {
|
|
69
|
+
let event = JSON.parse(eventJson);
|
|
70
|
+
(0, ReporterRunner_1.report)(event);
|
|
71
|
+
});
|
|
68
72
|
let [serializedBundleGraph, bundleGraphError] = (await bundleGraphPromise);
|
|
69
73
|
if (bundleGraphError) {
|
|
70
74
|
throw new diagnostic_1.default({ diagnostic: bundleGraphError });
|
package/lib/Atlaspack.js
CHANGED
|
@@ -118,6 +118,7 @@ function _featureFlags() {
|
|
|
118
118
|
var _atlaspackV = require("./atlaspack-v3");
|
|
119
119
|
var _AssetGraphRequest = _interopRequireDefault(require("./requests/AssetGraphRequest"));
|
|
120
120
|
var _AssetGraphRequestRust = require("./requests/AssetGraphRequestRust");
|
|
121
|
+
var _BundleGraphRequestRust = require("./requests/BundleGraphRequestRust");
|
|
121
122
|
var _rustWorkerThreadDylibHack = require("./rustWorkerThreadDylibHack");
|
|
122
123
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
123
124
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -197,7 +198,7 @@ class Atlaspack {
|
|
|
197
198
|
});
|
|
198
199
|
this.#resolvedOptions = resolvedOptions;
|
|
199
200
|
let rustAtlaspack;
|
|
200
|
-
if (resolvedOptions.featureFlags.atlaspackV3 || resolvedOptions.featureFlags.nativePackager) {
|
|
201
|
+
if (resolvedOptions.featureFlags.atlaspackV3 || resolvedOptions.featureFlags.fullNative || resolvedOptions.featureFlags.nativePackager) {
|
|
201
202
|
// eslint-disable-next-line no-unused-vars
|
|
202
203
|
let {
|
|
203
204
|
entries,
|
|
@@ -428,20 +429,51 @@ class Atlaspack {
|
|
|
428
429
|
type: 'buildStart'
|
|
429
430
|
});
|
|
430
431
|
this.#requestTracker.graph.invalidateOnBuildNodes();
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
432
|
+
let bundleGraph;
|
|
433
|
+
let bundleInfo;
|
|
434
|
+
let changedAssets;
|
|
435
|
+
let assetRequests;
|
|
436
|
+
let scopeHoistingStats;
|
|
437
|
+
if ((0, _featureFlags().getFeatureFlag)('fullNative') && this.rustAtlaspack) {
|
|
438
|
+
let [result, error] = await this.rustAtlaspack.build(eventJson => {
|
|
439
|
+
let event = JSON.parse(eventJson);
|
|
440
|
+
this.#reporterRunner.report(event);
|
|
441
|
+
});
|
|
442
|
+
if (error) {
|
|
443
|
+
throw new (_diagnostic().default)({
|
|
444
|
+
diagnostic: error
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
({
|
|
448
|
+
bundleGraph,
|
|
449
|
+
changedAssets
|
|
450
|
+
} = (0, _BundleGraphRequestRust.getBundleGraph)(result));
|
|
451
|
+
bundleInfo = new Map((result.bundleInfo ?? []).map(info => [info.bundleId, {
|
|
452
|
+
filePath: (0, _projectPath.toProjectPath)(options.projectRoot, info.filePath),
|
|
453
|
+
bundleId: info.bundleId,
|
|
454
|
+
type: info.type,
|
|
455
|
+
stats: {
|
|
456
|
+
size: info.size,
|
|
457
|
+
time: info.time
|
|
458
|
+
}
|
|
459
|
+
}]));
|
|
460
|
+
assetRequests = result.assetRequests ?? [];
|
|
461
|
+
} else {
|
|
462
|
+
let request = (0, _AtlaspackBuildRequest.default)({
|
|
463
|
+
optionsRef: this.#optionsRef,
|
|
464
|
+
requestedAssetIds: this.#requestedAssetIds,
|
|
465
|
+
signal
|
|
466
|
+
});
|
|
467
|
+
({
|
|
468
|
+
bundleGraph,
|
|
469
|
+
bundleInfo,
|
|
470
|
+
changedAssets,
|
|
471
|
+
assetRequests,
|
|
472
|
+
scopeHoistingStats
|
|
473
|
+
} = await this.#requestTracker.runRequest(request, {
|
|
474
|
+
force: true
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
445
477
|
this.#requestedAssetIds.clear();
|
|
446
478
|
await (0, _dumpGraphToGraphViz.default)(
|
|
447
479
|
// @ts-expect-error TS2345
|
|
@@ -69,11 +69,14 @@ class AtlaspackV3 {
|
|
|
69
69
|
this._napiWorkerPool.shutdown();
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
buildAssetGraph() {
|
|
73
|
-
return (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
72
|
+
buildAssetGraph(progressCallback) {
|
|
73
|
+
return (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi, progressCallback);
|
|
74
74
|
}
|
|
75
|
-
buildBundleGraph() {
|
|
76
|
-
return (0, _rust().atlaspackNapiBuildBundleGraph)(this._atlaspack_napi);
|
|
75
|
+
buildBundleGraph(progressCallback) {
|
|
76
|
+
return (0, _rust().atlaspackNapiBuildBundleGraph)(this._atlaspack_napi, progressCallback);
|
|
77
|
+
}
|
|
78
|
+
build(progressCallback) {
|
|
79
|
+
return (0, _rust().atlaspackNapiBuild)(this._atlaspack_napi, progressCallback);
|
|
77
80
|
}
|
|
78
81
|
loadBundleGraph(bundleGraph) {
|
|
79
82
|
const {
|
|
@@ -32,6 +32,13 @@ function _rust() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
+
function _logger() {
|
|
36
|
+
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
|
37
|
+
_logger = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
35
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
43
|
// @ts-expect-error TS2724
|
|
37
44
|
|
|
@@ -60,6 +67,31 @@ class NapiWorkerPool {
|
|
|
60
67
|
let worker = new (_worker_threads().Worker)(WORKER_PATH);
|
|
61
68
|
this.#workers.push(worker);
|
|
62
69
|
this.#napiWorkers.push(new Promise(res => worker.once('message', res)));
|
|
70
|
+
|
|
71
|
+
// Re-emit log events from the worker thread into the main-thread logger
|
|
72
|
+
// so they reach reporters and are subject to log-level filtering.
|
|
73
|
+
worker.on('message', message => {
|
|
74
|
+
if (message != null && typeof message === 'object' && message.type === 'logEvent') {
|
|
75
|
+
const event = message.event;
|
|
76
|
+
switch (event.level) {
|
|
77
|
+
case 'verbose':
|
|
78
|
+
_logger().default.verbose(event.diagnostics);
|
|
79
|
+
break;
|
|
80
|
+
case 'info':
|
|
81
|
+
_logger().default.info(event.diagnostics);
|
|
82
|
+
break;
|
|
83
|
+
case 'warn':
|
|
84
|
+
_logger().default.warn(event.diagnostics);
|
|
85
|
+
break;
|
|
86
|
+
case 'error':
|
|
87
|
+
_logger().default.error(event.diagnostics);
|
|
88
|
+
break;
|
|
89
|
+
case 'progress':
|
|
90
|
+
_logger().default.progress(event.message);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
63
95
|
}
|
|
64
96
|
}
|
|
65
97
|
clearAllWorkerState() {
|
|
@@ -72,6 +104,9 @@ class NapiWorkerPool {
|
|
|
72
104
|
if (message === 'stateCleared') {
|
|
73
105
|
worker.removeListener('message', messageHandler);
|
|
74
106
|
res();
|
|
107
|
+
} else if (message != null && typeof message === 'object' && message.type === 'logEvent') {
|
|
108
|
+
// logEvent messages are forwarded asynchronously from the worker
|
|
109
|
+
// logger bridge and are expected at any time; ignore them here.
|
|
75
110
|
} else {
|
|
76
111
|
// Log unexpected messages for debugging
|
|
77
112
|
// eslint-disable-next-line no-console
|
package/lib/atlaspack-v3/fs.js
CHANGED
|
@@ -69,17 +69,6 @@ Object.keys(_pluginTracer).forEach(function (key) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
var _pluginLogger = require("./plugin-logger");
|
|
73
|
-
Object.keys(_pluginLogger).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _pluginLogger[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _pluginLogger[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
72
|
var _pluginOptions = require("./plugin-options");
|
|
84
73
|
Object.keys(_pluginOptions).forEach(function (key) {
|
|
85
74
|
if (key === "default" || key === "__esModule") return;
|