Skip to content

Commit

Permalink
chore: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Sep 30, 2024
1 parent c5ebad2 commit 0527e78
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions examples/web-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,38 @@ import workerUrl from "./worker.ts?worker-env";
const worker = new Worker(workerUrl, { type: "module" });
```

## during dev
__during dev__

```ts
// /path-to/worker.ts?worker-env
//// transform of /path-to/worker.ts?worker-env
export default "/path-to/worker.ts?worker-env-file";
```

```ts
// /path-to/worker.ts?worker-env-file
//// transform of /path-to/worker.ts?worker-env-file
import { createFetchRunner } from "/src/lib/runner";
const runner = createFetchRunner({ root: "...", environmentName: "worker" });
runner.import("/path-to/worker.ts");
```

## during build
__during build__

TODO
App build goes through following steps:

- 1st client build: discover `./worker.ts?worker-env` imports,
- worker build: `emitFile({ type: "chunk", id: "/path-to/worker.ts" })` for collected `?worker-env` imports,
- 2nd client build: transform `./worker.ts?worker-env` using worker build chunks,

```ts
//// transform of /path-to/worker.ts?worker-env
export default "/path-to-emitted-chunk/worker-xxyyzzww.js";
```

## tbd

- need parallel client/worker build to avoid extra client build for discovering worker references
- only esm supports multi worker entries
- resolve conditions bug https://github.com/vitejs/vite/issues/18222

## related

Expand Down

0 comments on commit 0527e78

Please sign in to comment.