Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform code run twice #338

Closed
himself65 opened this issue Jan 1, 2024 · 2 comments · Fixed by #341
Closed

transform code run twice #338

himself65 opened this issue Jan 1, 2024 · 2 comments · Fixed by #341

Comments

@himself65
Copy link
Contributor

Index: examples/12_css/vite.config.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/examples/12_css/vite.config.ts b/examples/12_css/vite.config.ts
--- a/examples/12_css/vite.config.ts	(revision ebd005ff88a3236ec02d21a466f0dd5f086aa507)
+++ b/examples/12_css/vite.config.ts	(date 1704119642367)
@@ -1,10 +1,23 @@
 import { defineConfig } from 'vite';
 import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
 import styleX from 'vite-plugin-stylex';
-
+let counter = 0;
 export default defineConfig({
   ssr: {
     external: ['@stylexjs/stylex'],
   },
-  plugins: [vanillaExtractPlugin({ emitCssInSsr: true }), styleX()],
+  plugins: [
+    vanillaExtractPlugin({ emitCssInSsr: true }),
+    styleX(),
+    {
+      name: 'test-plugin',
+      transform(code) {
+        const c = `${code};${counter}`
+        console.log('c', c)
+        return {
+          code: c
+        }
+      }
+    }
+  ],
 });
/Users/himself65/Library/Caches/fnm_multishells/70636_1703645957566/bin/pnpm run dev

> [email protected] dev /Users/himself65/Code/waku/examples/12_css
> waku dev --with-ssr

ready: Listening on http://localhost:3000/
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
c import { jsxDEV } from "react/jsx-dev-runtime";
import { lazy } from "react";
import { defineEntries } from "waku/server";
const App = lazy(() => import("./components/App.js"));
export default defineEntries(
  // renderEntries
  async (input) => {
    return {
      App: /* @__PURE__ */ jsxDEV(App, { name: input || "Waku" }, void 0, false, {
        fileName: "/Users/himself65/Code/waku/examples/12_css/src/entries.tsx",
        lineNumber: 10,
        columnNumber: 12
      }, this)
    };
  },
  // getBuildConfig
  async () => [{ pathname: "/", entries: [{ input: "" }] }],
  // getSsrConfig
  async (pathname) => {
    switch (pathname) {
      case "/":
        return {
          input: "",
          unstable_render: ({ createElement, Slot }) => createElement(Slot, { id: "App" })
        };
      default:
        return null;
    }
  }
);
;0
c import { jsxDEV } from "react/jsx-dev-runtime";
import { lazy } from "react";
import { defineEntries } from "waku/server";
const App = lazy(() => import("./components/App.js"));
export default defineEntries(
  // renderEntries
  async (input) => {
    return {
      App: /* @__PURE__ */ jsxDEV(App, { name: input || "Waku" }, void 0, false, {
        fileName: "/Users/himself65/Code/waku/examples/12_css/src/entries.tsx",
        lineNumber: 10,
        columnNumber: 12
      }, this)
    };
  },
  // getBuildConfig
  async () => [{ pathname: "/", entries: [{ input: "" }] }],
  // getSsrConfig
  async (pathname) => {
    switch (pathname) {
      case "/":
        return {
          input: "",
          unstable_render: ({ createElement, Slot }) => createElement(Slot, { id: "App" })
        };
      default:
        return null;
    }
  }
);
;0;0
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

You will see that there are ;0;0 instead of ;0 on the second output

@himself65 himself65 changed the title two vite server might cause transform code incorrect result transform code run twice Jan 1, 2024
@himself65
Copy link
Contributor Author

Upstream issue: vitejs/vite#15482

@himself65
Copy link
Contributor Author

This will block #110, as commonjs plugin cannot work properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant