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[] {
1919 applyToEnvironment : ( env ) => env . config . dev . moduleRunnerTransform ,
2020 async transform ( code , id ) {
2121 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 ) ) &&
2723 ! id . startsWith ( this . environment . config . cacheDir ) &&
2824 / \b ( r e q u i r e | e x p o r t s ) \b / . test ( code )
2925 ) {
@@ -76,7 +72,7 @@ export default module.exports;
7672}
7773
7874function extractPackageKey ( id : string ) : string {
79- if ( id . includes ( '/packages/plugin-rsc/dist/vendor/react-server-dom/' ) ) {
75+ if ( isDevCjs ( id ) ) {
8076 return '@vitejs/plugin-rsc'
8177 }
8278
@@ -97,3 +93,11 @@ function extractPackageKey(id: string): string {
9793 }
9894 return id
9995}
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