File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
packages/app/src/sandbox/eval/transpilers/babel/worker Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ import {
1919} from './get-prefixed-name' ;
2020
2121let fsInitialized = false ;
22+ let fsLoading = false ;
2223let lastConfig = null ;
2324
2425async function initializeBrowserFS ( ) {
26+ fsLoading = true ;
2527 return new Promise ( resolve => {
2628 BrowserFS . configure (
2729 {
@@ -36,6 +38,7 @@ async function initializeBrowserFS() {
3638 console . error ( e ) ;
3739 return ;
3840 }
41+ fsLoading = false ;
3942 fsInitialized = true ;
4043 resolve ( ) ;
4144 // BrowserFS is initialized and ready-to-use!
@@ -46,6 +49,12 @@ async function initializeBrowserFS() {
4649
4750async function waitForFs ( ) {
4851 if ( ! fsInitialized ) {
52+ if ( ! fsLoading ) {
53+ // We only load the fs when it's needed. The FS is expensive, as we sync all
54+ // files of the main thread to the worker. We only want to do this if it's really
55+ // needed.
56+ await initializeBrowserFS ( ) ;
57+ }
4958 while ( ! fsInitialized ) {
5059 await delay ( 50 ) ; // eslint-disable-line
5160 }
@@ -192,11 +201,6 @@ self.addEventListener('message', async event => {
192201 return ;
193202 }
194203
195- if ( event . data . type === 'initialize-fs' ) {
196- initializeBrowserFS ( ) ;
197- return ;
198- }
199-
200204 if ( event . data . type === 'get-babel-context' ) {
201205 const transpilerOptions = event . data . babelTranspilerOptions ;
202206 loadCustomTranspiler (
You can’t perform that action at this time.
0 commit comments