forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregister-hooks.ts
More file actions
33 lines (29 loc) · 941 Bytes
/
register-hooks.ts
File metadata and controls
33 lines (29 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { register } from 'node:module';
import { pathToFileURL } from 'node:url';
import { MessageChannel, workerData } from 'node:worker_threads';
import { isLegacyESMLoaderImplementation } from './utils-lts-node';
if (isLegacyESMLoaderImplementation && workerData) {
/** TODO: Remove when Node.js versions < 22.2 are no longer supported. */
register('./loader-hooks.js', {
parentURL: pathToFileURL(__filename),
data: workerData,
});
} else {
const { port1, port2 } = new MessageChannel();
process.once('message', (msg) => {
port1.postMessage(msg);
port1.close();
});
register('./loader-hooks.js', {
parentURL: pathToFileURL(__filename),
data: { port: port2 },
transferList: [port2],
});
}