File tree 1 file changed +3
-9
lines changed
packages/vite/src/node/plugins
1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -76,13 +76,14 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
76
76
name : 'vite:worker-import-meta-url' ,
77
77
78
78
async transform ( code , id , options ) {
79
- const query = parseRequest ( id )
80
- let s : MagicString | undefined
81
79
if (
80
+ ! options ?. ssr &&
82
81
( code . includes ( 'new Worker' ) || code . includes ( 'new SharedWorker' ) ) &&
83
82
code . includes ( 'new URL' ) &&
84
83
code . includes ( `import.meta.url` )
85
84
) {
85
+ const query = parseRequest ( id )
86
+ let s : MagicString | undefined
86
87
const cleanString = stripLiteral ( code )
87
88
const workerImportMetaUrlRE =
88
89
/ \b n e w \s + ( W o r k e r | S h a r e d W o r k e r ) \s * \( \s * ( n e w \s + U R L \s * \( \s * ( ' [ ^ ' ] + ' | " [ ^ " ] + " | ` [ ^ ` ] + ` ) \s * , \s * i m p o r t \. m e t a \. u r l \s * \) ) / g
@@ -96,13 +97,6 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
96
97
const urlEnd = urlStart + emptyUrl . length
97
98
const rawUrl = code . slice ( urlStart , urlEnd )
98
99
99
- if ( options ?. ssr ) {
100
- this . error (
101
- `\`new URL(url, import.meta.url)\` is not supported in SSR.` ,
102
- urlIndex
103
- )
104
- }
105
-
106
100
// potential dynamic template string
107
101
if ( rawUrl [ 0 ] === '`' && / \$ \{ / . test ( rawUrl ) ) {
108
102
this . error (
You can’t perform that action at this time.
0 commit comments