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', () => {
5858 )
5959 } )
6060
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+ } )
6270
6371 test ( 'show warning' , async ( { page } ) => {
6472 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 / ,
6775 )
6876 } )
6977} )
Original file line number Diff line number Diff line change @@ -45,13 +45,11 @@ export default defineConfig({
4545 } ,
4646 ssr : {
4747 optimizeDeps : {
48- include : [ 'react-router > cookie' , 'react-router > set-cookie-parser' ] ,
4948 exclude : [ 'react-router' ] ,
5049 } ,
5150 } ,
5251 rsc : {
5352 optimizeDeps : {
54- include : [ 'react-router > cookie' , 'react-router > set-cookie-parser' ] ,
5553 exclude : [ 'react-router' ] ,
5654 } ,
5755 } ,
Original file line number Diff line number Diff line change @@ -5,10 +5,12 @@ import path from 'node:path'
55import fs from 'node:fs'
66import * as esModuleLexer from 'es-module-lexer'
77import { transformCjsToEsm } from '../transforms/cjs'
8+ import { createDebug } from '@hiogawa/utils'
9+
10+ const debug = createDebug ( 'vite-rsc:cjs' )
811
912export 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 > ( )
1214
1315 return [
1416 {
@@ -43,9 +45,8 @@ export function cjsModuleRunnerPlugin(): Plugin[] {
4345 // warning once per package
4446 const packageKey = extractPackageKey ( id )
4547 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 } ` ,
4950 )
5051 warnedPackages . add ( packageKey )
5152 }
You can’t perform that action at this time.
0 commit comments