Skip to content

Commit 717fc7d

Browse files
committed
fix: use debug
1 parent ae68bf6 commit 717fc7d

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default defineConfig({
2020
},
2121
// disable auto css injection to manually test `loadCss` feature.
2222
rscCssTransform: false,
23-
ignoredPackageWarnings: [/@vitejs\/test-dep-/],
2423
copyServerAssetsToClient: (fileName) =>
2524
fileName !== '__server_secret.txt',
2625
}),

packages/plugin-rsc/src/plugin.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
} from './vite-utils'
4040
import { cjsModuleRunnerPlugin } from './plugins/cjs'
4141
import { evalValue, parseIdQuery } from './plugins/utils'
42+
import { createDebug } from '@hiogawa/utils'
4243

4344
// state for build orchestration
4445
let serverReferences: Record<string, string> = {}
@@ -98,7 +99,7 @@ export type RscPluginOptions = {
9899

99100
rscCssTransform?: false | { filter?: (id: string) => boolean }
100101

101-
/** @deprecated no warning is emitted anymore. */
102+
/** @deprecated use "DEBUG=vite-env:*" to see warnings. */
102103
ignoredPackageWarnings?: (string | RegExp)[]
103104

104105
/**
@@ -940,7 +941,7 @@ function hashString(v: string) {
940941
function vitePluginUseClient(
941942
useClientPluginOptions: Pick<
942943
RscPluginOptions,
943-
'ignoredPackageWarnings' | 'keepUseCientProxy' | 'environment'
944+
'keepUseCientProxy' | 'environment'
944945
>,
945946
): Plugin[] {
946947
const packageSources = new Map<string, string>()
@@ -970,6 +971,8 @@ function vitePluginUseClient(
970971
}
971972
}
972973

974+
const debug = createDebug('vite-rsc:use-client')
975+
973976
return [
974977
{
975978
name: 'rsc:use-client',
@@ -993,18 +996,9 @@ function vitePluginUseClient(
993996
// expectation on dependency optimizer on browser. Directly copying over
994997
// "?v=<hash>" from client optimizer in client reference can make a hashed
995998
// module stale, so we use another virtual module wrapper to delay such process.
996-
// TODO: suggest `optimizeDeps.exclude` and skip warning if that's already the case.
997-
const ignored = useClientPluginOptions.ignoredPackageWarnings?.some(
998-
(pattern) =>
999-
pattern instanceof RegExp
1000-
? pattern.test(id)
1001-
: id.includes(`/node_modules/${pattern}/`),
999+
debug(
1000+
`internal client reference created through a package imported in '${this.environment.name}' environment: ${id}`,
10021001
)
1003-
if (!ignored) {
1004-
this.warn(
1005-
`[vite-rsc] detected an internal client boundary created by a package imported on rsc environment`,
1006-
)
1007-
}
10081002
id = cleanUrl(id)
10091003
warnInoncistentClientOptimization(this, id)
10101004
importId = `/@id/__x00__virtual:vite-rsc/client-in-server-package-proxy/${encodeURIComponent(id)}`
@@ -1233,13 +1227,15 @@ function vitePluginDefineEncryptionKey(
12331227
function vitePluginUseServer(
12341228
useServerPluginOptions: Pick<
12351229
RscPluginOptions,
1236-
'ignoredPackageWarnings' | 'enableActionEncryption' | 'environment'
1230+
'enableActionEncryption' | 'environment'
12371231
>,
12381232
): Plugin[] {
12391233
const serverEnvironmentName = useServerPluginOptions.environment?.rsc ?? 'rsc'
12401234
const browserEnvironmentName =
12411235
useServerPluginOptions.environment?.browser ?? 'client'
12421236

1237+
const debug = createDebug('vite-rsc:use-server')
1238+
12431239
return [
12441240
{
12451241
name: 'rsc:use-server',
@@ -1257,6 +1253,9 @@ function vitePluginUseServer(
12571253
// similar situation as `use client` (see `virtual:client-in-server-package-proxy`)
12581254
// but module runner has additional resolution step and it's not strict about
12591255
// 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+
)
12601259
id = cleanUrl(id)
12611260
}
12621261
if (config.command === 'build') {

0 commit comments

Comments
 (0)