fix: startup error

This commit is contained in:
hugo committed 2026-02-23 12:51:27 +01:00
1 parent 7213b6b78d
commit 77ddacd52a
3 files changed
+16 -4

No files matched your search

+7 -1
View File
@@ -1,3 +1,9 @@
export function resolvePyodideIndexURL(workerModuleUrl: string): string {
export function resolvePyodideIndexURL(workerModuleUrl: string): string | undefined {
const parsed = new URL(workerModuleUrl);
if (parsed.protocol !== 'file:') {
return undefined;
}
return new URL('../../../node_modules/pyodide/', workerModuleUrl).toString();
}
+2 -1
View File
@@ -183,8 +183,9 @@ json.dumps(__bds_entrypoints)
async function bootstrapRuntime(): Promise<void> {
try {
const indexURL = resolvePyodideIndexURL(import.meta.url);
runtime = await loadPyodide({
indexURL: resolvePyodideIndexURL(import.meta.url),
...(indexURL ? { indexURL } : {}),
stdout: (chunk) => {
if (!activeRequestId) {
return;
@@ -9,8 +9,13 @@ describe('resolvePyodideIndexURL', () => {
);
});
it('resolves to vite node_modules path for dev worker urls', () => {
it('returns undefined for dev worker urls to let pyodide use module-relative defaults', () => {
const workerUrl = 'http://localhost:5173/src/renderer/python/pythonRuntime.worker.ts';
expect(resolvePyodideIndexURL(workerUrl)).toBe('http://localhost:5173/node_modules/pyodide/');
expect(resolvePyodideIndexURL(workerUrl)).toBeUndefined();
});
it('returns undefined for vite worker_file urls with query parameters', () => {
const workerUrl = 'http://localhost:5173/python/pythonRuntime.worker.ts?worker_file&type=module';
expect(resolvePyodideIndexURL(workerUrl)).toBeUndefined();
});
});