forked from swc-project/cli
-
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.
Use workers to process files in parallel (swc-project#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 <wburgin@palantir.com>
- Loading branch information
Showing
9 changed files
with
155 additions
and
68 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