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.
- Loading branch information
Walker Burgin
committed
Jan 23, 2024
1 parent
5fcc7f5
commit e50e2cf
Showing
5 changed files
with
118 additions
and
56 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,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