File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ import type {
14
14
} from './types' ;
15
15
16
16
export async function workerThread ( sys : System ) {
17
+ // Special case: we allow importing qwik again in the same process, it's ok because we just needed the serializer
18
+ // TODO: remove this once we have vite environment API and no longer need the serializer separately
19
+ delete ( globalThis as any ) . __qwik ;
17
20
const ssgOpts = sys . getOptions ( ) ;
18
21
const pendingPromises = new Set < Promise < any > > ( ) ;
19
22
@@ -42,6 +45,9 @@ export async function workerThread(sys: System) {
42
45
}
43
46
44
47
export async function createSingleThreadWorker ( sys : System ) {
48
+ // Special case: we allow importing qwik again in the same process, it's ok because we just needed the serializer
49
+ // TODO: remove this once we have vite environment API and no longer need the serializer separately
50
+ delete ( globalThis as any ) . __qwik ;
45
51
const ssgOpts = sys . getOptions ( ) ;
46
52
const pendingPromises = new Set < Promise < any > > ( ) ;
47
53
Original file line number Diff line number Diff line change
1
+ //////////////////////////////////////////////////////////////////////////////////////////
2
+ // Protect against duplicate imports
3
+ //////////////////////////////////////////////////////////////////////////////////////////
4
+ import { version } from './version' ;
5
+ if ( ( globalThis as any ) . __qwik ) {
6
+ console . error (
7
+ `==============================================\n` +
8
+ `Qwik version ${ ( globalThis as any ) . __qwik } already imported while importing ${ version } . Verify external vs bundled imports etc. This can lead to issues due to duplicated shared structures.\n` +
9
+ `==============================================\n`
10
+ ) ;
11
+ }
12
+ ( globalThis as any ) . __qwik = version ;
13
+
1
14
//////////////////////////////////////////////////////////////////////////////////////////
2
15
// Developer Core API
3
16
//////////////////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -271,7 +271,8 @@ async function routerApp(
271
271
appDir : string ,
272
272
) {
273
273
const ssrPath = join ( appDir , "server" , `${ qwikRouterVirtualEntry } .js` ) ;
274
-
274
+ // it's ok in the devserver to import core multiple times
275
+ ( globalThis as any ) . __qwik = null ;
275
276
const mod = await import ( file ( ssrPath ) ) ;
276
277
const router : any = mod . router ;
277
278
router ( req , res , ( ) => {
@@ -289,6 +290,8 @@ async function ssrApp(
289
290
manifest : QwikManifest ,
290
291
) {
291
292
const ssrPath = join ( appDir , "server" , "entry.ssr.js" ) ;
293
+ // it's ok in the devserver to import core multiple times
294
+ ( globalThis as any ) . __qwik = null ;
292
295
const mod = await import ( file ( ssrPath ) ) ;
293
296
const render : Render = mod . default ?? mod . render ;
294
297
You can’t perform that action at this time.
0 commit comments