Skip to content

Commit 019614b

Browse files
committed
Revert "fix(@angular-devkit/build-angular): ensure Sass worker implementation supports Node.js 12.14"
This reverts commit 4dc7cf9.
1 parent 77fe6c4 commit 019614b

File tree

2 files changed

+8
-40
lines changed

2 files changed

+8
-40
lines changed

packages/angular_devkit/build_angular/src/sass/sass-service.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ interface RenderResponseMessage {
3939
result?: Result;
4040
}
4141

42-
/**
43-
* Workaround required for lack of new Worker transfer list support in Node.js prior to 12.17
44-
*/
45-
let transferListWorkaround = false;
46-
const version = process.versions.node.split('.').map((part) => Number(part));
47-
if (version[0] === 12 && version[1] < 17) {
48-
transferListWorkaround = true;
49-
}
50-
5142
/**
5243
* A Sass renderer implementation that provides an interface that can be used by Webpack's
5344
* `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
@@ -134,14 +125,10 @@ export class SassWorkerImplementation {
134125

135126
const workerPath = require.resolve('./worker');
136127
const worker = new Worker(workerPath, {
137-
workerData: transferListWorkaround ? undefined : { workerImporterPort, importerSignal },
138-
transferList: transferListWorkaround ? undefined : [workerImporterPort],
128+
workerData: { workerImporterPort, importerSignal },
129+
transferList: [workerImporterPort],
139130
});
140131

141-
if (transferListWorkaround) {
142-
worker.postMessage({ init: true, workerImporterPort, importerSignal }, [workerImporterPort]);
143-
}
144-
145132
worker.on('message', (response: RenderResponseMessage) => {
146133
const request = this.requests.get(response.id);
147134
if (!request) {

packages/angular_devkit/build_angular/src/sass/worker.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,27 @@ interface RenderRequestMessage {
1818
* importer on the main thread.
1919
*/
2020
id: number;
21-
2221
/**
2322
* The Sass options to provide to the `dart-sass` render function.
2423
*/
2524
options: Options;
26-
2725
/**
2826
* Indicates the request has a custom importer function on the main thread.
2927
*/
3028
hasImporter: boolean;
31-
32-
/**
33-
* Indicates this is not an init message.
34-
*/
35-
init: undefined;
36-
}
37-
38-
interface InitMessage {
39-
init: true;
40-
workerImporterPort: MessagePort;
41-
importerSignal: Int32Array;
4229
}
4330

44-
if (!parentPort) {
31+
if (!parentPort || !workerData) {
4532
throw new Error('Sass worker must be executed as a Worker.');
4633
}
4734

4835
// The importer variables are used to proxy import requests to the main thread
49-
let { workerImporterPort, importerSignal } = (workerData || {}) as InitMessage;
50-
51-
parentPort.on('message', (message: RenderRequestMessage | InitMessage) => {
52-
// The init message is only needed to support Node.js < 12.17 and can be removed once support is dropped
53-
if (message.init) {
54-
workerImporterPort = message.workerImporterPort;
55-
importerSignal = message.importerSignal;
56-
57-
return;
58-
}
36+
const { workerImporterPort, importerSignal } = workerData as {
37+
workerImporterPort: MessagePort;
38+
importerSignal: Int32Array;
39+
};
5940

60-
const { id, hasImporter, options } = message;
41+
parentPort.on('message', ({ id, hasImporter, options }: RenderRequestMessage) => {
6142
try {
6243
if (hasImporter) {
6344
// When a custom importer function is present, the importer request must be proxied

0 commit comments

Comments
 (0)