File tree Expand file tree Collapse file tree 1 file changed +13
-18
lines changed
packages/editor/src/lib/compile-worker Expand file tree Collapse file tree 1 file changed +13
-18
lines changed Original file line number Diff line number Diff line change @@ -40,26 +40,21 @@ addEventListener('message', async (event) => {
40
40
}
41
41
}
42
42
}
43
+
43
44
const { version } =
44
45
package_json ?? ( await fetch ( `${ svelte_url } /package.json` ) . then ( ( r ) => r . json ( ) ) ) ;
45
- if ( version . startsWith ( '4.' ) ) {
46
- // unpkg doesn't set the correct MIME type for .cjs files
47
- // https://github.com/mjackson/unpkg/issues/355
48
- const compiler =
49
- local_files ?. find ( ( file ) => file . name === 'package/compiler.cjs' ) ?. text ??
50
- ( await fetch ( `${ svelte_url } /compiler.cjs` ) . then ( ( r ) => r . text ( ) ) ) ;
51
- ( 0 , eval ) ( compiler + '\n//# sourceURL=compiler.cjs@' + version ) ;
52
- } else if ( version . startsWith ( '3.' ) ) {
53
- const compiler =
54
- local_files ?. find ( ( file ) => file . name === 'package/compiler.js' ) ?. text ??
55
- ( await fetch ( `${ svelte_url } /compiler.js` ) . then ( ( r ) => r . text ( ) ) ) ;
56
- ( 0 , eval ) ( compiler + '\n//# sourceURL=compiler.js@' + version ) ;
57
- } else {
58
- const compiler =
59
- local_files ?. find ( ( file ) => file . name === 'package/compiler/index.js' ) ?. text ??
60
- ( await fetch ( `${ svelte_url } /compiler/index.js` ) . then ( ( r ) => r . text ( ) ) ) ;
61
- ( 0 , eval ) ( compiler + '\n//# sourceURL=compiler/index.js@' + version ) ;
62
- }
46
+
47
+ const compiler_file = version . startsWith ( '3.' )
48
+ ? 'compiler.js'
49
+ : version . startsWith ( '4.' )
50
+ ? 'compiler.cjs'
51
+ : 'compiler/index.js' ;
52
+
53
+ const compiler_text = local_files
54
+ ? local_files . find ( ( file ) => file . name === `package/${ compiler_file } ` ) ! . text
55
+ : await fetch ( `${ svelte_url } /${ compiler_file } ` ) . then ( ( r ) => r . text ( ) ) ;
56
+
57
+ ( 0 , eval ) ( compiler_text + `\n//# sourceURL=${ compiler_file } @` + version ) ;
63
58
64
59
fulfil_ready ( ) ;
65
60
}
You can’t perform that action at this time.
0 commit comments