@@ -39,6 +39,7 @@ import {
39
39
} from './vite-utils'
40
40
import { cjsModuleRunnerPlugin } from './plugins/cjs'
41
41
import { evalValue , parseIdQuery } from './plugins/utils'
42
+ import { createDebug } from '@hiogawa/utils'
42
43
43
44
// state for build orchestration
44
45
let serverReferences : Record < string , string > = { }
@@ -98,6 +99,7 @@ export type RscPluginOptions = {
98
99
99
100
rscCssTransform ?: false | { filter ?: ( id : string ) => boolean }
100
101
102
+ /** @deprecated use "DEBUG=vite-env:*" to see warnings. */
101
103
ignoredPackageWarnings ?: ( string | RegExp ) [ ]
102
104
103
105
/**
@@ -939,7 +941,7 @@ function hashString(v: string) {
939
941
function vitePluginUseClient (
940
942
useClientPluginOptions : Pick <
941
943
RscPluginOptions ,
942
- 'ignoredPackageWarnings' | ' keepUseCientProxy' | 'environment'
944
+ 'keepUseCientProxy' | 'environment'
943
945
> ,
944
946
) : Plugin [ ] {
945
947
const packageSources = new Map < string , string > ( )
@@ -969,6 +971,8 @@ function vitePluginUseClient(
969
971
}
970
972
}
971
973
974
+ const debug = createDebug ( 'vite-rsc:use-client' )
975
+
972
976
return [
973
977
{
974
978
name : 'rsc:use-client' ,
@@ -992,18 +996,9 @@ function vitePluginUseClient(
992
996
// expectation on dependency optimizer on browser. Directly copying over
993
997
// "?v=<hash>" from client optimizer in client reference can make a hashed
994
998
// 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 } ` ,
1001
1001
)
1002
- if ( ! ignored ) {
1003
- this . warn (
1004
- `[vite-rsc] detected an internal client boundary created by a package imported on rsc environment` ,
1005
- )
1006
- }
1007
1002
id = cleanUrl ( id )
1008
1003
warnInoncistentClientOptimization ( this , id )
1009
1004
importId = `/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/${ encodeURIComponent ( id ) } `
@@ -1232,13 +1227,15 @@ function vitePluginDefineEncryptionKey(
1232
1227
function vitePluginUseServer (
1233
1228
useServerPluginOptions : Pick <
1234
1229
RscPluginOptions ,
1235
- 'ignoredPackageWarnings' | ' enableActionEncryption' | 'environment'
1230
+ 'enableActionEncryption' | 'environment'
1236
1231
> ,
1237
1232
) : Plugin [ ] {
1238
1233
const serverEnvironmentName = useServerPluginOptions . environment ?. rsc ?? 'rsc'
1239
1234
const browserEnvironmentName =
1240
1235
useServerPluginOptions . environment ?. browser ?? 'client'
1241
1236
1237
+ const debug = createDebug ( 'vite-rsc:use-server' )
1238
+
1242
1239
return [
1243
1240
{
1244
1241
name : 'rsc:use-server' ,
@@ -1253,20 +1250,12 @@ function vitePluginUseServer(
1253
1250
this . environment . mode === 'dev' &&
1254
1251
id . includes ( '/node_modules/' )
1255
1252
) {
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
1269
1255
// 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
+ )
1270
1259
id = cleanUrl ( id )
1271
1260
}
1272
1261
if ( config . command === 'build' ) {
0 commit comments