File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -58,12 +58,20 @@ test.describe('dev-non-optimized-cjs', () => {
58
58
)
59
59
} )
60
60
61
- const f = useFixture ( { root : 'examples/basic' , mode : 'dev' } )
61
+ const f = useFixture ( {
62
+ root : 'examples/basic' ,
63
+ mode : 'dev' ,
64
+ cliOptions : {
65
+ env : {
66
+ DEBUG : 'vite-rsc:cjs' ,
67
+ } ,
68
+ } ,
69
+ } )
62
70
63
71
test ( 'show warning' , async ( { page } ) => {
64
72
await page . goto ( f . url ( ) )
65
- expect ( f . proc ( ) . stderr ( ) ) . toContain (
66
- `Found non-optimized CJS dependency in 'ssr' environment.` ,
73
+ expect ( f . proc ( ) . stderr ( ) ) . toMatch (
74
+ / n o n - o p t i m i z e d C J S d e p e n d e n c y i n ' s s r ' e n v i r o n m e n t .* @ v i t e j s \/ t e s t - d e p - c j s \/ i n d e x . j s / ,
67
75
)
68
76
} )
69
77
} )
Original file line number Diff line number Diff line change @@ -45,13 +45,11 @@ export default defineConfig({
45
45
} ,
46
46
ssr : {
47
47
optimizeDeps : {
48
- include : [ 'react-router > cookie' , 'react-router > set-cookie-parser' ] ,
49
48
exclude : [ 'react-router' ] ,
50
49
} ,
51
50
} ,
52
51
rsc : {
53
52
optimizeDeps : {
54
- include : [ 'react-router > cookie' , 'react-router > set-cookie-parser' ] ,
55
53
exclude : [ 'react-router' ] ,
56
54
} ,
57
55
} ,
Original file line number Diff line number Diff line change @@ -5,10 +5,12 @@ import path from 'node:path'
5
5
import fs from 'node:fs'
6
6
import * as esModuleLexer from 'es-module-lexer'
7
7
import { transformCjsToEsm } from '../transforms/cjs'
8
+ import { createDebug } from '@hiogawa/utils'
9
+
10
+ const debug = createDebug ( 'vite-rsc:cjs' )
8
11
9
12
export function cjsModuleRunnerPlugin ( ) : Plugin [ ] {
10
- // use-sync-external-store is known to work fine so don't show warning
11
- const warnedPackages = new Set < string > ( [ 'use-sync-external-store' ] )
13
+ const warnedPackages = new Set < string > ( )
12
14
13
15
return [
14
16
{
@@ -43,9 +45,8 @@ export function cjsModuleRunnerPlugin(): Plugin[] {
43
45
// warning once per package
44
46
const packageKey = extractPackageKey ( id )
45
47
if ( ! warnedPackages . has ( packageKey ) ) {
46
- this . warn (
47
- `Found non-optimized CJS dependency in '${ this . environment . name } ' environment. ` +
48
- `It is recommended to add the dependency to 'environments.${ this . environment . name } .optimizeDeps.include'.` ,
48
+ debug (
49
+ `non-optimized CJS dependency in '${ this . environment . name } ' environment: ${ id } ` ,
49
50
)
50
51
warnedPackages . add ( packageKey )
51
52
}
You can’t perform that action at this time.
0 commit comments