Skip to content

Commit

Permalink
Allow pointing to a custom swcrc file
Browse files Browse the repository at this point in the history
  • Loading branch information
airhorns committed Nov 15, 2024
1 parent 7f398a1 commit 550e710
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Options as SwcOptions } from "@swc/core";

type SwcConfig = ".swcrc" | SwcOptions;
export type SwcConfig = string | SwcOptions;

export interface RunOptions {
argv: string[];
Expand Down
9 changes: 6 additions & 3 deletions src/SwcCompiler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Config, Options } from "@swc/core";
import writeFileAtomic from "write-file-atomic";
import { transformFile } from "@swc/core";
import findRoot from "find-root";
import * as fs from "fs/promises";
import globby from "globby";
import path from "path";
import writeFileAtomic from "write-file-atomic";
import type { Compiler } from "./Compiler";
import type { ProjectConfig } from "./Options";
import { log, projectConfig } from "./utils";
Expand Down Expand Up @@ -129,8 +129,11 @@ export class SwcCompiler implements Compiler {

let swcConfig: Options;

if (!config.swc || config.swc === ".swcrc") {
swcConfig = { swcrc: true };
if (!config.swc || typeof config.swc === "string") {
swcConfig = {
swcrc: true,
configFile: config.swc && config.swc !== ".swcrc" ? path.resolve(root, config.swc) : undefined,
};
} else if (config.swc === undefined) {
swcConfig = SWC_DEFAULTS;
} else {
Expand Down

0 comments on commit 550e710

Please sign in to comment.