Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify "worker in worker" build #123

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions examples/web-worker/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,17 @@ export function vitePluginWorkerEnvironment(): Plugin[] {
if (manager.workerScan) {
// client -> worker (scan)
manager.workerMap[entry] = {};
// import worker as is to collect worker in worker during scan
code = `
import ${JSON.stringify(entry)};
export default "noop";
`;
code = `export default "__unused"`;
} else if (this.environment.name === "worker") {
// worker -> worker (build)
if (!(entry in manager.workerMap)) {
manager.workerMap[entry] = {
referenceId: this.emitFile({
type: "chunk",
id: entry,
}),
};
}
const referenceId = manager.workerMap[entry]!.referenceId;
code = `export default import.meta.ROLLUP_FILE_URL_${referenceId}`;
} else if (this.environment.name === "client") {
Expand Down
5 changes: 5 additions & 0 deletions misc/vite-ecosystem-ci.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -eu -o pipefail

# web worker environment
pnpm -C examples/web-worker test-e2e
pnpm -C examples/web-worker build
pnpm -C examples/web-worker test-e2e-preview

# workerd environment
pnpm -C examples/react-ssr-workerd test-e2e

Expand Down