File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
packages/app/src/sandbox/eval/transpilers/babel/worker Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,34 @@ export async function downloadPath(absolutePath) {
8383
8484 const fs = BrowserFS . BFSRequire ( 'fs' ) ;
8585
86- mkDirByPathSync ( BrowserFS . BFSRequire ( 'path' ) . dirname ( r . path ) ) ;
86+ let existingFile ;
87+
88+ try {
89+ existingFile = fs . readFileSync ( r . path ) ;
90+ } catch ( e ) { }
91+
92+ if ( existingFile ) {
93+ try {
94+ // Maybe there was a redirect from package.json. Manager only returns the redirect,
95+ // if the babel worker doesn't have the package.json it enters an infinite loop.
96+ const r2 = await resolveAsyncModule (
97+ path . join ( absolutePath , 'package.json' ) ,
98+ { }
99+ ) ;
100+ if ( r2 ) {
101+ mkDirByPathSync ( path . dirname ( r2 . path ) ) ;
102+
103+ fs . writeFileSync ( r2 . path , r2 . code ) ;
104+ }
105+ } catch ( e ) { }
106+
107+ return Promise . resolve ( {
108+ code : existingFile ,
109+ path : r . path ,
110+ } ) ;
111+ }
112+
113+ mkDirByPathSync ( path . dirname ( r . path ) ) ;
87114
88115 fs . writeFileSync ( r . path , r . code ) ;
89116
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ export default function evaluate(
2828 return ( ) => { } ;
2929 }
3030
31+ if ( requirePath === 'stream' ) {
32+ return { } ;
33+ }
34+
3135 if ( requirePath === 'constants' ) {
3236 return { } ;
3337 }
@@ -59,15 +63,15 @@ export default function evaluate(
5963 availablePlugins [ requirePath ] ||
6064 availablePlugins [ requirePath . replace ( 'babel-plugin-' , '' ) ] ||
6165 availablePlugins [ requirePath . replace ( '@babel/plugin-' , '' ) ] ;
62- if ( plugin ) {
66+ if ( plugin && requirePath !== 'react' ) {
6367 return plugin ;
6468 }
6569
6670 const preset =
6771 availablePresets [ requirePath ] ||
6872 availablePresets [ requirePath . replace ( 'babel-preset-' , '' ) ] ||
6973 availablePresets [ requirePath . replace ( '@babel/preset-' , '' ) ] ;
70- if ( preset ) {
74+ if ( preset && requirePath !== 'react' ) {
7175 return preset ;
7276 }
7377
You can’t perform that action at this time.
0 commit comments