Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ProtonMail/WebClients.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMargeBot <321-margebot@users.noreply.gitlab.protontech.ch>2022-09-26 17:38:33 +0300
committerRichard <richard@protonmail.com>2022-09-28 10:55:12 +0300
commita27752ba4b67de603fde16dde52b7280bb3aef97 (patch)
tree86a0b25e2cd75f34ce2a56047ee1d0ddac3bbc86
parentbb6747d50972c93556ba9bc50ba141783097f067 (diff)
Merge branch 'disable-worker-chunks' into 'main'
Disable crypto worker chunking See merge request web/clients!3460 Changelog:
-rw-r--r--packages/crypto/lib/worker/workerPool.ts5
-rw-r--r--packages/pack/webpack/optimization.js5
2 files changed, 9 insertions, 1 deletions
diff --git a/packages/crypto/lib/worker/workerPool.ts b/packages/crypto/lib/worker/workerPool.ts
index edaf4dd140..78a4788dde 100644
--- a/packages/crypto/lib/worker/workerPool.ts
+++ b/packages/crypto/lib/worker/workerPool.ts
@@ -10,6 +10,7 @@ interface WorkerPoolInterface extends CryptoApiInterface {
* @param options.poolSize - number of workers to start; defaults to `Navigator.hardwareConcurrency()` if available, otherwise to 1.
*/
init(options?: { poolSize?: number }): Promise<void>;
+
/**
* Close all workers, after clearing their internal key store.
* After the pool has been destroyed, it is possible to `init()` it again.
@@ -26,7 +27,9 @@ export const CryptoWorkerPool: WorkerPoolInterface = (() => {
// Webpack static analyser is not especially powerful at detecting web workers that require bundling,
// see: https://github.com/webpack/webpack.js.org/issues/4898#issuecomment-823073304.
// Harcoding the path here is the easiet way to get the worker to be bundled properly.
- const RemoteApi = wrap<typeof CryptoApi>(new Worker(new URL('./worker.ts', import.meta.url)));
+ const RemoteApi = wrap<typeof CryptoApi>(
+ new Worker(new URL(/* webpackChunkName: "crypto-worker" */ './worker.ts', import.meta.url))
+ );
const worker = await new RemoteApi();
return worker;
};
diff --git a/packages/pack/webpack/optimization.js b/packages/pack/webpack/optimization.js
index ec7d86312e..a8ae169bc4 100644
--- a/packages/pack/webpack/optimization.js
+++ b/packages/pack/webpack/optimization.js
@@ -32,4 +32,9 @@ module.exports = ({ isProduction }) => ({
}),
new CssMinimizerPlugin(),
],
+ splitChunks: {
+ chunks(chunk) {
+ return chunk.name !== 'crypto-worker';
+ },
+ },
});