@@ -1924,6 +1924,10 @@ export function rewriteStandaloneProject(
19241924 } ) ;
19251925 }
19261926
1927+ if ( packageManager === PackageManager . pnpm ) {
1928+ ensurePnpmWorkspaceExoticSubdepsSetting ( projectPath ) ;
1929+ }
1930+
19271931 if ( packageManager === PackageManager . yarn ) {
19281932 rewriteYarnrcYml ( projectPath , usesVitest ) ;
19291933 } else if ( packageManager === PackageManager . bun ) {
@@ -2188,6 +2192,8 @@ function rewritePnpmWorkspaceYaml(
21882192 const managed = managedOverridePackages ( usesVitest ) ;
21892193
21902194 editYamlFile ( pnpmWorkspaceYamlPath , ( doc ) => {
2195+ ensurePnpmExoticSubdepsSetting ( doc ) ;
2196+
21912197 // catalog
21922198 rewriteCatalog ( doc , usesVitest ) ;
21932199 if ( pnpmMajorVersion !== undefined ) {
@@ -3802,6 +3808,50 @@ function readPnpmWorkspacePeerDependencyRules(
38023808 return doc ?. peerDependencyRules ;
38033809}
38043810
3811+ function forceOverrideUsesExoticPnpmSpec ( ) : boolean {
3812+ if ( ! isForceOverrideMode ( ) ) {
3813+ return false ;
3814+ }
3815+ return [ VITE_PLUS_VERSION , ...Object . values ( VITE_PLUS_OVERRIDE_PACKAGES ) ] . some ( ( spec ) =>
3816+ / ^ (?: f i l e | h t t p s ? ) : / . test ( spec ) ,
3817+ ) ;
3818+ }
3819+
3820+ function pnpmWorkspaceExoticSubdepsSettingSatisfied ( projectPath : string ) : boolean {
3821+ if ( ! forceOverrideUsesExoticPnpmSpec ( ) ) {
3822+ return true ;
3823+ }
3824+ const pnpmWorkspaceYamlPath = path . join ( projectPath , 'pnpm-workspace.yaml' ) ;
3825+ if ( ! fs . existsSync ( pnpmWorkspaceYamlPath ) ) {
3826+ return false ;
3827+ }
3828+ const doc = readYamlFile ( pnpmWorkspaceYamlPath ) as { blockExoticSubdeps ?: boolean } | null ;
3829+ return doc ?. blockExoticSubdeps === false ;
3830+ }
3831+
3832+ function ensurePnpmExoticSubdepsSetting ( doc : YamlDocument ) : boolean {
3833+ if ( ! forceOverrideUsesExoticPnpmSpec ( ) || doc . get ( 'blockExoticSubdeps' ) === false ) {
3834+ return false ;
3835+ }
3836+ doc . set ( 'blockExoticSubdeps' , false ) ;
3837+ return true ;
3838+ }
3839+
3840+ function ensurePnpmWorkspaceExoticSubdepsSetting ( projectPath : string ) : boolean {
3841+ if ( ! forceOverrideUsesExoticPnpmSpec ( ) ) {
3842+ return false ;
3843+ }
3844+ const pnpmWorkspaceYamlPath = path . join ( projectPath , 'pnpm-workspace.yaml' ) ;
3845+ if ( ! fs . existsSync ( pnpmWorkspaceYamlPath ) ) {
3846+ fs . writeFileSync ( pnpmWorkspaceYamlPath , '' ) ;
3847+ }
3848+ let changed = false ;
3849+ editYamlFile ( pnpmWorkspaceYamlPath , ( doc ) => {
3850+ changed = ensurePnpmExoticSubdepsSetting ( doc ) ;
3851+ } ) ;
3852+ return changed ;
3853+ }
3854+
38053855function yarnrcSatisfiesVitePlus ( projectPath : string , usesVitest : boolean ) : boolean {
38063856 const yarnrcYmlPath = path . join ( projectPath , '.yarnrc.yml' ) ;
38073857 if ( ! fs . existsSync ( yarnrcYmlPath ) ) {
@@ -4120,6 +4170,9 @@ export function detectVitePlusBootstrapPending(
41204170 ) ;
41214171 }
41224172 if ( packageManager === PackageManager . pnpm ) {
4173+ if ( ! pnpmWorkspaceExoticSubdepsSettingSatisfied ( projectPath ) ) {
4174+ return true ;
4175+ }
41234176 if ( pnpmConfigLivesInPackageJson ( pkg , projectPath ) ) {
41244177 return (
41254178 vitePlusDependencyNeedsConcreteVersion ( pkg ) ||
@@ -4390,6 +4443,7 @@ export function ensureVitePlusBootstrap(
43904443 const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver ( projectPath ) ;
43914444 if (
43924445 result . packageJson ||
4446+ ! pnpmWorkspaceExoticSubdepsSettingSatisfied ( projectPath ) ||
43934447 defaultCatalogVitePlusDependencyPending ( pkg , catalogDependencyResolver ) ||
43944448 ! overridesSatisfyVitePlus (
43954449 readPnpmWorkspaceOverrides ( projectPath ) ,
@@ -4415,6 +4469,9 @@ export function ensureVitePlusBootstrap(
44154469 ? fs . readFileSync ( pnpmWorkspaceYamlPath , 'utf-8' )
44164470 : undefined ;
44174471 result . packageManagerConfig = before !== after ;
4472+ } else if ( ensurePnpmWorkspaceExoticSubdepsSetting ( projectPath ) ) {
4473+ ensurePnpmWorkspacePackages ( projectPath , workspaceInfo . workspacePatterns ) ;
4474+ result . packageManagerConfig = true ;
44184475 }
44194476 } else if ( workspaceInfo . packageManager === PackageManager . yarn ) {
44204477 const yarnrcYmlPath = path . join ( projectPath , '.yarnrc.yml' ) ;
0 commit comments