-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: import url worker two times (#7468)
- Loading branch information
Showing
10 changed files
with
181 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
import SubWorker from './emit-chunk-sub-worker?worker' | ||
|
||
const subWorker = new SubWorker() | ||
|
||
subWorker.onmessage = (event) => { | ||
self.postMessage(event.data) | ||
self.postMessage({ | ||
type: 'emit-chunk-sub-worker', | ||
data: event.data | ||
}) | ||
} | ||
|
||
const moduleWorker = new Worker( | ||
new URL('./module-and-worker.js', import.meta.url), | ||
{ type: 'module' } | ||
) | ||
|
||
moduleWorker.onmessage = (event) => { | ||
self.postMessage({ | ||
type: 'module-and-worker:worker', | ||
data: event.data | ||
}) | ||
} | ||
|
||
import('./module-and-worker').then((res) => { | ||
self.postMessage({ | ||
type: 'module-and-worker:module', | ||
data: res.module | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Promise.all([import('./modules/module2'), import('./modules/module3')]).then( | ||
(data) => { | ||
const _data = { ...data[0], ...data[1] } | ||
self.postMessage(_data) | ||
} | ||
) | ||
Promise.all([ | ||
import('./module-and-worker'), | ||
import('./modules/module2'), | ||
import('./modules/module3') | ||
]).then((data) => { | ||
const _data = { ...data[0], ...data[1], ...data[2] } | ||
self.postMessage(_data) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import constant from './modules/module' | ||
|
||
self.postMessage(constant) | ||
|
||
export const module = 'module and worker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, the code here is redundant~