Skip to content

Commit

Permalink
chore(deps): vite d002e7d (resolve.conditions rework) (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Nov 1, 2024
1 parent 6103be8 commit feaa3d2
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 64 deletions.
4 changes: 0 additions & 4 deletions examples/browser-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ async function main() {
},
environments: {
custom: {
webCompatible: true,
resolve: {
noExternal: true,
},
optimizeDeps: {
exclude: ["vite/module-runner"],
},
},
},
server: {
Expand Down
4 changes: 4 additions & 0 deletions examples/browser-cli/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default defineConfig((_env) => ({
"react-dom",
"react-dom/client",
],
esbuildOptions: {
platform: "browser",
banner: undefined,
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions examples/child-process/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default defineConfig((_env) => ({
environments: {
rsc: {
resolve: {
conditions: ["module", "react-server"],
externalConditions: ["react-server"],
},
dev: {
Expand Down
2 changes: 1 addition & 1 deletion examples/react-server/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function vitePluginReactServer(): PluginOption {
tinyassert(config.environments);
config.environments["rsc"] = {
resolve: {
conditions: ["react-server"],
conditions: ["module", "react-server"],
noExternal: true,
},
optimizeDeps: {
Expand Down
1 change: 0 additions & 1 deletion examples/react-ssr-workerd/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default defineConfig((_env) => ({
},
},
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
},
Expand Down
1 change: 0 additions & 1 deletion examples/react-ssr/vite.config.workerd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default defineConfig((_env) => ({
],
environments: {
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
},
Expand Down
13 changes: 7 additions & 6 deletions examples/vue-ssr-extra/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ export default defineConfig((_env) => ({
},
},
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
},
optimizeDeps: {
// prevent flaky outdated deps error
noDiscovery: true,
include: [],
conditions: ["module", "browser", "production/development"],
},
build: {
outDir: "dist/server",
rollupOptions: {
output: {
// TODO: broken without this. probably my app setup issue.
inlineDynamicImports: true,
},
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-ssr/vite.config.workerd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default defineConfig((_env) => ({
],
environments: {
workerd: {
webCompatible: true,
resolve: {
conditions: ["module"],
noExternal: true,
},
},
Expand Down
9 changes: 7 additions & 2 deletions examples/web-worker-rsc/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export default defineConfig((_env) => ({
},
},
worker: {
webCompatible: true,
keepProcessEnv: false,
resolve: {
conditions: ["react-server"],
// need "browser" condition for "react-server-dom-webpack/server"
conditions: ["module", "worker", "browser", "react-server"],
noExternal: true,
},
optimizeDeps: {
Expand All @@ -29,6 +30,10 @@ export default defineConfig((_env) => ({
"react/jsx-dev-runtime",
"react-server-dom-webpack/server",
],
esbuildOptions: {
platform: "browser",
banner: undefined,
},
},
},
},
Expand Down
13 changes: 6 additions & 7 deletions examples/web-worker/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export default defineConfig((_env) => ({
},
},
worker: {
webCompatible: true,
keepProcessEnv: false,
resolve: {
conditions: ["worker"],
conditions: ["module", "worker"],
noExternal: true,
},
optimizeDeps: {
Expand All @@ -35,6 +35,10 @@ export default defineConfig((_env) => ({
"react/jsx-dev-runtime",
"react-dom/server",
],
esbuildOptions: {
platform: "browser",
banner: undefined,
},
},
build: {
assetsDir: "_worker",
Expand All @@ -46,11 +50,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,
},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/workerd/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export function vitePluginWorkerd(pluginOptions: WorkerdPluginOptions): Plugin {
return {
environments: {
workerd: {
keepProcessEnv: false,
optimizeDeps: {
// prevent `import { createRequire } from "node:module"`
esbuildOptions: {
platform: "browser",
banner: undefined,
},
},
dev: {
createEnvironment: (name, config) =>
createWorkerdDevEnvironment(name, config, pluginOptions),
Expand Down
Loading

0 comments on commit feaa3d2

Please sign in to comment.