File tree Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Expand file tree Collapse file tree 4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export const ConfigSchema = DataType.RecordOf({
8080 base64 : OptionalField ( DataType . Boolean ) ,
8181 fetch : OptionalField ( DataType . Boolean ) ,
8282 WebSocket : OptionalField ( DataType . Boolean ) ,
83+ queueMicrotask : OptionalField ( DataType . Boolean ) ,
8384 node : OptionalField (
8485 DataType . RecordOf ( {
8586 path : OptionalField ( DataType . Boolean ) ,
Original file line number Diff line number Diff line change 1+ import { registerPolyfills } from "./shared/polyfill-global" ;
2+
3+ registerPolyfills ( "queueMicrotask" ) ( ( ) => {
4+ let onNextMicrotask : Array < ( ) => void > | undefined ;
5+
6+ function queueMicrotask ( task : ( ) => void ) {
7+ if ( onNextMicrotask ) {
8+ onNextMicrotask . push ( task ) ;
9+ }
10+
11+ onNextMicrotask = [ task ] ;
12+
13+ imports . mainloop . idle_add ( ( ) => {
14+ if ( ! onNextMicrotask ) return ;
15+ const tasks = onNextMicrotask ;
16+ onNextMicrotask = undefined ;
17+ for ( const task of tasks ! ) {
18+ try {
19+ task ( ) ;
20+ } catch ( e ) {
21+ console . error ( e ) ;
22+ }
23+ }
24+ } , - 2000 ) ;
25+ }
26+
27+ return { queueMicrotask } ;
28+ } ) ;
Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ export const getGlobalPolyfills = (program: Program): Promise<Polyfills> => {
5757 polyFilepaths . push ( "./polyfills/esm/websocket.mjs" ) ;
5858 }
5959
60+ if ( polyfills ?. queueMicrotask ) {
61+ polyFilepaths . push ( "./polyfills/esm/queue-microtask.mjs" ) ;
62+ }
63+
6064 const customPolyfills : string [ ] = [ ] ;
6165
6266 if ( program . config . customPolyfills ) {
Original file line number Diff line number Diff line change @@ -102,15 +102,12 @@ export const parseEnvVarConfig = (program: Program) => {
102102 }
103103
104104 // Add env file vars
105- const cwdFiles = fs . readdirSync ( program . cwd ) ;
106105 const envFileName = envVars ?. envFilePath ?? ".env" ;
107106 const failIfNoEnvFile = envVars ?. envFilePath !== undefined ;
108107
109- if ( cwdFiles . includes ( envFileName ) ) {
110- const envFileData = fs . readFileSync (
111- path . resolve ( program . cwd , envFileName ) ,
112- "utf-8" ,
113- ) ;
108+ const envFilepath = path . resolve ( program . cwd , envFileName ) ;
109+ if ( fs . existsSync ( envFilepath ) ) {
110+ const envFileData = fs . readFileSync ( envFilepath , "utf-8" ) ;
114111
115112 for ( const envVarEntry of parseDotEnv ( envFileData ) ) {
116113 if ( vars . some ( ( [ k ] ) => k === envVarEntry [ 0 ] ) ) {
You can’t perform that action at this time.
0 commit comments