diff --git a/examples/37_css/package.json b/examples/37_css/package.json index f32269b38..f221b641a 100644 --- a/examples/37_css/package.json +++ b/examples/37_css/package.json @@ -20,7 +20,7 @@ "devDependencies": { "@types/react": "19.0.1", "@types/react-dom": "19.0.1", - "@vanilla-extract/vite-plugin": "4.0.10", + "@vanilla-extract/vite-plugin": "4.0.18", "typescript": "5.7.2", "vite": "5.4.10", "vite-plugin-stylex-dev": "0.7.5" diff --git a/examples/37_css/vite.config.ts b/examples/37_css/vite.config.ts index 64053fcfa..5e51938c0 100644 --- a/examples/37_css/vite.config.ts +++ b/examples/37_css/vite.config.ts @@ -5,9 +5,9 @@ import { stylexPlugin } from 'vite-plugin-stylex-dev'; export default { plugins: [ { - name: 'hack-css-plugin-why-do-we-need-this-FIXME', + name: 'hack-css-plugin-needed-for-stylex-dev-FIXME', resolveId(id: string) { - if (id.endsWith('.css')) { + if (id.endsWith('.css') && !id.endsWith('.vanilla.css')) { return id; } }, diff --git a/packages/waku/src/lib/middleware/dev-server-impl.ts b/packages/waku/src/lib/middleware/dev-server-impl.ts index 9af1bdfde..ded3a7f13 100644 --- a/packages/waku/src/lib/middleware/dev-server-impl.ts +++ b/packages/waku/src/lib/middleware/dev-server-impl.ts @@ -24,7 +24,6 @@ import { rscEnvPlugin } from '../plugins/vite-plugin-rsc-env.js'; import { rscPrivatePlugin } from '../plugins/vite-plugin-rsc-private.js'; import { rscManagedPlugin } from '../plugins/vite-plugin-rsc-managed.js'; import { rscDelegatePlugin } from '../plugins/vite-plugin-rsc-delegate.js'; -import { mergeUserViteConfig } from '../utils/merge-vite-config.js'; import type { ClonableModuleNode, Middleware } from './types.js'; import { fsRouterTypegenPlugin } from '../plugins/vite-plugin-fs-router-typegen.js'; @@ -84,7 +83,7 @@ const createMainViteServer = ( configPromise: ReturnType<typeof resolveConfig>, ) => { const vitePromise = configPromise.then(async (config) => { - const mergedViteConfig = await mergeUserViteConfig({ + const vite = await createViteServer({ // Since we have multiple instances of vite, different ones might overwrite the others' cache. cacheDir: 'node_modules/.vite/waku-dev-server-main', base: config.basePath, @@ -126,7 +125,6 @@ const createMainViteServer = ( appType: 'mpa', server: { middlewareMode: true }, }); - const vite = await createViteServer(mergedViteConfig); registerHotUpdateCallback((payload) => hotUpdate(vite, payload)); return vite; }); @@ -219,7 +217,7 @@ const createRscViteServer = ( const dummyServer = new Server(); // FIXME we hope to avoid this hack const vitePromise = configPromise.then(async (config) => { - const mergedViteConfig = await mergeUserViteConfig({ + const vite = await createViteServer({ // Since we have multiple instances of vite, different ones might overwrite the others' cache. cacheDir: 'node_modules/.vite/waku-dev-server-rsc', plugins: [ @@ -262,7 +260,6 @@ const createRscViteServer = ( appType: 'custom', server: { middlewareMode: true, hmr: { server: dummyServer } }, }); - const vite = await createViteServer(mergedViteConfig); return vite; }); diff --git a/packages/waku/src/lib/utils/merge-vite-config.ts b/packages/waku/src/lib/utils/merge-vite-config.ts deleted file mode 100644 index 7072c91de..000000000 --- a/packages/waku/src/lib/utils/merge-vite-config.ts +++ /dev/null @@ -1,55 +0,0 @@ -import type { UserConfig, PluginOption } from 'vite'; -import { - resolveConfig as resolveViteConfig, - mergeConfig as mergeViteConfig, -} from 'vite'; - -// Avoid terser warning and "path" error for each time we instantiate a vite server -// Avoid vite finding the config itself, instead, we handle it ourselves with the config argument -export async function mergeUserViteConfig(config: UserConfig) { - const resolvedViteConfig = await resolveViteConfig({}, 'serve'); - const filterPlugins = (plugin: PluginOption[]): PluginOption[] => - plugin.flatMap((plugin) => { - if (Array.isArray(plugin)) { - return [filterPlugins(plugin)]; - } - if (plugin && 'name' in plugin) { - if (resolvedViteConfig.plugins.some((p) => p.name === plugin.name)) { - return []; - } - return [plugin]; - } - return [plugin]; - }); - - const mergedViteConfig = mergeViteConfig( - { - ...resolvedViteConfig, - configFile: false, - // FIXME weird error around plugin duplication when removed - plugins: resolvedViteConfig.plugins.filter( - (plugin) => - ![ - 'vite:css', - 'vite:css-post', - 'vite:import-analysis', - 'vite:json', - 'vite:client-inject', - ].includes(plugin.name), - ), - }, - { - ...config, - plugins: config.plugins && filterPlugins(config.plugins), - }, - ); - - // vite sets terserOptions to {} in resolveViteConfig and minify to 'esbuild' at the same time which shows a warning - if (!Object.keys(mergedViteConfig.build.terserOptions).length) { - mergedViteConfig.build.terserOptions = null; - } - - // HACK: Vite bug: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received function assetsInclude - mergedViteConfig.assetsInclude = null; - return mergedViteConfig; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24abbd5f4..8c9ef209b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -866,8 +866,8 @@ importers: specifier: 19.0.1 version: 19.0.1 '@vanilla-extract/vite-plugin': - specifier: 4.0.10 - version: 4.0.10(@types/node@22.10.1)(terser@5.37.0)(vite@5.4.10(@types/node@22.10.1)(terser@5.37.0)) + specifier: 4.0.18 + version: 4.0.18(@types/node@22.10.1)(terser@5.37.0)(vite@5.4.10(@types/node@22.10.1)(terser@5.37.0)) typescript: specifier: 5.7.2 version: 5.7.2 @@ -1323,10 +1323,6 @@ packages: peerDependencies: '@babel/core': ^7.0.0 - '@babel/helper-plugin-utils@7.25.7': - resolution: {integrity: sha512-eaPZai0PiqCi09pPs3pAFfl/zYgGaE6IdXtYvmf0qlcDTd3WCtO7JWCcRd64e0EQrcYgiHibEZnOGsSY4QSgaw==} - engines: {node: '>=6.9.0'} - '@babel/helper-plugin-utils@7.25.9': resolution: {integrity: sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==} engines: {node: '>=6.9.0'} @@ -2776,14 +2772,14 @@ packages: '@vanilla-extract/css@1.16.1': resolution: {integrity: sha512-3jKxH5ty/ZjmGoLAx8liY7e87FRCIJfnuufX/K9fQklu0YHP3ClrNisU++LkZuD+GZleqMSAQMF0r8Otln+OPQ==} - '@vanilla-extract/integration@7.1.10': - resolution: {integrity: sha512-EXe8l0u51ta2H78kksf7gJENkdYnvDW9c+18FUvKfxtjHmpc4KthXnUTuALt5k9wbAjfFakIR4IsqzvOP43cDQ==} + '@vanilla-extract/integration@7.1.11': + resolution: {integrity: sha512-IGRaLrpkjyVHTHDZQBQvFBl399yRfSMJoVI2KaocEZB33aP+H4Qup83od2hc6R5IxGWdvbiiCOJCYsnmFiy85Q==} '@vanilla-extract/private@1.0.6': resolution: {integrity: sha512-ytsG/JLweEjw7DBuZ/0JCN4WAQgM9erfSTdS1NQY778hFQSZ6cfCDEZZ0sgVm4k54uNz6ImKB33AYvSR//fjxw==} - '@vanilla-extract/vite-plugin@4.0.10': - resolution: {integrity: sha512-bjX5ioQeBTKuV/MOweeSCrGU5m7z4a76yf8J/r4gC5MGJrEvYu0YHaQIiiL7o2wlFSc929JUEUO1ahnVXUET6A==} + '@vanilla-extract/vite-plugin@4.0.18': + resolution: {integrity: sha512-j5vJVbvW33THGXG3ZI+nfgeYCknlBEWTJVphZWSAGmLO4XO4690m/iQQg+3gUtla3wvU8eyA2qmJNa05Wa7mVA==} peerDependencies: vite: 5.4.10 @@ -6123,8 +6119,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/helper-plugin-utils@7.25.7': {} - '@babel/helper-plugin-utils@7.25.9': {} '@babel/helper-simple-access@7.25.7': @@ -6171,10 +6165,10 @@ snapshots: dependencies: '@babel/types': 7.26.3 - '@babel/plugin-syntax-typescript@7.25.7(@babel/core@7.25.8)': + '@babel/plugin-syntax-typescript@7.25.7(@babel/core@7.26.0)': dependencies: - '@babel/core': 7.25.8 - '@babel/helper-plugin-utils': 7.25.7 + '@babel/core': 7.26.0 + '@babel/helper-plugin-utils': 7.25.9 '@babel/plugin-transform-react-jsx-self@7.25.9(@babel/core@7.26.0)': dependencies: @@ -7256,7 +7250,7 @@ snapshots: '@vanilla-extract/babel-plugin-debug-ids@1.1.0': dependencies: - '@babel/core': 7.25.8 + '@babel/core': 7.26.0 transitivePeerDependencies: - supports-color @@ -7277,10 +7271,10 @@ snapshots: transitivePeerDependencies: - babel-plugin-macros - '@vanilla-extract/integration@7.1.10(@types/node@22.10.1)(terser@5.37.0)': + '@vanilla-extract/integration@7.1.11(@types/node@22.10.1)(terser@5.37.0)': dependencies: - '@babel/core': 7.25.8 - '@babel/plugin-syntax-typescript': 7.25.7(@babel/core@7.25.8) + '@babel/core': 7.26.0 + '@babel/plugin-syntax-typescript': 7.25.7(@babel/core@7.26.0) '@vanilla-extract/babel-plugin-debug-ids': 1.1.0 '@vanilla-extract/css': 1.16.1 dedent: 1.5.3 @@ -7305,9 +7299,9 @@ snapshots: '@vanilla-extract/private@1.0.6': {} - '@vanilla-extract/vite-plugin@4.0.10(@types/node@22.10.1)(terser@5.37.0)(vite@5.4.10(@types/node@22.10.1)(terser@5.37.0))': + '@vanilla-extract/vite-plugin@4.0.18(@types/node@22.10.1)(terser@5.37.0)(vite@5.4.10(@types/node@22.10.1)(terser@5.37.0))': dependencies: - '@vanilla-extract/integration': 7.1.10(@types/node@22.10.1)(terser@5.37.0) + '@vanilla-extract/integration': 7.1.11(@types/node@22.10.1)(terser@5.37.0) vite: 5.4.10(@types/node@22.10.1)(terser@5.37.0) transitivePeerDependencies: - '@types/node' @@ -10857,7 +10851,7 @@ snapshots: vite-node@1.6.0(@types/node@22.10.1)(terser@5.37.0): dependencies: cac: 6.7.14 - debug: 4.3.7 + debug: 4.4.0 pathe: 1.1.2 picocolors: 1.1.1 vite: 5.4.10(@types/node@22.10.1)(terser@5.37.0)