Skip to content

Commit

Permalink
chore: squashed all
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Aug 31, 2024
1 parent f4d97b3 commit 3cc83a4
Show file tree
Hide file tree
Showing 23 changed files with 661 additions and 588 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"tsup": "^8.1.0",
"tsx": "^4.16.2",
"typescript": "^5.5.4",
"vite": "^5.3.3",
"vite": "6.0.0-alpha.19",
"vitest": "^2.0.1",
"wrangler": "^3.72.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server/examples/basic/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ test("rsc + client + rsc hmr @dev", async ({ page }) => {
await waitForHydration(page);
});

test("module invalidation @dev", async ({ page }) => {
test.skip("module invalidation @dev", async ({ page }) => {
checkNoError(page);

await page.goto("/test");
Expand Down
23 changes: 13 additions & 10 deletions packages/vite-node-miniflare/examples/basic/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import fs from "node:fs";
import { tinyReactVitePlugin } from "@hiogawa/tiny-react/dist/plugins/vite";
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare";
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare";
import { vitePluginSimpleHmr } from "@hiogawa/vite-plugin-simple-hmr";
import { Log } from "miniflare";
import { type Plugin, type ViteDevServer, defineConfig } from "vite";

export default defineConfig({
clearScreen: false,
appType: "custom",
ssr: {
noExternal: true,
},
plugins: [
vitePluginSimpleHmr({
include: new URL("./src/**/*.tsx", import.meta.url).pathname,
}),
vitePluginViteNodeMiniflare({
debug: true,
hmr: true,
entry: "/src/worker-entry.ts",
miniflareOptions(options) {
options.log = new Log();
vitePluginWorkerd({
entry: "/src/worker-entry",
miniflare: {
log: new Log(),
},
}),
tinyReactVitePlugin(),
vitePluginVirtualIndexHtml(),
],
environments: {
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
},
},
},
});

export function vitePluginVirtualIndexHtml(): Plugin {
Expand Down
48 changes: 27 additions & 21 deletions packages/vite-node-miniflare/examples/react-router/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
import globRoutesPlugin from "@hiogawa/vite-glob-routes";
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare";
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare";
import react from "@vitejs/plugin-react";
import { Log } from "miniflare";
import { defineConfig } from "vite";
import { vitePluginVirtualIndexHtml } from "../basic/vite.config";

export default defineConfig({
clearScreen: false,
ssr: {
resolve: {
conditions: ["workerd"],
},
optimizeDeps: {
include: [
"react",
"react/jsx-dev-runtime",
"react-dom",
"react-dom/server",
],
},
},
appType: "custom",
plugins: [
react(),
globRoutesPlugin({ root: "/src/routes" }),
vitePluginViteNodeMiniflare({
debug: true,
entry: "/src/server/worker-entry.ts",
miniflareOptions(options) {
options.log = new Log();
options.compatibilityFlags = ["nodejs_compat"];
vitePluginWorkerd({
entry: "/src/server/worker-entry",
miniflare: {
log: new Log(),
compatibilityFlags: ["nodejs_compat"],
},
}),
react(),
vitePluginVirtualIndexHtml(),
],
environments: {
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
conditions: ["workerd"],
},
dev: {
optimizeDeps: {
include: [
"react",
"react/jsx-dev-runtime",
"react-dom",
"react-dom/server",
],
},
},
},
},
});
46 changes: 26 additions & 20 deletions packages/vite-node-miniflare/examples/react/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare";
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare";
import react from "@vitejs/plugin-react";
import { Log } from "miniflare";
import { defineConfig } from "vite";
import { vitePluginVirtualIndexHtml } from "../basic/vite.config";

export default defineConfig({
clearScreen: false,
optimizeDeps: {
// for debugging
// DEBUG=vite:deps pnpm -C examples/react dev
// force: true,
},
ssr: {
resolve: {
conditions: ["workerd"],
},
optimizeDeps: {
include: ["react", "react/jsx-dev-runtime", "react-dom/server"],
},
},
appType: "custom",
plugins: [
vitePluginViteNodeMiniflare({
debug: true,
entry: "/src/worker-entry.tsx",
miniflareOptions(options) {
options.log = new Log();
react(),
vitePluginWorkerd({
entry: "/src/worker-entry",
miniflare: {
log: new Log(),
},
}),
react(),
vitePluginVirtualIndexHtml(),
],
environments: {
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
conditions: ["workerd"],
},
dev: {
optimizeDeps: {
include: [
"react",
"react/jsx-runtime",
"react/jsx-dev-runtime",
"react-dom/server",
],
},
},
},
},
});
1 change: 1 addition & 0 deletions packages/vite-node-miniflare/examples/remix/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
.mf
3 changes: 2 additions & 1 deletion packages/vite-node-miniflare/examples/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@hiogawa/vite-node-miniflare": "workspace:*",
"@remix-run/dev": "2.8.1",
"@types/react": "latest",
"@types/react-dom": "latest"
"@types/react-dom": "latest",
"wrangler": "^3.72.2"
}
}
58 changes: 34 additions & 24 deletions packages/vite-node-miniflare/examples/remix/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
import { vitePluginViteNodeMiniflare } from "@hiogawa/vite-node-miniflare";
import { vitePluginWorkerd } from "@hiogawa/vite-node-miniflare";
import { vitePlugin as remix } from "@remix-run/dev";
import { Log, Response as MiniflareResponse } from "miniflare";
import { defineConfig } from "vite";
import { vitePluginVirtualIndexHtml } from "../basic/vite.config";

export default defineConfig({
clearScreen: false,
ssr: {
resolve: {
conditions: ["workerd"],
},
optimizeDeps: {
include: [
"react",
"react/jsx-dev-runtime",
"react-dom",
"react-dom/server",
"@remix-run/server-runtime",
],
},
},
plugins: [
vitePluginViteNodeMiniflare({
debug: true,
entry: "/app/worker-entry.ts",
miniflareOptions(options) {
options.log = new Log();
options.kvNamespaces = { kv: "0".repeat(32) };
options.kvPersist = ".wrangler/state/v3/kv";
options.serviceBindings = {
// TODO: how to avoid spawning this for remix child compiler
vitePluginWorkerd({
entry: "/app/worker-entry",
miniflare: {
log: new Log(),
kvPersist: true,
serviceBindings: {
// DevServerHook is implemented via serviceBindings based rpc
// https://github.com/remix-run/remix/blob/db4471d2e32a175abdcb907b877f9a510c735d8b/packages/remix-server-runtime/dev.ts#L37-L48
__remixGetCriticalCss: async (request) => {
Expand All @@ -37,9 +23,33 @@ export default defineConfig({
].getCriticalCss(...args);
return new MiniflareResponse(JSON.stringify({ result }));
},
};
},
},
wrangler: {
configPath: "./wrangler.toml",
},
}),
vitePluginVirtualIndexHtml(),
remix(),
],
environments: {
workerd: {
webCompatible: true,
resolve: {
noExternal: true,
conditions: ["workerd"],
},
dev: {
optimizeDeps: {
include: [
"react",
"react/jsx-dev-runtime",
"react-dom",
"react-dom/server",
"@remix-run/server-runtime",
],
},
},
},
},
});
5 changes: 5 additions & 0 deletions packages/vite-node-miniflare/examples/remix/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compatibility_date = "2024-01-01"
compatibility_flags = ["nodejs_compat"]
kv_namespaces = [
{ binding = "kv", id = "test-namespace" }
]
23 changes: 14 additions & 9 deletions packages/vite-node-miniflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,23 @@
"scripts": {
"dev": "tsup --watch",
"build": "tsup",
"prepack": "tsup --clean",
"release": "pnpm publish --no-git-checks --access public"
},
"dependencies": {
"@hattip/adapter-node": "^0.0.44",
"@hattip/compose": "^0.0.44",
"miniflare": "^3.20240821.0"
"prepack": "tsup --clean"
},
"dependencies": {},
"devDependencies": {
"@hiogawa/tiny-rpc": "0.2.3-pre.18"
"@cloudflare/workers-types": "^4.20240821.1",
"@hiogawa/utils-node": "^0.0.2",
"miniflare": "^3.20240821.0",
"wrangler": "^3.72.2"
},
"peerDependencies": {
"vite": "*"
"miniflare": "*",
"vite": "*",
"wrangler": "*"
},
"peerDependenciesMeta": {
"wrangler": {
"optional": true
}
}
}
Loading

0 comments on commit 3cc83a4

Please sign in to comment.