File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/plugin-rsc/src/plugins Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,7 @@ export function cjsModuleRunnerPlugin(): Plugin[] {
19
19
applyToEnvironment : ( env ) => env . config . dev . moduleRunnerTransform ,
20
20
async transform ( code , id ) {
21
21
if (
22
- ( id . includes ( '/node_modules/' ) ||
23
- // it's not inside node_modules when developing rsc plugin inside pnpm workspace.
24
- id . includes (
25
- '/packages/plugin-rsc/dist/vendor/react-server-dom/' ,
26
- ) ) &&
22
+ ( id . includes ( '/node_modules/' ) || isDevCjs ( id ) ) &&
27
23
! id . startsWith ( this . environment . config . cacheDir ) &&
28
24
/ \b ( r e q u i r e | e x p o r t s ) \b / . test ( code )
29
25
) {
@@ -76,7 +72,7 @@ export default module.exports;
76
72
}
77
73
78
74
function extractPackageKey ( id : string ) : string {
79
- if ( id . includes ( '/packages/plugin-rsc/dist/vendor/react-server-dom/' ) ) {
75
+ if ( isDevCjs ( id ) ) {
80
76
return '@vitejs/plugin-rsc'
81
77
}
82
78
@@ -97,3 +93,11 @@ function extractPackageKey(id: string): string {
97
93
}
98
94
return id
99
95
}
96
+
97
+ // this is needed only when developing package itself within pnpm workspace
98
+ function isDevCjs ( id : string ) : boolean {
99
+ return (
100
+ ! import . meta. url . includes ( '/node_modules/' ) &&
101
+ id . includes ( '/vendor/react-server-dom/' )
102
+ )
103
+ }
You can’t perform that action at this time.
0 commit comments