Skip to content

Commit

Permalink
fix(worker): fix workerRemote handler
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Nov 11, 2024
1 parent 80947d9 commit 229967d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions examples/basic/app2/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type App3 from '@example/app3/src/bootstrap';
import App from './App';

console.log('testValue in main thread', testValue);
const worker = new SharedWorker(new URL('./worker', import.meta.url), {
name: getWorkerName('app2'),
});
// const worker = new SharedWorker(new URL('./worker', import.meta.url), {
// name: getWorkerName('app2'),
// });

(window as any)._log2 = useLogger({
name: 'app2',
Expand Down
7 changes: 4 additions & 3 deletions packages/builder/src/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export const makeRemoteScript = (
}
// TODO: support custom worker remote
const url = new URL(remoteEntry);
const pathname = url.pathname.split('/');
pathname.splice(-1, 0, 'worker');
// replace the default remote with the worker remote
// e.g. http://localhost:3000/remoteEntry.js -> http://localhost:3000/worker/remoteEntry.js
const workerRemote = `${url.origin}${pathname.join('/')}`;
const workerRemote = remoteEntry.replace(
url.pathname,
`/worker${url.pathname}`
);
importScripts(workerRemote);
}
const toBeResolved = () => {
Expand Down

0 comments on commit 229967d

Please sign in to comment.