File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -853,20 +853,17 @@ function detectNonOptimizedCjsPlugin(): Plugin {
853853 ( code . includes ( 'exports' ) || code . includes ( 'require' ) )
854854 ) {
855855 id = parseIdQuery ( id ) . filename
856- let isCjs = id . endsWith ( '.cjs' )
857- if ( ! isCjs && id . endsWith ( '.js' ) ) {
858- // check closest package.json
856+ let isEsm = id . endsWith ( '.mjs' )
857+ if ( id . endsWith ( '.js' ) ) {
859858 const pkgJsonPath = await findClosestPkgJsonPath ( path . dirname ( id ) )
860859 if ( pkgJsonPath ) {
861860 const pkgJson = JSON . parse (
862861 fs . readFileSync ( pkgJsonPath , 'utf-8' ) ,
863862 ) as { type ?: string }
864- isCjs = pkgJson . type !== 'module'
865- } else {
866- isCjs = true
863+ isEsm = pkgJson . type === 'module'
867864 }
868865 }
869- if ( isCjs ) {
866+ if ( ! isEsm ) {
870867 this . warn (
871868 `[vite-rsc] found non-optimized CJS dependency in '${ this . environment . name } ' environment. ` +
872869 `It is recommended to manually add the dependency to 'environments.${ this . environment . name } .optimizeDeps.include'.` ,
You can’t perform that action at this time.
0 commit comments