From 89dccf70bc8a9163b0e6e733879926c3f8383a87 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 11:40:11 +0900 Subject: [PATCH 01/11] chore(deps): vite d002e7d (better resolve.conditions) --- package.json | 2 +- pnpm-lock.yaml | 79 +++++++++++++++++++++++++------------------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index f310cd5e..4bdf9b64 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "tsup": "^8.1.2", "tsx": "^4.16.2", "typescript": "^5.5.3", - "vite": "https://pkg.pr.new/vite@ddd5c5d", + "vite": "https://pkg.pr.new/vite@d002e7d", "vitest": "^2.0.3", "wrangler": "^3.79.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a93eb85..1c4e7e7d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,7 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d importers: @@ -22,7 +22,7 @@ importers: version: 0.0.2 '@hiogawa/vite-plugin-ssr-middleware': specifier: ^0.0.3 - version: 0.0.3(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + version: 0.0.3(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) '@playwright/test': specifier: ^1.45.2 version: 1.45.2 @@ -40,7 +40,7 @@ importers: version: 18.3.0 '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + version: 4.3.1(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) esbuild: specifier: ^0.23.0 version: 0.23.0 @@ -69,8 +69,8 @@ importers: specifier: ^5.5.3 version: 5.5.3 vite: - specifier: https://pkg.pr.new/vite@ddd5c5d - version: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + specifier: https://pkg.pr.new/vite@d002e7d + version: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) vitest: specifier: ^2.0.3 version: 2.0.3(@types/node@20.14.11)(happy-dom@14.12.3)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) @@ -105,7 +105,7 @@ importers: version: 0.30.10 unocss: specifier: 0.61.5 - version: 0.61.5(postcss@8.4.47)(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + version: 0.61.5(postcss@8.4.47)(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) examples/react-ssr: devDependencies: @@ -139,7 +139,7 @@ importers: version: link:../../packages/workerd '@vitejs/plugin-vue': specifier: ^5.0.5 - version: 5.0.5(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3)) + version: 5.0.5(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3)) vue-tsc: specifier: ^2.0.26 version: 2.0.26(typescript@5.5.3) @@ -164,7 +164,7 @@ importers: version: link:../../packages/workerd '@vitejs/plugin-vue': specifier: ^5.0.5 - version: 5.0.5(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3)) + version: 5.0.5(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3)) vue-tsc: specifier: ^2.0.26 version: 2.0.26(typescript@5.5.3) @@ -186,8 +186,8 @@ importers: packages/ssr-middleware: dependencies: vite: - specifier: https://pkg.pr.new/vite@ddd5c5d - version: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + specifier: https://pkg.pr.new/vite@d002e7d + version: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) packages/workerd: devDependencies: @@ -198,8 +198,8 @@ importers: specifier: ^3.20240925.0 version: 3.20240925.0 vite: - specifier: https://pkg.pr.new/vite@ddd5c5d - version: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + specifier: https://pkg.pr.new/vite@d002e7d + version: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) wrangler: specifier: ^3.79.0 version: 3.79.0(@cloudflare/workers-types@4.20240925.0) @@ -1060,7 +1060,7 @@ packages: resolution: {integrity: sha512-84bzaAuImty4s4vHjOk5MQMzmDs0W0GP43fOTFhsBfj/MSJCNJ68elmPNZWs57WkIEzcdB4haY/P8Nf4ZGH8Qw==} version: 0.0.3 peerDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d '@iconify/types@2.0.0': resolution: {integrity: sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==} @@ -1347,7 +1347,7 @@ packages: resolution: {integrity: sha512-keyh6/EsPMBEiLguaOsh47UcMkWCGT0rW3KV5aYRUfYXlgccSzDd4SLmTNsdlGXIso2XCl/14BJQuwjP0UEU0Q==} version: 0.61.5 peerDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d peerDependenciesMeta: vite: optional: true @@ -1429,21 +1429,21 @@ packages: resolution: {integrity: sha512-+U5Ey5Z2csjLy7zcaDCtUqs08+ugRK87UWGm65W8yMAGW7me72f36QR8IHJUTqlVVEdhbJVIAy+yNFjGHYffjA==} version: 0.61.5 peerDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d '@vitejs/plugin-react@4.3.1': resolution: {integrity: sha512-m/V2syj5CuVnaxcUJOQRel/Wr31FFXRFlnOoq1TVtkCxsY5veGMTEmpWHndrhB2U8ScHtCQB1e+4hWYExQc6Lg==} version: 4.3.1 engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d '@vitejs/plugin-vue@5.0.5': resolution: {integrity: sha512-LOjm7XeIimLBZyzinBQ6OSm3UBCNVCpLkxGC0oWmm2YPzVZoxMsdvNVimLTBzpAnR9hl/yn1SHGuRfe6/Td9rQ==} version: 5.0.5 engines: {node: ^18.0.0 || >=20.0.0} peerDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d vue: ^3.2.25 '@vitest/expect@2.0.3': @@ -2673,7 +2673,7 @@ packages: engines: {node: '>=14'} peerDependencies: '@unocss/webpack': 0.61.5 - vite: https://pkg.pr.new/vite@ddd5c5d + vite: https://pkg.pr.new/vite@d002e7d peerDependenciesMeta: '@unocss/webpack': optional: true @@ -2694,9 +2694,9 @@ packages: engines: {node: ^18.0.0 || >=20.0.0} hasBin: true - vite@https://pkg.pr.new/vite@ddd5c5d: - resolution: {tarball: https://pkg.pr.new/vite@ddd5c5d} - version: 6.0.0-beta.6 + vite@https://pkg.pr.new/vite@d002e7d: + resolution: {tarball: https://pkg.pr.new/vite@d002e7d} + version: 6.0.0-beta.7 engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -3503,9 +3503,9 @@ snapshots: '@hiogawa/utils@1.7.0': {} - '@hiogawa/vite-plugin-ssr-middleware@0.0.3(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': + '@hiogawa/vite-plugin-ssr-middleware@0.0.3(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': dependencies: - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) '@iconify/types@2.0.0': {} @@ -3752,13 +3752,13 @@ snapshots: dependencies: '@types/node': 20.14.11 - '@unocss/astro@0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': + '@unocss/astro@0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': dependencies: '@unocss/core': 0.61.5 '@unocss/reset': 0.61.5 - '@unocss/vite': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + '@unocss/vite': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) optionalDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) transitivePeerDependencies: - rollup @@ -3889,7 +3889,7 @@ snapshots: dependencies: '@unocss/core': 0.61.5 - '@unocss/vite@0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': + '@unocss/vite@0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': dependencies: '@ampproject/remapping': 2.3.0 '@rollup/pluginutils': 5.1.0(rollup@4.23.0) @@ -3901,24 +3901,24 @@ snapshots: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.10 - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) transitivePeerDependencies: - rollup - '@vitejs/plugin-react@4.3.1(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': + '@vitejs/plugin-react@4.3.1(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))': dependencies: '@babel/core': 7.24.9 '@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.24.9) '@babel/plugin-transform-react-jsx-source': 7.24.7(@babel/core@7.24.9) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue@5.0.5(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3))': + '@vitejs/plugin-vue@5.0.5(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2))(vue@3.4.32(typescript@5.5.3))': dependencies: - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) vue: 3.4.32(typescript@5.5.3) '@vitest/expect@2.0.3': @@ -5216,9 +5216,9 @@ snapshots: pathe: 1.1.2 ufo: 1.5.4 - unocss@0.61.5(postcss@8.4.47)(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)): + unocss@0.61.5(postcss@8.4.47)(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)): dependencies: - '@unocss/astro': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + '@unocss/astro': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) '@unocss/cli': 0.61.5(rollup@4.23.0) '@unocss/core': 0.61.5 '@unocss/extractor-arbitrary-variants': 0.61.5 @@ -5237,9 +5237,9 @@ snapshots: '@unocss/transformer-compile-class': 0.61.5 '@unocss/transformer-directives': 0.61.5 '@unocss/transformer-variant-group': 0.61.5 - '@unocss/vite': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) + '@unocss/vite': 0.61.5(rollup@4.23.0)(vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2)) optionalDependencies: - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) transitivePeerDependencies: - postcss - rollup @@ -5261,7 +5261,7 @@ snapshots: debug: 4.3.5 pathe: 1.1.2 tinyrainbow: 1.2.0 - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) transitivePeerDependencies: - '@types/node' - jiti @@ -5276,14 +5276,13 @@ snapshots: - tsx - yaml - vite@https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2): + vite@https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2): dependencies: esbuild: 0.24.0 postcss: 8.4.47 rollup: 4.23.0 optionalDependencies: '@types/node': 20.14.11 - fsevents: 2.3.3 jiti: 1.21.6 terser: 5.31.3 tsx: 4.16.2 @@ -5306,7 +5305,7 @@ snapshots: tinybench: 2.8.0 tinypool: 1.0.0 tinyrainbow: 1.2.0 - vite: https://pkg.pr.new/vite@ddd5c5d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) + vite: https://pkg.pr.new/vite@d002e7d(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) vite-node: 2.0.3(@types/node@20.14.11)(jiti@1.21.6)(terser@5.31.3)(tsx@4.16.2) why-is-node-running: 2.3.0 optionalDependencies: From 55beb61a668d5f3a118e701a3d21bf4f6c7ed2b4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 11:43:44 +0900 Subject: [PATCH 02/11] wip: remove webCompatible --- examples/browser-cli/src/cli.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/browser-cli/src/cli.ts b/examples/browser-cli/src/cli.ts index 6f21188b..4d27f979 100644 --- a/examples/browser-cli/src/cli.ts +++ b/examples/browser-cli/src/cli.ts @@ -26,13 +26,9 @@ async function main() { }, environments: { custom: { - webCompatible: true, resolve: { noExternal: true, }, - optimizeDeps: { - exclude: ["vite/module-runner"], - }, }, }, server: { From 72c5927890ab999b23991dee0066a7acc11178fd Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 11:47:22 +0900 Subject: [PATCH 03/11] wip: remove more --- examples/react-ssr-workerd/vite.config.ts | 1 - examples/react-ssr/vite.config.workerd.ts | 1 - examples/vue-ssr-extra/vite.config.ts | 6 ------ examples/vue-ssr/vite.config.workerd.ts | 1 - examples/web-worker-rsc/vite.config.ts | 1 - examples/web-worker/vite.config.ts | 6 ------ 6 files changed, 16 deletions(-) diff --git a/examples/react-ssr-workerd/vite.config.ts b/examples/react-ssr-workerd/vite.config.ts index cf9f2db6..4a30808f 100644 --- a/examples/react-ssr-workerd/vite.config.ts +++ b/examples/react-ssr-workerd/vite.config.ts @@ -41,7 +41,6 @@ export default defineConfig((_env) => ({ }, }, workerd: { - webCompatible: true, resolve: { noExternal: true, }, diff --git a/examples/react-ssr/vite.config.workerd.ts b/examples/react-ssr/vite.config.workerd.ts index ebf8f948..96bd4385 100644 --- a/examples/react-ssr/vite.config.workerd.ts +++ b/examples/react-ssr/vite.config.workerd.ts @@ -19,7 +19,6 @@ export default defineConfig((_env) => ({ ], environments: { workerd: { - webCompatible: true, resolve: { noExternal: true, }, diff --git a/examples/vue-ssr-extra/vite.config.ts b/examples/vue-ssr-extra/vite.config.ts index 739f19ab..ee9ba8e8 100644 --- a/examples/vue-ssr-extra/vite.config.ts +++ b/examples/vue-ssr-extra/vite.config.ts @@ -37,15 +37,9 @@ export default defineConfig((_env) => ({ }, }, workerd: { - webCompatible: true, resolve: { noExternal: true, }, - optimizeDeps: { - // prevent flaky outdated deps error - noDiscovery: true, - include: [], - }, build: { outDir: "dist/server", }, diff --git a/examples/vue-ssr/vite.config.workerd.ts b/examples/vue-ssr/vite.config.workerd.ts index 43d06400..6e1f6024 100644 --- a/examples/vue-ssr/vite.config.workerd.ts +++ b/examples/vue-ssr/vite.config.workerd.ts @@ -20,7 +20,6 @@ export default defineConfig((_env) => ({ ], environments: { workerd: { - webCompatible: true, resolve: { noExternal: true, }, diff --git a/examples/web-worker-rsc/vite.config.ts b/examples/web-worker-rsc/vite.config.ts index db601fd6..3c9e02e1 100644 --- a/examples/web-worker-rsc/vite.config.ts +++ b/examples/web-worker-rsc/vite.config.ts @@ -17,7 +17,6 @@ export default defineConfig((_env) => ({ }, }, worker: { - webCompatible: true, resolve: { conditions: ["react-server"], noExternal: true, diff --git a/examples/web-worker/vite.config.ts b/examples/web-worker/vite.config.ts index a80430a1..970b0d89 100644 --- a/examples/web-worker/vite.config.ts +++ b/examples/web-worker/vite.config.ts @@ -23,7 +23,6 @@ export default defineConfig((_env) => ({ }, }, worker: { - webCompatible: true, resolve: { conditions: ["worker"], noExternal: true, @@ -46,11 +45,6 @@ export default defineConfig((_env) => ({ // emit actual worker entries during `buildStart` _noop: "data:text/javascript,console.log()", }, - output: { - // force false since vite enables it when `consumer: "server"` and `webCompatible: true` - // https://github.com/vitejs/vite/blob/95020ab49e12d143262859e095025cf02423c1d9/packages/vite/src/node/build.ts#L761-L766 - inlineDynamicImports: false, - }, }, }, }, From d44b1f9ae11ad431bd3dcf906fa7f3cb14552e90 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 11:59:41 +0900 Subject: [PATCH 04/11] fix: fix `node:module` banner --- packages/workerd/src/plugin.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/workerd/src/plugin.ts b/packages/workerd/src/plugin.ts index 5c5542b5..2ef05493 100644 --- a/packages/workerd/src/plugin.ts +++ b/packages/workerd/src/plugin.ts @@ -37,6 +37,13 @@ export function vitePluginWorkerd(pluginOptions: WorkerdPluginOptions): Plugin { return { environments: { workerd: { + optimizeDeps: { + // prevent `import { createRequire } from "node:module"` + esbuildOptions: { + platform: "browser", + banner: undefined, + }, + }, dev: { createEnvironment: (name, config) => createWorkerdDevEnvironment(name, config, pluginOptions), From 429c432c9c0b7232664668acb17cec4cff2ef9c5 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 12:07:42 +0900 Subject: [PATCH 05/11] fix: fix more banner --- examples/browser-cli/vite.config.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/browser-cli/vite.config.ts b/examples/browser-cli/vite.config.ts index 1a7cc785..39b32801 100644 --- a/examples/browser-cli/vite.config.ts +++ b/examples/browser-cli/vite.config.ts @@ -12,6 +12,10 @@ export default defineConfig((_env) => ({ "react-dom", "react-dom/client", ], + esbuildOptions: { + platform: "browser", + banner: undefined, + }, }, }, }, From 9756f1f12c4efa916425a0d954e3b3e60b2e6b27 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 12:08:40 +0900 Subject: [PATCH 06/11] chore: module or not? --- examples/child-process/vite.config.ts | 1 + examples/react-server/vite.config.ts | 2 +- examples/web-worker-rsc/vite.config.ts | 2 +- examples/web-worker/vite.config.ts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/child-process/vite.config.ts b/examples/child-process/vite.config.ts index 3501fb2e..58f9c6fc 100644 --- a/examples/child-process/vite.config.ts +++ b/examples/child-process/vite.config.ts @@ -32,6 +32,7 @@ export default defineConfig((_env) => ({ environments: { rsc: { resolve: { + conditions: ["module", "react-server"], externalConditions: ["react-server"], }, dev: { diff --git a/examples/react-server/vite.config.ts b/examples/react-server/vite.config.ts index cb90f7ed..8b9ac1ef 100644 --- a/examples/react-server/vite.config.ts +++ b/examples/react-server/vite.config.ts @@ -127,7 +127,7 @@ function vitePluginReactServer(): PluginOption { tinyassert(config.environments); config.environments["rsc"] = { resolve: { - conditions: ["react-server"], + conditions: ["module", "react-server"], noExternal: true, }, optimizeDeps: { diff --git a/examples/web-worker-rsc/vite.config.ts b/examples/web-worker-rsc/vite.config.ts index 3c9e02e1..4a356e35 100644 --- a/examples/web-worker-rsc/vite.config.ts +++ b/examples/web-worker-rsc/vite.config.ts @@ -18,7 +18,7 @@ export default defineConfig((_env) => ({ }, worker: { resolve: { - conditions: ["react-server"], + conditions: ["module", "react-server"], noExternal: true, }, optimizeDeps: { diff --git a/examples/web-worker/vite.config.ts b/examples/web-worker/vite.config.ts index 970b0d89..8a75c49a 100644 --- a/examples/web-worker/vite.config.ts +++ b/examples/web-worker/vite.config.ts @@ -24,7 +24,7 @@ export default defineConfig((_env) => ({ }, worker: { resolve: { - conditions: ["worker"], + conditions: ["module", "worker"], noExternal: true, }, optimizeDeps: { From 9a0ce88c2d0f68f76cf48b4546469c7a264854e2 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 12:12:34 +0900 Subject: [PATCH 07/11] fix: more banner fix --- examples/web-worker-rsc/vite.config.ts | 4 ++++ examples/web-worker/vite.config.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/examples/web-worker-rsc/vite.config.ts b/examples/web-worker-rsc/vite.config.ts index 4a356e35..54a8d80b 100644 --- a/examples/web-worker-rsc/vite.config.ts +++ b/examples/web-worker-rsc/vite.config.ts @@ -28,6 +28,10 @@ export default defineConfig((_env) => ({ "react/jsx-dev-runtime", "react-server-dom-webpack/server", ], + esbuildOptions: { + platform: "browser", + banner: undefined, + }, }, }, }, diff --git a/examples/web-worker/vite.config.ts b/examples/web-worker/vite.config.ts index 8a75c49a..a7212c3f 100644 --- a/examples/web-worker/vite.config.ts +++ b/examples/web-worker/vite.config.ts @@ -34,6 +34,10 @@ export default defineConfig((_env) => ({ "react/jsx-dev-runtime", "react-dom/server", ], + esbuildOptions: { + platform: "browser", + banner: undefined, + }, }, build: { assetsDir: "_worker", From ed0f59dd63094a1cc8c034dedc8ed4ef6ff87e0c Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 12:17:42 +0900 Subject: [PATCH 08/11] fix: keepProcessEnv --- examples/web-worker-rsc/vite.config.ts | 1 + examples/web-worker/vite.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/web-worker-rsc/vite.config.ts b/examples/web-worker-rsc/vite.config.ts index 54a8d80b..a5d58d56 100644 --- a/examples/web-worker-rsc/vite.config.ts +++ b/examples/web-worker-rsc/vite.config.ts @@ -17,6 +17,7 @@ export default defineConfig((_env) => ({ }, }, worker: { + keepProcessEnv: false, resolve: { conditions: ["module", "react-server"], noExternal: true, diff --git a/examples/web-worker/vite.config.ts b/examples/web-worker/vite.config.ts index a7212c3f..650828c1 100644 --- a/examples/web-worker/vite.config.ts +++ b/examples/web-worker/vite.config.ts @@ -23,6 +23,7 @@ export default defineConfig((_env) => ({ }, }, worker: { + keepProcessEnv: false, resolve: { conditions: ["module", "worker"], noExternal: true, From 97df938fcf160c93e93f4e02635442bc07d81713 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 13:02:46 +0900 Subject: [PATCH 09/11] fix: browser condition for react-server-dom-webpack/server --- examples/web-worker-rsc/vite.config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/web-worker-rsc/vite.config.ts b/examples/web-worker-rsc/vite.config.ts index a5d58d56..843f51c4 100644 --- a/examples/web-worker-rsc/vite.config.ts +++ b/examples/web-worker-rsc/vite.config.ts @@ -19,7 +19,8 @@ export default defineConfig((_env) => ({ worker: { keepProcessEnv: false, resolve: { - conditions: ["module", "react-server"], + // need "browser" condition for "react-server-dom-webpack/server" + conditions: ["module", "worker", "browser", "react-server"], noExternal: true, }, optimizeDeps: { From 79519f555087c858924366c37eaca2aafc75954a Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 13:32:08 +0900 Subject: [PATCH 10/11] chore: more conditions module --- examples/vue-ssr-extra/vite.config.ts | 1 + examples/vue-ssr/vite.config.workerd.ts | 1 + packages/workerd/src/plugin.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/examples/vue-ssr-extra/vite.config.ts b/examples/vue-ssr-extra/vite.config.ts index ee9ba8e8..baa39bee 100644 --- a/examples/vue-ssr-extra/vite.config.ts +++ b/examples/vue-ssr-extra/vite.config.ts @@ -39,6 +39,7 @@ export default defineConfig((_env) => ({ workerd: { resolve: { noExternal: true, + conditions: ["module"], }, build: { outDir: "dist/server", diff --git a/examples/vue-ssr/vite.config.workerd.ts b/examples/vue-ssr/vite.config.workerd.ts index 6e1f6024..59e1ec9e 100644 --- a/examples/vue-ssr/vite.config.workerd.ts +++ b/examples/vue-ssr/vite.config.workerd.ts @@ -21,6 +21,7 @@ export default defineConfig((_env) => ({ environments: { workerd: { resolve: { + conditions: ["module"], noExternal: true, }, }, diff --git a/packages/workerd/src/plugin.ts b/packages/workerd/src/plugin.ts index 2ef05493..d2c7451e 100644 --- a/packages/workerd/src/plugin.ts +++ b/packages/workerd/src/plugin.ts @@ -37,6 +37,7 @@ export function vitePluginWorkerd(pluginOptions: WorkerdPluginOptions): Plugin { return { environments: { workerd: { + keepProcessEnv: false, optimizeDeps: { // prevent `import { createRequire } from "node:module"` esbuildOptions: { From b3ecdb9fd55f907aad09947f8c74495b04becf1d Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 1 Nov 2024 13:46:33 +0900 Subject: [PATCH 11/11] fix: fix vue-ssr-extra build --- examples/vue-ssr-extra/vite.config.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/vue-ssr-extra/vite.config.ts b/examples/vue-ssr-extra/vite.config.ts index baa39bee..b1edb0a0 100644 --- a/examples/vue-ssr-extra/vite.config.ts +++ b/examples/vue-ssr-extra/vite.config.ts @@ -39,10 +39,16 @@ export default defineConfig((_env) => ({ workerd: { resolve: { noExternal: true, - conditions: ["module"], + conditions: ["module", "browser", "production/development"], }, build: { outDir: "dist/server", + rollupOptions: { + output: { + // TODO: broken without this. probably my app setup issue. + inlineDynamicImports: true, + }, + }, }, }, },