@@ -5,6 +5,15 @@ import type { ReplInputOptions } from '../types';
5
5
import { depResponse } from './repl-dependencies' ;
6
6
import type { QwikWorkerGlobal } from './repl-service-worker' ;
7
7
8
+ /**
9
+ * Use paths that look like the paths ones from node modules. The plugin uses the paths to recognize
10
+ * the Qwik packages.
11
+ */
12
+ const corePath = '/@qwik.dev/core/dist/core.mjs' ;
13
+ const handlersPath = '/@qwik.dev/core/handlers.mjs' ;
14
+ const serverPath = '/@qwik.dev/core/dist/server.mjs' ;
15
+ const preloaderPath = '/@qwik.dev/core/dist/preloader.mjs' ;
16
+
8
17
export const replResolver = ( options : ReplInputOptions , buildMode : 'client' | 'ssr' ) : Plugin => {
9
18
const srcInputs = options . srcInputs ;
10
19
const resolveId = ( id : string ) => {
@@ -23,13 +32,16 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
23
32
if ( match ) {
24
33
const pkgPath = match [ 2 ] ;
25
34
if ( pkgPath === '/server' ) {
26
- return '\0qwikServer' ;
35
+ return serverPath ;
27
36
}
28
37
if ( pkgPath === '/preloader' ) {
29
- return '\0qwikPreloader' ;
38
+ return preloaderPath ;
39
+ }
40
+ if ( pkgPath === '/handlers.mjs' ) {
41
+ return handlersPath ;
30
42
}
31
- if ( / ^ ( | \/ j s x ( - d e v ) ? - r u n t i m e | \/ i n t e r n a l | \/ h a n d l e r s . m j s ) $ / . test ( pkgPath ) ) {
32
- return '\0qwikCore' ;
43
+ if ( / ^ ( | \/ j s x ( - d e v ) ? - r u n t i m e | \/ i n t e r n a l ) $ / . test ( pkgPath ) ) {
44
+ return corePath ;
33
45
}
34
46
console . error ( `Unknown package ${ id } ` , match ) ;
35
47
}
@@ -52,14 +64,14 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
52
64
return input . code ;
53
65
}
54
66
if ( buildMode === 'ssr' ) {
55
- if ( id === '\0qwikCore' ) {
67
+ if ( id === corePath || id === handlersPath ) {
56
68
return getRuntimeBundle ( 'qwikCore' ) ;
57
69
}
58
- if ( id === '\0qwikServer' ) {
70
+ if ( id === serverPath ) {
59
71
return getRuntimeBundle ( 'qwikServer' ) ;
60
72
}
61
73
}
62
- if ( id === '\0qwikCore' ) {
74
+ if ( id === corePath ) {
63
75
if ( options . buildMode === 'production' ) {
64
76
const rsp = await depResponse ( '@qwik.dev/core' , '/core.min.mjs' ) ;
65
77
if ( rsp ) {
@@ -73,12 +85,18 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
73
85
}
74
86
throw new Error ( `Unable to load Qwik core` ) ;
75
87
}
76
- if ( id === '\0qwikPreloader' ) {
88
+ if ( id === preloaderPath ) {
77
89
const rsp = await depResponse ( '@qwik.dev/core' , '/preloader.mjs' ) ;
78
90
if ( rsp ) {
79
91
return rsp . text ( ) ;
80
92
}
81
93
}
94
+ if ( id === handlersPath ) {
95
+ const rsp = await depResponse ( '@qwik.dev/core' , '/handlers.mjs' ) ;
96
+ if ( rsp ) {
97
+ return rsp . text ( ) ;
98
+ }
99
+ }
82
100
83
101
// We're the fallback, we know all the files
84
102
if ( / \. [ j t ] s x ? $ / . test ( id ) ) {
0 commit comments