-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using nodejs worker for better perf on largeeeeeee app
- Loading branch information
1 parent
05432de
commit 5ef44ef
Showing
13 changed files
with
167 additions
and
75 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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,31 @@ | ||
import path from 'path' | ||
import getNodeCode from './getNodeCode' | ||
import updateImports from '../updateImports' | ||
import { MakeOutputOptions } from './makeOutputFile' | ||
|
||
export default async function ( | ||
filePath: string, | ||
fileContent: string, | ||
options: MakeOutputOptions | ||
) { | ||
const [tempFilePath, newFileContent] = await updateImports( | ||
options.tempOutDir, | ||
filePath, | ||
fileContent, | ||
options.moduleType, | ||
options.tsConfig?.baseUrl, | ||
options.tsConfig?.paths | ||
) | ||
|
||
const newFilePath = path.join( | ||
options.finalOutDir, | ||
path.relative(options.tempOutDir, tempFilePath) | ||
) | ||
|
||
const output = | ||
options.pushNodeCode && options.moduleType === 'cjs' | ||
? getNodeCode(newFilePath, newFileContent) + newFileContent | ||
: newFileContent | ||
|
||
return [newFilePath, output] as const | ||
} |
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,17 @@ | ||
import { parentPort } from 'worker_threads' | ||
import generateOutput from './generateOutput' | ||
import { MakeOutputOptions } from './makeOutputFile' | ||
|
||
parentPort!.on('message', (options: WorkerMessage) => { | ||
generateOutput(options.filePath, options.fileContent, options.options).then( | ||
(data) => { | ||
parentPort!.postMessage(data) | ||
} | ||
) | ||
}) | ||
|
||
export type WorkerMessage = { | ||
filePath: string | ||
fileContent: string | ||
options: MakeOutputOptions | ||
} |
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
Oops, something went wrong.