-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: - Added worker to handle compilation
- Loading branch information
1 parent
fab0d77
commit 9e8f204
Showing
8 changed files
with
113 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
fork, ChildProcess, | ||
} from 'child_process'; | ||
import path from 'path'; | ||
|
||
import { | ||
CompileTypesParams, CompileTypesResult, | ||
} from './compileTypes'; | ||
|
||
let currentWorker: ChildProcess | null = null; | ||
|
||
export function compileTypesAsync(params: CompileTypesParams): Promise<CompileTypesResult> { | ||
return new Promise((resolve, reject) => { | ||
if (currentWorker) { | ||
currentWorker.kill(); | ||
} | ||
|
||
const workerPath = path.join(__dirname, 'compileWorker.js'); | ||
currentWorker = fork(workerPath); | ||
|
||
currentWorker.on('message', (result: CompileTypesResult) => { | ||
resolve(result); | ||
currentWorker?.kill(); | ||
currentWorker = null; | ||
}); | ||
|
||
currentWorker.on('error', error => { | ||
reject(error); | ||
currentWorker?.kill(); | ||
currentWorker = null; | ||
}); | ||
|
||
currentWorker.on('exit', code => { | ||
if (code !== 0 && code !== null) { | ||
reject(new Error(`Worker process exited with code ${code}`)); | ||
} | ||
currentWorker = null; | ||
}); | ||
|
||
currentWorker.send(params); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { | ||
compileTypes, CompileTypesParams, | ||
} from './compileTypes'; | ||
|
||
process.on('message', (message: CompileTypesParams) => { | ||
process.send?.(compileTypes(message)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './compileTypes'; | ||
export * from './compileTypesAsync'; | ||
export * from './rewritePathsWithExposedFederatedModules'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters