Skip to content

Commit e49bf90

Browse files
committed
fix(repl): correct finding _run and _task
1 parent ea883d7 commit e49bf90

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

packages/docs/src/repl/bundled.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import qPublicDts from '../../node_modules/@qwik.dev/core/public.d.ts?raw-source
1616
import qCoreInternalDts from '../../node_modules/@qwik.dev/core/dist/core-internal.d.ts?raw-source';
1717
import qCoreMinMjs from '../../node_modules/@qwik.dev/core/dist/core.min.mjs?raw-source';
1818
import qPreloaderMjs from '../../node_modules/@qwik.dev/core/dist/preloader.mjs?raw-source';
19+
import qHandlersMjs from '../../node_modules/@qwik.dev/core/handlers.mjs?raw-source';
1920
import qCoreMjs from '../../node_modules/@qwik.dev/core/dist/core.mjs?raw-source';
2021
import qOptimizerCjs from '../../node_modules/@qwik.dev/core/dist/optimizer.cjs?raw-source';
2122
import qServerCjs from '../../node_modules/@qwik.dev/core/dist/server.cjs?raw-source';
@@ -65,6 +66,7 @@ export const bundled: PkgUrls = {
6566
'/dist/server.cjs': qServerCjs,
6667
'/dist/server.d.ts': qServerDts,
6768
'/dist/preloader.mjs': qPreloaderMjs,
69+
'/handlers.mjs': qHandlersMjs,
6870
'/bindings/qwik.wasm.cjs': qWasmCjs,
6971
'/bindings/qwik_wasm_bg.wasm': qWasmBinUrl,
7072
},

packages/docs/src/repl/worker/repl-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const depResponse = async (pkgName: string, pkgPath: string) => {
1010
if (pkgName === QWIK_PKG_NAME) {
1111
const version = dep.version;
1212
const [M, m, p] = version.split('-')[0].split('.').map(Number);
13-
if (!pkgPath.startsWith('/bindings')) {
13+
if (!pkgPath.startsWith('/bindings') && !pkgPath.startsWith('/handlers.mjs')) {
1414
if (M > 1 || (M == 1 && (m > 7 || (m == 7 && p >= 2)))) {
1515
pkgPath = `/dist${pkgPath}`;
1616
}

packages/docs/src/repl/worker/repl-plugins.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ import type { ReplInputOptions } from '../types';
55
import { depResponse } from './repl-dependencies';
66
import type { QwikWorkerGlobal } from './repl-service-worker';
77

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+
817
export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 'ssr'): Plugin => {
918
const srcInputs = options.srcInputs;
1019
const resolveId = (id: string) => {
@@ -23,13 +32,16 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
2332
if (match) {
2433
const pkgPath = match[2];
2534
if (pkgPath === '/server') {
26-
return '\0qwikServer';
35+
return serverPath;
2736
}
2837
if (pkgPath === '/preloader') {
29-
return '\0qwikPreloader';
38+
return preloaderPath;
39+
}
40+
if (pkgPath === '/handlers.mjs') {
41+
return handlersPath;
3042
}
31-
if (/^(|\/jsx(-dev)?-runtime|\/internal|\/handlers.mjs)$/.test(pkgPath)) {
32-
return '\0qwikCore';
43+
if (/^(|\/jsx(-dev)?-runtime|\/internal)$/.test(pkgPath)) {
44+
return corePath;
3345
}
3446
console.error(`Unknown package ${id}`, match);
3547
}
@@ -52,14 +64,14 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
5264
return input.code;
5365
}
5466
if (buildMode === 'ssr') {
55-
if (id === '\0qwikCore') {
67+
if (id === corePath || id === handlersPath) {
5668
return getRuntimeBundle('qwikCore');
5769
}
58-
if (id === '\0qwikServer') {
70+
if (id === serverPath) {
5971
return getRuntimeBundle('qwikServer');
6072
}
6173
}
62-
if (id === '\0qwikCore') {
74+
if (id === corePath) {
6375
if (options.buildMode === 'production') {
6476
const rsp = await depResponse('@qwik.dev/core', '/core.min.mjs');
6577
if (rsp) {
@@ -73,12 +85,18 @@ export const replResolver = (options: ReplInputOptions, buildMode: 'client' | 's
7385
}
7486
throw new Error(`Unable to load Qwik core`);
7587
}
76-
if (id === '\0qwikPreloader') {
88+
if (id === preloaderPath) {
7789
const rsp = await depResponse('@qwik.dev/core', '/preloader.mjs');
7890
if (rsp) {
7991
return rsp.text();
8092
}
8193
}
94+
if (id === handlersPath) {
95+
const rsp = await depResponse('@qwik.dev/core', '/handlers.mjs');
96+
if (rsp) {
97+
return rsp.text();
98+
}
99+
}
82100

83101
// We're the fallback, we know all the files
84102
if (/\.[jt]sx?$/.test(id)) {

0 commit comments

Comments
 (0)