@@ -2,30 +2,66 @@ import webpack = require("webpack");
22
33export = WorkerPlugin ;
44
5- declare class WorkerPlugin extends webpack . Plugin {
5+ declare class WorkerPlugin implements webpack . WebpackPluginInstance {
66 constructor ( options ?: WorkerPlugin . Options ) ;
7+ apply ( compiler : webpack . Compiler ) : void ;
78}
89
910declare namespace WorkerPlugin {
1011 interface Options {
12+ /**
13+ * Controls the name of the generated worker chunk.
14+ * The name is used to generate a URL according to `output.chunkFilename`.
15+ */
1116 filename ?: string | undefined ;
17+
18+ /**
19+ * Controls the chunk filename of secondary chunks generated by the worker bundle.
20+ * Defaults to the parent compiler's `output.chunkFilename`.
21+ */
1222 chunkFilename ?: string | undefined ;
23+
24+ /**
25+ * Configures the value of `output.globalObject` for WorkerPlugin's internal Webpack compiler.
26+ * Set to `false` to disable the warning when `output.globalObject` is set to `"window"`.
27+ * Defaults to `"self"`, which is required for HMR to work correctly in workers.
28+ */
1329 globalObject ?: false | string | undefined ;
14- plugins ?: Array < string | webpack . Plugin > | undefined ;
30+
1531 /**
16- * If set to `true`, this option enables the bundling of [SharedWorker](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker)
32+ * List of Webpack plugins to apply to the worker's child compiler.
33+ * By default, no plugins from the parent compiler are applied to avoid running things
34+ * like `html-webpack-plugin` twice. Pass a plugin name string to copy it from the
35+ * parent compiler's configuration, or pass a plugin instance to apply it only to worker code.
36+ */
37+ plugins ?: Array < string | webpack . WebpackPluginInstance > | undefined ;
38+
39+ /**
40+ * If set to `true`, enables bundling of
41+ * [`SharedWorker`](https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker).
42+ * @default false
1743 */
1844 sharedWorker ?: boolean | undefined ;
45+
1946 /**
20- * If set to `false`, this option disables the bundling of [Worker].
21- * Intended to be used with `{ sharedWorker: true }` to allow bundling of [SharedWorker] only without also bundling [Worker].
47+ * If set to `false`, disables bundling of `Worker`.
48+ * Intended to be used with `{ sharedWorker: true }` to bundle `SharedWorker` only.
49+ * @default true
2250 */
2351 worker ?: boolean | undefined ;
52+
53+ /**
54+ * If set to `true`, retains `{ type: 'module' }` in the bundled output instead of
55+ * removing it. By default, WorkerPlugin removes the `type` option to compile
56+ * Module Workers to Classic Workers, which are supported in all browsers.
57+ * @default false
58+ */
2459 preserveTypeModule ?: boolean | undefined ;
60+
2561 /**
26- * Normally, WorkerPlugin will transform `new Worker('./a.js', { type: 'module' })`
27- * to completely remove the `type` option, outputting something like `new Worker('a.worker.js')`.
28- * This allows the plugin to compile Module Workers to Classic Workers, which are supported in all browsers .
62+ * Override the `type` value output by WorkerPlugin in the worker constructor options.
63+ * For example, setting `workerType: 'foo'` will output `new Worker('a.worker.js', { type: 'foo' } )`.
64+ * Takes precedence over `preserveTypeModule` .
2965 */
3066 workerType ?: string | undefined ;
3167 }
0 commit comments