File tree 1 file changed +21
-8
lines changed
packages/vite/src/node/plugins
1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,18 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
198
198
let server : ViteDevServer
199
199
const isWorker = config . isWorker
200
200
201
+ const isWorkerQueryId = ( id : string ) => {
202
+ const parsedQuery = parseRequest ( id )
203
+ if (
204
+ parsedQuery &&
205
+ ( parsedQuery . worker ?? parsedQuery . sharedworker ) != null
206
+ ) {
207
+ return true
208
+ }
209
+
210
+ return false
211
+ }
212
+
201
213
return {
202
214
name : 'vite:worker' ,
203
215
@@ -217,15 +229,16 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
217
229
} ,
218
230
219
231
load ( id ) {
220
- if ( isBuild ) {
221
- const parsedQuery = parseRequest ( id )
222
- if (
223
- parsedQuery &&
224
- ( parsedQuery . worker ?? parsedQuery . sharedworker ) != null
225
- ) {
226
- return ''
227
- }
232
+ if ( isBuild && isWorkerQueryId ( id ) ) {
233
+ return ''
234
+ }
235
+ } ,
236
+
237
+ shouldTransformCachedModule ( { id } ) {
238
+ if ( isBuild && isWorkerQueryId ( id ) && config . build . watch ) {
239
+ return true
228
240
}
241
+ return false
229
242
} ,
230
243
231
244
async transform ( raw , id , options ) {
You can’t perform that action at this time.
0 commit comments