This repository has been archived by the owner on Jan 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use workers to process files in parallel (#280)
* Bump @types/node to 20.x.x and increase 'engines' check * Add dependency on piscina * Add a worker pool --------- Co-authored-by: Walker Burgin <[email protected]>
- Loading branch information
1 parent
908d0a1
commit 7d9a493
Showing
9 changed files
with
159 additions
and
64 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
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,28 @@ | ||
import slash from "slash"; | ||
import { dirname, relative } from "path"; | ||
import { CompileStatus } from "./constants"; | ||
import { compile, getDest } from "./util"; | ||
import { outputResult } from "./compile"; | ||
|
||
import type { Options } from "@swc/core"; | ||
|
||
export default async function handleCompile(opts: { | ||
filename: string; | ||
outDir: string; | ||
sync: boolean; | ||
swcOptions: Options; | ||
}) { | ||
const dest = getDest(opts.filename, opts.outDir, ".js"); | ||
const sourceFileName = slash(relative(dirname(dest), opts.filename)); | ||
|
||
const options = { ...opts.swcOptions, sourceFileName }; | ||
|
||
const result = await compile(opts.filename, options, opts.sync, dest); | ||
|
||
if (result) { | ||
await outputResult(result, opts.filename, dest, options); | ||
return CompileStatus.Compiled; | ||
} else { | ||
return CompileStatus.Omitted; | ||
} | ||
} |
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