You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Workerize options can either be defined in your Webpack configuration, or using Webpack's [syntax for inline loader options](https://webpack.js.org/concepts/loaders/#inline).
50
+
49
51
#### `inline`
50
52
51
53
Type: `Boolean`
@@ -60,11 +62,94 @@ You can also inline the worker as a BLOB with the `inline` parameter
Workerize uses the configured value of `output.publicPath` from Webpack unless specified here. The value of `publicPath` gets prepended to bundle filenames to get their full URL. It can be a path, or a full URL with host.
99
+
100
+
```js
101
+
// webpack.config.js
102
+
{
103
+
loader:'workerize-loader',
104
+
options: { publicPath:'/static/' }
105
+
}
106
+
```
107
+
108
+
#### `ready`
109
+
110
+
Type: `Boolean`
111
+
Default: `false`
112
+
113
+
If `true`, the imported "workerized" module will include a `ready` property, which is a Promise that resolves once the Worker has been loaded. Note: this is unnecessary in most cases, since worker methods can be called prior to the worker being loaded.
114
+
115
+
```js
116
+
// webpack.config.js
117
+
{
118
+
loader:'workerize-loader',
119
+
options: { ready:true }
120
+
}
121
+
```
122
+
123
+
or
124
+
125
+
```js
126
+
importworkerfrom'workerize-loader?ready!./worker'
127
+
128
+
let instance =worker() // `new` is optional
129
+
awaitinstance.ready
130
+
```
131
+
132
+
#### `import`
133
+
134
+
Type: `Boolean`
135
+
Default: `false`
136
+
137
+
When enabled, generated output will create your Workers using a Data URL that loads your code via `importScripts` (eg: `new Worker('data:,importScripts("url")')`). This workaround enables cross-origin script preloading, but Workers are created on an "opaque origin" and cannot access resources on the origin of their host page without CORS enabled. Only enable it if you understand this and specifically need the workaround.
If you're using [Babel](https://babeljs.io/) in your build, make sure you disabled commonJS transform. Otherwize, workerize-loader won't be able to retrieve the list of exported function from your worker script :
0 commit comments