From fc38fd3cd475153d79963649e064147108747de7 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 12 Nov 2024 17:29:24 +0900 Subject: [PATCH] refactor(viteroll): inline `react-refresh/runtime` (#72) --- .github/workflows/ci.yml | 1 + viteroll/examples/ssr/src/entry-client.tsx | 2 - viteroll/viteroll.ts | 116 ++++++++++----------- 3 files changed, 54 insertions(+), 65 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71b2646..f2f451e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,3 +117,4 @@ jobs: - run: pnpm test-e2e - run: pnpm -C examples/react test-e2e - run: pnpm -C examples/mpa test-e2e + - run: pnpm -C examples/ssr test-e2e diff --git a/viteroll/examples/ssr/src/entry-client.tsx b/viteroll/examples/ssr/src/entry-client.tsx index f50a730..3e5c48f 100644 --- a/viteroll/examples/ssr/src/entry-client.tsx +++ b/viteroll/examples/ssr/src/entry-client.tsx @@ -1,5 +1,3 @@ -// TODO: how to inject automatically? -import "virtual:react-refresh/entry"; import React from "react"; import ReactDOMClient from "react-dom/client"; import { App } from "./app"; diff --git a/viteroll/viteroll.ts b/viteroll/viteroll.ts index e785301..dc142b5 100644 --- a/viteroll/viteroll.ts +++ b/viteroll/viteroll.ts @@ -63,8 +63,10 @@ export function viteroll(viterollOptions: ViterollOptions = {}): Plugin { }, ssr: { dev: { - createEnvironment: - RolldownEnvironment.createFactory(viterollOptions), + createEnvironment: RolldownEnvironment.createFactory({ + ...viterollOptions, + reactRefresh: false, + }), }, }, }, @@ -315,9 +317,6 @@ function viterollEntryPlugin( htmlEntryMap.set(id, htmlOutput); let jsOutput = ``; - if (viterollOptions?.reactRefresh) { - jsOutput += `import "virtual:react-refresh/entry";\n`; - } // extract