@@ -39,6 +39,7 @@ import {
3939} from './vite-utils'
4040import { cjsModuleRunnerPlugin } from './plugins/cjs'
4141import { evalValue , parseIdQuery } from './plugins/utils'
42+ import { createDebug } from '@hiogawa/utils'
4243
4344// state for build orchestration
4445let serverReferences : Record < string , string > = { }
@@ -98,6 +99,7 @@ export type RscPluginOptions = {
9899
99100 rscCssTransform ?: false | { filter ?: ( id : string ) => boolean }
100101
102+ /** @deprecated use "DEBUG=vite-env:*" to see warnings. */
101103 ignoredPackageWarnings ?: ( string | RegExp ) [ ]
102104
103105 /**
@@ -939,7 +941,7 @@ function hashString(v: string) {
939941function vitePluginUseClient (
940942 useClientPluginOptions : Pick <
941943 RscPluginOptions ,
942- 'ignoredPackageWarnings' | ' keepUseCientProxy' | 'environment'
944+ 'keepUseCientProxy' | 'environment'
943945 > ,
944946) : Plugin [ ] {
945947 const packageSources = new Map < string , string > ( )
@@ -969,6 +971,8 @@ function vitePluginUseClient(
969971 }
970972 }
971973
974+ const debug = createDebug ( 'vite-rsc:use-client' )
975+
972976 return [
973977 {
974978 name : 'rsc:use-client' ,
@@ -992,18 +996,9 @@ function vitePluginUseClient(
992996 // expectation on dependency optimizer on browser. Directly copying over
993997 // "?v=<hash>" from client optimizer in client reference can make a hashed
994998 // module stale, so we use another virtual module wrapper to delay such process.
995- // TODO: suggest `optimizeDeps.exclude` and skip warning if that's already the case.
996- const ignored = useClientPluginOptions . ignoredPackageWarnings ?. some (
997- ( pattern ) =>
998- pattern instanceof RegExp
999- ? pattern . test ( id )
1000- : id . includes ( `/node_modules/${ pattern } /` ) ,
999+ debug (
1000+ `internal client reference created through a package imported in '${ this . environment . name } ' environment: ${ id } ` ,
10011001 )
1002- if ( ! ignored ) {
1003- this . warn (
1004- `[vite-rsc] detected an internal client boundary created by a package imported on rsc environment` ,
1005- )
1006- }
10071002 id = cleanUrl ( id )
10081003 warnInoncistentClientOptimization ( this , id )
10091004 importId = `/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/${ encodeURIComponent ( id ) } `
@@ -1232,13 +1227,15 @@ function vitePluginDefineEncryptionKey(
12321227function vitePluginUseServer (
12331228 useServerPluginOptions : Pick <
12341229 RscPluginOptions ,
1235- 'ignoredPackageWarnings' | ' enableActionEncryption' | 'environment'
1230+ 'enableActionEncryption' | 'environment'
12361231 > ,
12371232) : Plugin [ ] {
12381233 const serverEnvironmentName = useServerPluginOptions . environment ?. rsc ?? 'rsc'
12391234 const browserEnvironmentName =
12401235 useServerPluginOptions . environment ?. browser ?? 'client'
12411236
1237+ const debug = createDebug ( 'vite-rsc:use-server' )
1238+
12421239 return [
12431240 {
12441241 name : 'rsc:use-server' ,
@@ -1253,20 +1250,12 @@ function vitePluginUseServer(
12531250 this . environment . mode === 'dev' &&
12541251 id . includes ( '/node_modules/' )
12551252 ) {
1256- const ignored =
1257- useServerPluginOptions . ignoredPackageWarnings ?. some (
1258- ( pattern ) =>
1259- pattern instanceof RegExp
1260- ? pattern . test ( id )
1261- : id . includes ( `/node_modules/${ pattern } /` ) ,
1262- )
1263- if ( ! ignored ) {
1264- this . warn (
1265- `[vite-rsc] detected an internal server function created by a package imported on ${ this . environment . name } environment` ,
1266- )
1267- }
1268- // module runner has additional resolution step and it's not strict about
1253+ // similar situation as `use client` (see `virtual:client-in-server-package-proxy`)
1254+ // but module runner has additional resolution step and it's not strict about
12691255 // module identity of `import(id)` like browser, so we simply strip queries such as `?v=`.
1256+ debug (
1257+ `internal server reference created through a package imported in ${ this . environment . name } environment: ${ id } ` ,
1258+ )
12701259 id = cleanUrl ( id )
12711260 }
12721261 if ( config . command === 'build' ) {
0 commit comments