From e0286965ebcbb9e100cef8c9b1901c7831b313ad Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 11 Aug 2025 13:49:12 +0900 Subject: [PATCH 1/3] fix(rsc): remove `ignoredPackageWarnings` --- packages/plugin-rsc/src/plugin.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/plugin-rsc/src/plugin.ts b/packages/plugin-rsc/src/plugin.ts index 1181c7d1e..7507a56e9 100644 --- a/packages/plugin-rsc/src/plugin.ts +++ b/packages/plugin-rsc/src/plugin.ts @@ -1232,19 +1232,8 @@ function vitePluginUseServer( this.environment.mode === 'dev' && id.includes('/node_modules/') ) { - const ignored = - useServerPluginOptions.ignoredPackageWarnings?.some( - (pattern) => - pattern instanceof RegExp - ? pattern.test(id) - : id.includes(`/node_modules/${pattern}/`), - ) - if (!ignored) { - this.warn( - `[vite-rsc] detected an internal server function created by a package imported on ${this.environment.name} environment`, - ) - } - // module runner has additional resolution step and it's not strict about + // similar situation as `use client` (see `virtual:client-in-server-package-proxy`) + // but module runner has additional resolution step and it's not strict about // module identity of `import(id)` like browser, so we simply strip queries such as `?v=`. id = cleanUrl(id) } From 2bcb8644f8cedf5b4a99ad61d1b353a0e5aa1505 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 11 Aug 2025 13:55:31 +0900 Subject: [PATCH 2/3] chore: deprecated --- packages/plugin-rsc/src/plugin.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/plugin-rsc/src/plugin.ts b/packages/plugin-rsc/src/plugin.ts index 7507a56e9..41ca4069c 100644 --- a/packages/plugin-rsc/src/plugin.ts +++ b/packages/plugin-rsc/src/plugin.ts @@ -98,6 +98,7 @@ export type RscPluginOptions = { rscCssTransform?: false | { filter?: (id: string) => boolean } + /** @deprecated no warning is emitted anymore. */ ignoredPackageWarnings?: (string | RegExp)[] /** From 717fc7de89fbea3b777928e2bbcdf71d8c843379 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 13 Aug 2025 11:15:02 +0900 Subject: [PATCH 3/3] fix: use debug --- .../plugin-rsc/examples/basic/vite.config.ts | 1 - packages/plugin-rsc/src/plugin.ts | 27 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/plugin-rsc/examples/basic/vite.config.ts b/packages/plugin-rsc/examples/basic/vite.config.ts index 98edceac7..258a0e3ef 100644 --- a/packages/plugin-rsc/examples/basic/vite.config.ts +++ b/packages/plugin-rsc/examples/basic/vite.config.ts @@ -20,7 +20,6 @@ export default defineConfig({ }, // disable auto css injection to manually test `loadCss` feature. rscCssTransform: false, - ignoredPackageWarnings: [/@vitejs\/test-dep-/], copyServerAssetsToClient: (fileName) => fileName !== '__server_secret.txt', }), diff --git a/packages/plugin-rsc/src/plugin.ts b/packages/plugin-rsc/src/plugin.ts index 398771736..54365be47 100644 --- a/packages/plugin-rsc/src/plugin.ts +++ b/packages/plugin-rsc/src/plugin.ts @@ -39,6 +39,7 @@ import { } from './vite-utils' import { cjsModuleRunnerPlugin } from './plugins/cjs' import { evalValue, parseIdQuery } from './plugins/utils' +import { createDebug } from '@hiogawa/utils' // state for build orchestration let serverReferences: Record = {} @@ -98,7 +99,7 @@ export type RscPluginOptions = { rscCssTransform?: false | { filter?: (id: string) => boolean } - /** @deprecated no warning is emitted anymore. */ + /** @deprecated use "DEBUG=vite-env:*" to see warnings. */ ignoredPackageWarnings?: (string | RegExp)[] /** @@ -940,7 +941,7 @@ function hashString(v: string) { function vitePluginUseClient( useClientPluginOptions: Pick< RscPluginOptions, - 'ignoredPackageWarnings' | 'keepUseCientProxy' | 'environment' + 'keepUseCientProxy' | 'environment' >, ): Plugin[] { const packageSources = new Map() @@ -970,6 +971,8 @@ function vitePluginUseClient( } } + const debug = createDebug('vite-rsc:use-client') + return [ { name: 'rsc:use-client', @@ -993,18 +996,9 @@ function vitePluginUseClient( // expectation on dependency optimizer on browser. Directly copying over // "?v=" from client optimizer in client reference can make a hashed // module stale, so we use another virtual module wrapper to delay such process. - // TODO: suggest `optimizeDeps.exclude` and skip warning if that's already the case. - const ignored = useClientPluginOptions.ignoredPackageWarnings?.some( - (pattern) => - pattern instanceof RegExp - ? pattern.test(id) - : id.includes(`/node_modules/${pattern}/`), + debug( + `internal client reference created through a package imported in '${this.environment.name}' environment: ${id}`, ) - if (!ignored) { - this.warn( - `[vite-rsc] detected an internal client boundary created by a package imported on rsc environment`, - ) - } id = cleanUrl(id) warnInoncistentClientOptimization(this, id) importId = `/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/${encodeURIComponent(id)}` @@ -1233,13 +1227,15 @@ function vitePluginDefineEncryptionKey( function vitePluginUseServer( useServerPluginOptions: Pick< RscPluginOptions, - 'ignoredPackageWarnings' | 'enableActionEncryption' | 'environment' + 'enableActionEncryption' | 'environment' >, ): Plugin[] { const serverEnvironmentName = useServerPluginOptions.environment?.rsc ?? 'rsc' const browserEnvironmentName = useServerPluginOptions.environment?.browser ?? 'client' + const debug = createDebug('vite-rsc:use-server') + return [ { name: 'rsc:use-server', @@ -1257,6 +1253,9 @@ function vitePluginUseServer( // similar situation as `use client` (see `virtual:client-in-server-package-proxy`) // but module runner has additional resolution step and it's not strict about // module identity of `import(id)` like browser, so we simply strip queries such as `?v=`. + debug( + `internal server reference created through a package imported in ${this.environment.name} environment: ${id}`, + ) id = cleanUrl(id) } if (config.command === 'build') {