Skip to content

Commit 58ed974

Browse files
committed
fix(@angular-devkit/build-angular): allow Workers in Stackblitz
This is no longer needed as Stackblitz implemented the missing Node.Js worker APIs. (cherry picked from commit 2ab7742)
1 parent 6ef9e2a commit 58ed974

File tree

1 file changed

+8
-21
lines changed
  • packages/angular_devkit/build_angular/src/webpack/configs

1 file changed

+8
-21
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/styles.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,14 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
107107
);
108108
}
109109

110-
const sassImplementation = getSassImplementation();
111-
if (sassImplementation instanceof SassWorkerImplementation) {
112-
extraPlugins.push({
113-
apply(compiler) {
114-
compiler.hooks.shutdown.tap('sass-worker', () => {
115-
sassImplementation?.close();
116-
});
117-
},
118-
});
119-
}
110+
const sassImplementation = new SassWorkerImplementation();
111+
extraPlugins.push({
112+
apply(compiler) {
113+
compiler.hooks.shutdown.tap('sass-worker', () => {
114+
sassImplementation.close();
115+
});
116+
},
117+
});
120118

121119
const assetNameTemplate = assetNameTemplateFactory(hashFormat);
122120

@@ -403,14 +401,3 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
403401
plugins: extraPlugins,
404402
};
405403
}
406-
407-
function getSassImplementation(): SassWorkerImplementation | typeof import('sass') {
408-
const { webcontainer } = process.versions as unknown as Record<string, unknown>;
409-
410-
// When `webcontainer` is a truthy it means that we are running in a StackBlitz webcontainer.
411-
// `SassWorkerImplementation` uses `receiveMessageOnPort` Node.js `worker_thread` API to ensure sync behavior which is ~2x faster.
412-
// However, it is non trivial to support this in a webcontainer and while slower we choose to use `dart-sass`
413-
// which in Webpack uses the slower async path.
414-
// We should periodically check with StackBlitz folks (Mark Whitfeld / Dominic Elm) to determine if this workaround is still needed.
415-
return webcontainer ? require('sass') : new SassWorkerImplementation();
416-
}

0 commit comments

Comments
 (0)