Skip to content

Commit

Permalink
chore: alpha.18 change
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Jun 8, 2024
1 parent 32524d8 commit 87b5bb0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
7 changes: 1 addition & 6 deletions examples/custom/src/optimize-deps/runner.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { fileURLToPath } from "url";
import { tinyassert } from "@hiogawa/utils";
import {
createNodeDevEnvironment,
createServer,
createServerModuleRunner,
} from "vite";
import { createServer, createServerModuleRunner } from "vite";

const server = await createServer({
clearScreen: false,
Expand All @@ -13,7 +9,6 @@ const server = await createServer({
environments: {
custom: {
dev: {
createEnvironment: createNodeDevEnvironment,
optimizeDeps: {
include: ["react", "react-dom"],
},
Expand Down
2 changes: 0 additions & 2 deletions examples/react-server/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
DevEnvironment,
type Plugin,
type PluginOption,
createNodeDevEnvironment,
createServerModuleRunner,
defineConfig,
parseAstAsync,
Expand Down Expand Up @@ -118,7 +117,6 @@ function vitePluginReactServer(): PluginOption {
noExternal: true,
},
dev: {
createEnvironment: createNodeDevEnvironment,
optimizeDeps: {
include: [
"react",
Expand Down
7 changes: 2 additions & 5 deletions packages/workerd/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import {
type CustomPayload,
DevEnvironment,
type HMRChannel,
type HotChannel,
type Plugin,
type ResolvedConfig,
} from "vite";
Expand Down Expand Up @@ -165,7 +165,6 @@ export async function createWorkerdDevEnvironment(

// websocket hmr channgel
const hot = createSimpleHMRChannel({
name,
post: (data) => webSocket.send(data),
on: (listener) => {
webSocket.addEventListener("message", listener);
Expand Down Expand Up @@ -245,17 +244,15 @@ export async function createWorkerdDevEnvironment(
// https://github.com/vitejs/vite/blob/feat/environment-api/packages/vite/src/node/server/hmr.ts/#L909-L910
// https://github.com/vitejs/vite/blob/feat/environment-api/packages/vite/src/node/ssr/runtime/serverHmrConnector.ts/#L33-L34
function createSimpleHMRChannel(options: {
name: string;
post: (data: any) => any;
on: (listener: (data: any) => void) => () => void;
serialize: (v: any) => any;
deserialize: (v: any) => any;
}): HMRChannel {
}): HotChannel {
const listerMap = new DefaultMap<string, Set<Function>>(() => new Set());
let dispose: (() => void) | undefined;

return {
name: options.name,
listen() {
dispose = options.on((data) => {
const payload = options.deserialize(data) as CustomPayload;
Expand Down

0 comments on commit 87b5bb0

Please sign in to comment.