@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
|
@@ -40,6 +40,13 @@ function _worker_threads() {
|
|
|
40
40
|
};
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
|
+
function _logger() {
|
|
44
|
+
const data = _interopRequireWildcard(require("@atlaspack/logger"));
|
|
45
|
+
_logger = function () {
|
|
46
|
+
return data;
|
|
47
|
+
};
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
43
50
|
function _module() {
|
|
44
51
|
const data = _interopRequireWildcard(require("module"));
|
|
45
52
|
_module = function () {
|
|
@@ -144,7 +151,9 @@ class AtlaspackWorker {
|
|
|
144
151
|
const env = new _compat.Environment(napiDependency.env);
|
|
145
152
|
const dependency = new _compat.Dependency(napiDependency, env);
|
|
146
153
|
const defaultOptions = {
|
|
147
|
-
logger: new
|
|
154
|
+
logger: new (_logger().PluginLogger)({
|
|
155
|
+
origin: key
|
|
156
|
+
}),
|
|
148
157
|
tracer: new _compat.PluginTracer(),
|
|
149
158
|
options: new _compat.PluginOptions(this.options)
|
|
150
159
|
};
|
|
@@ -186,14 +195,25 @@ class AtlaspackWorker {
|
|
|
186
195
|
}
|
|
187
196
|
};
|
|
188
197
|
}
|
|
198
|
+
// A resolver may return a result without filePath to indicate it didn't
|
|
199
|
+
// resolve the dependency (equivalent to returning null). The JS-side
|
|
200
|
+
// PathRequest treats this as "try the next resolver".
|
|
201
|
+
if (!result.filePath) {
|
|
202
|
+
return {
|
|
203
|
+
invalidations: [],
|
|
204
|
+
resolution: {
|
|
205
|
+
type: 'unresolved'
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
189
209
|
return {
|
|
190
210
|
invalidations: [],
|
|
191
211
|
resolution: {
|
|
192
212
|
type: 'resolved',
|
|
193
|
-
filePath: result.filePath
|
|
213
|
+
filePath: result.filePath,
|
|
194
214
|
canDefer: result.canDefer || false,
|
|
195
215
|
sideEffects: result.sideEffects ?? true,
|
|
196
|
-
code: result.code
|
|
216
|
+
code: result.code ?? undefined,
|
|
197
217
|
meta: result.meta || undefined,
|
|
198
218
|
pipeline: result.pipeline || undefined,
|
|
199
219
|
priority: _compat.dependencyPriorityMap.intoNullable(result.priority),
|
|
@@ -229,7 +249,9 @@ class AtlaspackWorker {
|
|
|
229
249
|
contents, env, this.#fs, map, this.options.projectRoot);
|
|
230
250
|
const pluginOptions = new _compat.PluginOptions(this.options);
|
|
231
251
|
const defaultOptions = {
|
|
232
|
-
logger: new
|
|
252
|
+
logger: new (_logger().PluginLogger)({
|
|
253
|
+
origin: key
|
|
254
|
+
}),
|
|
233
255
|
tracer: new _compat.PluginTracer(),
|
|
234
256
|
options: pluginOptions
|
|
235
257
|
};
|
|
@@ -358,7 +380,9 @@ class AtlaspackWorker {
|
|
|
358
380
|
if (transformer.setup) {
|
|
359
381
|
var _setupResult$env;
|
|
360
382
|
let setupResult = await transformer.setup({
|
|
361
|
-
logger: new
|
|
383
|
+
logger: new (_logger().PluginLogger)({
|
|
384
|
+
origin: specifier
|
|
385
|
+
}),
|
|
362
386
|
options: new _compat.PluginOptions({
|
|
363
387
|
...this.options,
|
|
364
388
|
shouldAutoInstall: false,
|
|
@@ -395,8 +419,17 @@ class AtlaspackWorker {
|
|
|
395
419
|
}
|
|
396
420
|
}
|
|
397
421
|
|
|
398
|
-
//
|
|
422
|
+
// Forward all logger events from this worker thread to the main thread so
|
|
423
|
+
// they are re-emitted into the main-thread logger and reach reporters.
|
|
399
424
|
exports.AtlaspackWorker = AtlaspackWorker;
|
|
425
|
+
_logger().default.onLog(event => {
|
|
426
|
+
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.postMessage({
|
|
427
|
+
type: 'logEvent',
|
|
428
|
+
event
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// Create napi worker and send it back to main thread
|
|
400
433
|
const worker = new AtlaspackWorker();
|
|
401
434
|
const napiWorker = napi().newNodejsWorker(worker);
|
|
402
435
|
_worker_threads().parentPort === null || _worker_threads().parentPort === void 0 || _worker_threads().parentPort.postMessage(napiWorker);
|
|
@@ -34,6 +34,7 @@ function _featureFlags() {
|
|
|
34
34
|
return data;
|
|
35
35
|
}
|
|
36
36
|
var _AssetGraph = _interopRequireDefault(require("../AssetGraph"));
|
|
37
|
+
var _ReporterRunner = require("../ReporterRunner");
|
|
37
38
|
var _RequestTracker = require("../RequestTracker");
|
|
38
39
|
var _SymbolPropagation = require("../SymbolPropagation");
|
|
39
40
|
var _EnvironmentManager = require("../EnvironmentManager");
|
|
@@ -51,7 +52,10 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
51
52
|
let {
|
|
52
53
|
assetGraphPromise,
|
|
53
54
|
commitPromise
|
|
54
|
-
} = await rustAtlaspack.buildAssetGraph(
|
|
55
|
+
} = await rustAtlaspack.buildAssetGraph(eventJson => {
|
|
56
|
+
let event = JSON.parse(eventJson);
|
|
57
|
+
(0, _ReporterRunner.report)(event);
|
|
58
|
+
});
|
|
55
59
|
let [serializedAssetGraph, assetGraphError] = await assetGraphPromise;
|
|
56
60
|
if (assetGraphError) {
|
|
57
61
|
throw new (_diagnostic().default)({
|
|
@@ -30,6 +30,13 @@ function _featureFlags() {
|
|
|
30
30
|
return data;
|
|
31
31
|
}
|
|
32
32
|
var _EnvironmentManager = require("../EnvironmentManager");
|
|
33
|
+
function _logger() {
|
|
34
|
+
const data = require("@atlaspack/logger");
|
|
35
|
+
_logger = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
33
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
41
|
function createAtlaspackBuildRequest(input) {
|
|
35
42
|
return {
|
|
@@ -96,6 +103,7 @@ async function run({
|
|
|
96
103
|
changedAssets: new Map(Array.from(changedAssets).map(([id, asset]) => [id, (0, _Asset.assetFromValue)(asset, options)]))
|
|
97
104
|
});
|
|
98
105
|
let packagingMeasurement = _profiler().tracer.createMeasurement('packaging');
|
|
106
|
+
const span = _logger().tracer.enter('writeBundles');
|
|
99
107
|
let writeBundlesRequest = (0, _WriteBundlesRequest.default)({
|
|
100
108
|
bundleGraph,
|
|
101
109
|
optionsRef
|
|
@@ -105,6 +113,7 @@ async function run({
|
|
|
105
113
|
scopeHoistingStats
|
|
106
114
|
} = await api.runRequest(writeBundlesRequest);
|
|
107
115
|
packagingMeasurement && packagingMeasurement.end();
|
|
116
|
+
_logger().tracer.exit(span);
|
|
108
117
|
(0, _utils.assertSignalNotAborted)(signal);
|
|
109
118
|
return {
|
|
110
119
|
bundleGraph,
|
|
@@ -41,6 +41,7 @@ function _featureFlags() {
|
|
|
41
41
|
return data;
|
|
42
42
|
}
|
|
43
43
|
var _BundleGraph = _interopRequireWildcard(require("../BundleGraph"));
|
|
44
|
+
var _ReporterRunner = require("../ReporterRunner");
|
|
44
45
|
var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
|
|
45
46
|
function _nullthrows() {
|
|
46
47
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
@@ -83,7 +84,10 @@ function createBundleGraphRequestRust(input) {
|
|
|
83
84
|
let {
|
|
84
85
|
bundleGraphPromise,
|
|
85
86
|
commitPromise
|
|
86
|
-
} = await rustAtlaspack.buildBundleGraph(
|
|
87
|
+
} = await rustAtlaspack.buildBundleGraph(eventJson => {
|
|
88
|
+
let event = JSON.parse(eventJson);
|
|
89
|
+
(0, _ReporterRunner.report)(event);
|
|
90
|
+
});
|
|
87
91
|
let [serializedBundleGraph, bundleGraphError] = await bundleGraphPromise;
|
|
88
92
|
if (bundleGraphError) {
|
|
89
93
|
throw new (_diagnostic().default)({
|
|
@@ -24,8 +24,9 @@ export declare class AtlaspackV3 {
|
|
|
24
24
|
constructor(atlaspack_napi: AtlaspackNapi, napiWorkerPool: INapiWorkerPool, isDefaultNapiWorkerPool: boolean);
|
|
25
25
|
static create({ fs, packageManager, threads, lmdb, napiWorkerPool, ...options }: AtlaspackV3Options): Promise<AtlaspackV3>;
|
|
26
26
|
end(): void;
|
|
27
|
-
buildAssetGraph(): Promise<any>;
|
|
28
|
-
buildBundleGraph(): Promise<any>;
|
|
27
|
+
buildAssetGraph(progressCallback?: (eventJson: string) => void): Promise<any>;
|
|
28
|
+
buildBundleGraph(progressCallback?: (eventJson: string) => void): Promise<any>;
|
|
29
|
+
build(progressCallback: (eventJson: string) => void): Promise<any>;
|
|
29
30
|
loadBundleGraph(bundleGraph: BundleGraph): Promise<void>;
|
|
30
31
|
updateBundleGraph(bundleGraph: BundleGraph, changedAssetIds: string[]): Promise<void>;
|
|
31
32
|
package(bundleId: string, options?: PackageOptions): Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.38.2",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
26
|
-
"@atlaspack/build-cache": "2.13.
|
|
27
|
-
"@atlaspack/cache": "3.2.
|
|
26
|
+
"@atlaspack/build-cache": "2.13.14",
|
|
27
|
+
"@atlaspack/cache": "3.2.55",
|
|
28
28
|
"@atlaspack/diagnostic": "2.14.4",
|
|
29
29
|
"@atlaspack/events": "2.14.4",
|
|
30
|
-
"@atlaspack/feature-flags": "2.
|
|
31
|
-
"@atlaspack/fs": "2.15.
|
|
32
|
-
"@atlaspack/graph": "3.6.
|
|
33
|
-
"@atlaspack/logger": "2.14.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.
|
|
35
|
-
"@atlaspack/plugin": "2.14.
|
|
36
|
-
"@atlaspack/profiler": "2.15.
|
|
37
|
-
"@atlaspack/rust": "3.
|
|
38
|
-
"@atlaspack/types": "2.15.
|
|
39
|
-
"@atlaspack/utils": "3.
|
|
40
|
-
"@atlaspack/workers": "2.14.
|
|
41
|
-
"@atlaspack/source-map": "3.3.
|
|
30
|
+
"@atlaspack/feature-flags": "2.31.0",
|
|
31
|
+
"@atlaspack/fs": "2.15.55",
|
|
32
|
+
"@atlaspack/graph": "3.6.22",
|
|
33
|
+
"@atlaspack/logger": "2.14.52",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.60",
|
|
35
|
+
"@atlaspack/plugin": "2.14.60",
|
|
36
|
+
"@atlaspack/profiler": "2.15.21",
|
|
37
|
+
"@atlaspack/rust": "3.28.0",
|
|
38
|
+
"@atlaspack/types": "2.15.50",
|
|
39
|
+
"@atlaspack/utils": "3.4.2",
|
|
40
|
+
"@atlaspack/workers": "2.14.60",
|
|
41
|
+
"@atlaspack/source-map": "3.3.4",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
44
44
|
"clone": "^2.1.1",
|
package/src/Atlaspack.ts
CHANGED
|
@@ -67,6 +67,7 @@ import {AtlaspackV3, FileSystemV3} from './atlaspack-v3';
|
|
|
67
67
|
import createAssetGraphRequestJS from './requests/AssetGraphRequest';
|
|
68
68
|
import {createAssetGraphRequestRust} from './requests/AssetGraphRequestRust';
|
|
69
69
|
import type {AssetGraphRequestResult} from './requests/AssetGraphRequest';
|
|
70
|
+
import {getBundleGraph} from './requests/BundleGraphRequestRust';
|
|
70
71
|
import {loadRustWorkerThreadDylibHack} from './rustWorkerThreadDylibHack';
|
|
71
72
|
|
|
72
73
|
registerCoreWithSerializer();
|
|
@@ -171,6 +172,7 @@ export default class Atlaspack {
|
|
|
171
172
|
let rustAtlaspack: AtlaspackV3;
|
|
172
173
|
if (
|
|
173
174
|
resolvedOptions.featureFlags.atlaspackV3 ||
|
|
175
|
+
resolvedOptions.featureFlags.fullNative ||
|
|
174
176
|
resolvedOptions.featureFlags.nativePackager
|
|
175
177
|
) {
|
|
176
178
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -433,19 +435,59 @@ export default class Atlaspack {
|
|
|
433
435
|
|
|
434
436
|
this.#requestTracker.graph.invalidateOnBuildNodes();
|
|
435
437
|
|
|
436
|
-
let
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
let bundleGraph: any;
|
|
439
|
+
let bundleInfo: Map<any, any>;
|
|
440
|
+
let changedAssets: Map<any, any>;
|
|
441
|
+
let assetRequests: Array<any>;
|
|
442
|
+
let scopeHoistingStats: any;
|
|
443
|
+
|
|
444
|
+
if (getFeatureFlag('fullNative') && this.rustAtlaspack) {
|
|
445
|
+
let [result, error] = await this.rustAtlaspack.build(
|
|
446
|
+
(eventJson: string) => {
|
|
447
|
+
let event = JSON.parse(eventJson);
|
|
448
|
+
this.#reporterRunner.report(event);
|
|
449
|
+
},
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
if (error) {
|
|
453
|
+
throw new ThrowableDiagnostic({diagnostic: error});
|
|
454
|
+
}
|
|
455
|
+
({bundleGraph, changedAssets} = getBundleGraph(result));
|
|
456
|
+
bundleInfo = new Map(
|
|
457
|
+
(result.bundleInfo ?? []).map(
|
|
458
|
+
(info: {
|
|
459
|
+
bundleId: string;
|
|
460
|
+
filePath: string;
|
|
461
|
+
type: string;
|
|
462
|
+
size: number;
|
|
463
|
+
time: number;
|
|
464
|
+
}) => [
|
|
465
|
+
info.bundleId,
|
|
466
|
+
{
|
|
467
|
+
filePath: toProjectPath(options.projectRoot, info.filePath),
|
|
468
|
+
bundleId: info.bundleId,
|
|
469
|
+
type: info.type,
|
|
470
|
+
stats: {size: info.size, time: info.time},
|
|
471
|
+
},
|
|
472
|
+
],
|
|
473
|
+
),
|
|
474
|
+
);
|
|
475
|
+
assetRequests = result.assetRequests ?? [];
|
|
476
|
+
} else {
|
|
477
|
+
let request = createAtlaspackBuildRequest({
|
|
478
|
+
optionsRef: this.#optionsRef,
|
|
479
|
+
requestedAssetIds: this.#requestedAssetIds,
|
|
480
|
+
signal,
|
|
481
|
+
});
|
|
441
482
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
483
|
+
({
|
|
484
|
+
bundleGraph,
|
|
485
|
+
bundleInfo,
|
|
486
|
+
changedAssets,
|
|
487
|
+
assetRequests,
|
|
488
|
+
scopeHoistingStats,
|
|
489
|
+
} = await this.#requestTracker.runRequest(request, {force: true}));
|
|
490
|
+
}
|
|
449
491
|
|
|
450
492
|
this.#requestedAssetIds.clear();
|
|
451
493
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
atlaspackNapiCreate,
|
|
3
|
+
atlaspackNapiBuild,
|
|
3
4
|
atlaspackNapiBuildAssetGraph,
|
|
4
5
|
atlaspackNapiBuildBundleGraph,
|
|
5
6
|
atlaspackNapiRespondToFsEvents,
|
|
@@ -100,12 +101,29 @@ export class AtlaspackV3 {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
buildAssetGraph(
|
|
104
|
-
|
|
104
|
+
buildAssetGraph(
|
|
105
|
+
progressCallback?: (eventJson: string) => void,
|
|
106
|
+
): Promise<any> {
|
|
107
|
+
return atlaspackNapiBuildAssetGraph(
|
|
108
|
+
this._atlaspack_napi,
|
|
109
|
+
progressCallback,
|
|
110
|
+
) as Promise<any>;
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
buildBundleGraph(
|
|
108
|
-
|
|
113
|
+
buildBundleGraph(
|
|
114
|
+
progressCallback?: (eventJson: string) => void,
|
|
115
|
+
): Promise<any> {
|
|
116
|
+
return atlaspackNapiBuildBundleGraph(
|
|
117
|
+
this._atlaspack_napi,
|
|
118
|
+
progressCallback,
|
|
119
|
+
) as Promise<any>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
build(progressCallback: (eventJson: string) => void): Promise<any> {
|
|
123
|
+
return atlaspackNapiBuild(
|
|
124
|
+
this._atlaspack_napi,
|
|
125
|
+
progressCallback,
|
|
126
|
+
) as Promise<any>;
|
|
109
127
|
}
|
|
110
128
|
|
|
111
129
|
loadBundleGraph(bundleGraph: BundleGraph): Promise<void> {
|
|
@@ -5,6 +5,8 @@ import process from 'process';
|
|
|
5
5
|
// @ts-expect-error TS2724
|
|
6
6
|
import type {Transferable} from '@atlaspack/rust';
|
|
7
7
|
import {getAvailableThreads} from '@atlaspack/rust';
|
|
8
|
+
import logger from '@atlaspack/logger';
|
|
9
|
+
import type {LogEvent} from '@atlaspack/types-internal';
|
|
8
10
|
|
|
9
11
|
const WORKER_PATH = path.join(__dirname, 'worker', 'index.js');
|
|
10
12
|
const ATLASPACK_NAPI_WORKERS =
|
|
@@ -43,6 +45,35 @@ export class NapiWorkerPool implements INapiWorkerPool {
|
|
|
43
45
|
worker.once('message', res),
|
|
44
46
|
),
|
|
45
47
|
);
|
|
48
|
+
|
|
49
|
+
// Re-emit log events from the worker thread into the main-thread logger
|
|
50
|
+
// so they reach reporters and are subject to log-level filtering.
|
|
51
|
+
worker.on('message', (message: unknown) => {
|
|
52
|
+
if (
|
|
53
|
+
message != null &&
|
|
54
|
+
typeof message === 'object' &&
|
|
55
|
+
(message as {type?: unknown}).type === 'logEvent'
|
|
56
|
+
) {
|
|
57
|
+
const event = (message as {type: string; event: LogEvent}).event;
|
|
58
|
+
switch (event.level) {
|
|
59
|
+
case 'verbose':
|
|
60
|
+
logger.verbose(event.diagnostics);
|
|
61
|
+
break;
|
|
62
|
+
case 'info':
|
|
63
|
+
logger.info(event.diagnostics);
|
|
64
|
+
break;
|
|
65
|
+
case 'warn':
|
|
66
|
+
logger.warn(event.diagnostics);
|
|
67
|
+
break;
|
|
68
|
+
case 'error':
|
|
69
|
+
logger.error(event.diagnostics);
|
|
70
|
+
break;
|
|
71
|
+
case 'progress':
|
|
72
|
+
logger.progress(event.message);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
46
77
|
}
|
|
47
78
|
}
|
|
48
79
|
|
|
@@ -59,6 +90,13 @@ export class NapiWorkerPool implements INapiWorkerPool {
|
|
|
59
90
|
if (message === 'stateCleared') {
|
|
60
91
|
worker.removeListener('message', messageHandler);
|
|
61
92
|
res();
|
|
93
|
+
} else if (
|
|
94
|
+
message != null &&
|
|
95
|
+
typeof message === 'object' &&
|
|
96
|
+
(message as {type?: unknown}).type === 'logEvent'
|
|
97
|
+
) {
|
|
98
|
+
// logEvent messages are forwarded asynchronously from the worker
|
|
99
|
+
// logger bridge and are expected at any time; ignore them here.
|
|
62
100
|
} else {
|
|
63
101
|
// Log unexpected messages for debugging
|
|
64
102
|
// eslint-disable-next-line no-console
|
package/src/atlaspack-v3/fs.ts
CHANGED
|
@@ -19,14 +19,15 @@ import type {
|
|
|
19
19
|
} from '@atlaspack/types';
|
|
20
20
|
import type {FeatureFlags} from '@atlaspack/feature-flags';
|
|
21
21
|
import {parentPort} from 'worker_threads';
|
|
22
|
+
import logger from '@atlaspack/logger';
|
|
22
23
|
import * as module from 'module';
|
|
23
24
|
|
|
24
25
|
import {jsCallable} from '../jsCallable';
|
|
26
|
+
import {PluginLogger} from '@atlaspack/logger';
|
|
25
27
|
import {
|
|
26
28
|
Environment,
|
|
27
29
|
Dependency,
|
|
28
30
|
PluginConfig,
|
|
29
|
-
PluginLogger,
|
|
30
31
|
PluginTracer,
|
|
31
32
|
PluginOptions,
|
|
32
33
|
MutableAsset,
|
|
@@ -130,7 +131,7 @@ export class AtlaspackWorker {
|
|
|
130
131
|
const dependency = new Dependency(napiDependency, env);
|
|
131
132
|
|
|
132
133
|
const defaultOptions = {
|
|
133
|
-
logger: new PluginLogger(),
|
|
134
|
+
logger: new PluginLogger({origin: key}),
|
|
134
135
|
tracer: new PluginTracer(),
|
|
135
136
|
options: new PluginOptions(this.options),
|
|
136
137
|
} as const;
|
|
@@ -173,15 +174,24 @@ export class AtlaspackWorker {
|
|
|
173
174
|
resolution: {type: 'excluded'},
|
|
174
175
|
};
|
|
175
176
|
}
|
|
177
|
+
// A resolver may return a result without filePath to indicate it didn't
|
|
178
|
+
// resolve the dependency (equivalent to returning null). The JS-side
|
|
179
|
+
// PathRequest treats this as "try the next resolver".
|
|
180
|
+
if (!result.filePath) {
|
|
181
|
+
return {
|
|
182
|
+
invalidations: [],
|
|
183
|
+
resolution: {type: 'unresolved'},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
176
186
|
|
|
177
187
|
return {
|
|
178
188
|
invalidations: [],
|
|
179
189
|
resolution: {
|
|
180
190
|
type: 'resolved',
|
|
181
|
-
filePath: result.filePath
|
|
191
|
+
filePath: result.filePath,
|
|
182
192
|
canDefer: result.canDefer || false,
|
|
183
193
|
sideEffects: result.sideEffects ?? true,
|
|
184
|
-
code: result.code
|
|
194
|
+
code: result.code ?? undefined,
|
|
185
195
|
meta: result.meta || undefined,
|
|
186
196
|
pipeline: result.pipeline || undefined,
|
|
187
197
|
priority: dependencyPriorityMap.intoNullable(result.priority),
|
|
@@ -227,7 +237,7 @@ export class AtlaspackWorker {
|
|
|
227
237
|
|
|
228
238
|
const pluginOptions = new PluginOptions(this.options);
|
|
229
239
|
const defaultOptions = {
|
|
230
|
-
logger: new PluginLogger(),
|
|
240
|
+
logger: new PluginLogger({origin: key}),
|
|
231
241
|
tracer: new PluginTracer(),
|
|
232
242
|
options: pluginOptions,
|
|
233
243
|
} as const;
|
|
@@ -394,7 +404,7 @@ export class AtlaspackWorker {
|
|
|
394
404
|
|
|
395
405
|
if (transformer.setup) {
|
|
396
406
|
let setupResult = await transformer.setup({
|
|
397
|
-
logger: new PluginLogger(),
|
|
407
|
+
logger: new PluginLogger({origin: specifier}),
|
|
398
408
|
options: new PluginOptions({
|
|
399
409
|
...this.options,
|
|
400
410
|
shouldAutoInstall: false,
|
|
@@ -439,6 +449,12 @@ export class AtlaspackWorker {
|
|
|
439
449
|
}
|
|
440
450
|
}
|
|
441
451
|
|
|
452
|
+
// Forward all logger events from this worker thread to the main thread so
|
|
453
|
+
// they are re-emitted into the main-thread logger and reach reporters.
|
|
454
|
+
logger.onLog((event) => {
|
|
455
|
+
parentPort?.postMessage({type: 'logEvent', event});
|
|
456
|
+
});
|
|
457
|
+
|
|
442
458
|
// Create napi worker and send it back to main thread
|
|
443
459
|
const worker = new AtlaspackWorker();
|
|
444
460
|
const napiWorker = napi.newNodejsWorker(worker);
|
|
@@ -7,6 +7,7 @@ import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
|
7
7
|
|
|
8
8
|
import AssetGraph from '../AssetGraph';
|
|
9
9
|
import type {AtlaspackV3} from '../atlaspack-v3';
|
|
10
|
+
import {report} from '../ReporterRunner';
|
|
10
11
|
import {requestTypes, StaticRunOpts} from '../RequestTracker';
|
|
11
12
|
import {propagateSymbols} from '../SymbolPropagation';
|
|
12
13
|
import type {
|
|
@@ -54,7 +55,10 @@ export function createAssetGraphRequestRust(
|
|
|
54
55
|
run: async (runInput) => {
|
|
55
56
|
let options = runInput.options;
|
|
56
57
|
let {assetGraphPromise, commitPromise} =
|
|
57
|
-
await rustAtlaspack.buildAssetGraph()
|
|
58
|
+
await rustAtlaspack.buildAssetGraph((eventJson: string) => {
|
|
59
|
+
let event = JSON.parse(eventJson);
|
|
60
|
+
report(event);
|
|
61
|
+
});
|
|
58
62
|
|
|
59
63
|
let [serializedAssetGraph, assetGraphError] =
|
|
60
64
|
(await assetGraphPromise) as [SerializedAssetGraphDelta, Error | null];
|
|
@@ -23,6 +23,7 @@ import {tracer} from '@atlaspack/profiler';
|
|
|
23
23
|
import {requestTypes} from '../RequestTracker';
|
|
24
24
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
25
25
|
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
26
|
+
import {tracer as atlaspackTracer} from '@atlaspack/logger';
|
|
26
27
|
|
|
27
28
|
type AtlaspackBuildRequestInput = {
|
|
28
29
|
optionsRef: SharedReference;
|
|
@@ -144,6 +145,8 @@ async function run({
|
|
|
144
145
|
});
|
|
145
146
|
|
|
146
147
|
let packagingMeasurement = tracer.createMeasurement('packaging');
|
|
148
|
+
const span = atlaspackTracer.enter('writeBundles');
|
|
149
|
+
|
|
147
150
|
let writeBundlesRequest = createWriteBundlesRequest({
|
|
148
151
|
bundleGraph,
|
|
149
152
|
optionsRef,
|
|
@@ -152,6 +155,7 @@ async function run({
|
|
|
152
155
|
let {bundleInfo, scopeHoistingStats} =
|
|
153
156
|
await api.runRequest(writeBundlesRequest);
|
|
154
157
|
packagingMeasurement && packagingMeasurement.end();
|
|
158
|
+
atlaspackTracer.exit(span);
|
|
155
159
|
assertSignalNotAborted(signal);
|
|
156
160
|
|
|
157
161
|
return {
|
|
@@ -7,6 +7,7 @@ import {instrument, instrumentAsync, PluginLogger} from '@atlaspack/logger';
|
|
|
7
7
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
8
8
|
|
|
9
9
|
import InternalBundleGraph, {bundleGraphEdgeTypes} from '../BundleGraph';
|
|
10
|
+
import {report} from '../ReporterRunner';
|
|
10
11
|
import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
|
|
11
12
|
import nullthrows from 'nullthrows';
|
|
12
13
|
import {hashString} from '@atlaspack/rust';
|
|
@@ -96,7 +97,10 @@ export default function createBundleGraphRequestRust(
|
|
|
96
97
|
invariant(rustAtlaspack, 'BundleGraphRequestRust requires rustAtlaspack');
|
|
97
98
|
|
|
98
99
|
let {bundleGraphPromise, commitPromise} =
|
|
99
|
-
await rustAtlaspack.buildBundleGraph()
|
|
100
|
+
await rustAtlaspack.buildBundleGraph((eventJson: string) => {
|
|
101
|
+
let event = JSON.parse(eventJson);
|
|
102
|
+
report(event);
|
|
103
|
+
});
|
|
100
104
|
let [serializedBundleGraph, bundleGraphError] =
|
|
101
105
|
(await bundleGraphPromise) as [SerializedBundleGraph, Error | null];
|
|
102
106
|
|