Skip to content

Commit 508cead

Browse files
committed
[README] Updated.
1 parent 5c1c14a commit 508cead

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# rollup-plugin-web-worker-loader
22

3-
Rollup plugin to bundle web worker code to later be instantiated as a Worker.
3+
Rollup plugin to handle Web Workers.
44

5-
Preserves the code so other plugins can modify it and/or transpile it.
6-
Can be
7-
configured to inline a sourcemap.
5+
Can inline the worker code or emit a script file using code-split.
6+
Handles Worker dependencies and can emit source maps.
7+
Worker dependencies are added to Rollup's watch list.
88

99
### Getting started
1010

@@ -20,7 +20,7 @@ import webWorkerLoader from 'rollup-plugin-web-worker-loader';
2020
export default {
2121
entry: 'src/index.js',
2222
plugins: [
23-
webWorkerLoader(),
23+
webWorkerLoader(/* configuration */),
2424
],
2525
format: 'esm',
2626
};
@@ -39,14 +39,25 @@ dataWorker.postMessage('Hello World!');
3939
The plugin responds to the following configuration options:
4040
```javascript
4141
webWorkerLoader({
42-
sourcemap: boolean, // should a source map be included in the final output
42+
sourcemap?: boolean, // when inlined, should a source map be included in the final output. Default: false
43+
inline?: boolean, // should the worker code be inlined (Base64). Default: true
44+
loadPath?: string // this options is useful when the worker scripts need to be loaded from another folder. Default: ''
4345
})
4446
```
4547

48+
### Notes
49+
WARNING: To use code-splitting for the worker scripts, Rollup v1.9.2 or higher is required. See https://github.com/rollup/rollup/issues/2801 for more details.
50+
51+
The `sourcemap` configuration option is ignored when `inline` is set to `false`, in that case the project's sourcemap configuration is inherited.
52+
53+
`loadPath` is meant to be used in situations where code-splitting is used (`inline = false`) and the entry script is hosted in a different folder than the worker code.
54+
55+
4656
### Roadmap
4757
- [x] Bundle file as web worker blob
4858
- [x] Support for dependencies using `import`
4959
- [x] Include source map
60+
- [x] Configuration options to inline or code-split workers
5061
- [ ] Provide capability checks and fallbacks
5162
- [ ] Avoid code duplication
5263

0 commit comments

Comments
 (0)