diff --git a/packages/cli/commands/build.ts b/packages/cli/commands/build.ts index 657900f..a9f7457 100644 --- a/packages/cli/commands/build.ts +++ b/packages/cli/commands/build.ts @@ -43,6 +43,10 @@ export class BuildCommand { await intentCliFileTransformer.load(TS_CONFIG); const SWC_OPTIONS = defaultSwcOptionsFactory(TS_CONFIG, INTENT_CONFIG); - await this.swcFileTransformer.handle(TS_CONFIG, INTENT_CONFIG, SWC_OPTIONS); + await this.swcFileTransformer.handle( + tsConfigPath, + INTENT_CONFIG, + SWC_OPTIONS + ); } } diff --git a/packages/cli/commands/start-server.ts b/packages/cli/commands/start-server.ts index 3dffe5c..fcef884 100644 --- a/packages/cli/commands/start-server.ts +++ b/packages/cli/commands/start-server.ts @@ -60,7 +60,7 @@ export class StartServerCommand { const onSuccessHook = this.createOnSuccessHook(INTENT_CONFIG); const swcOnUpdateHook = await this.swcFileTransformer.handle( - TS_CONFIG, + tsConfigPath, INTENT_CONFIG, SWC_OPTIONS ); diff --git a/packages/cli/lib/dev-server/swc/swc-file-transformer.ts b/packages/cli/lib/dev-server/swc/swc-file-transformer.ts index 2a07969..4f8864c 100644 --- a/packages/cli/lib/dev-server/swc/swc-file-transformer.ts +++ b/packages/cli/lib/dev-server/swc/swc-file-transformer.ts @@ -7,18 +7,23 @@ import { ParsedCommandLine } from "typescript"; import { Output } from "@swc/core"; import { transformFile } from "@swc/core"; import { IntentConfiguration } from "../../configuration/interface.js"; +import { TsConfigLoader } from "../typescript/tsconfig-loader.js"; const { mkdirSync, writeFileSync } = fs; export class SwcFileTransformer { + protected readonly tsConfigLoader = new TsConfigLoader(); + async handle( - TS_CONFIG: ParsedCommandLine, + tsConfigPath: string, INTENT_CONFIG: IntentConfiguration, options: ReturnType ): Promise<() => Promise> { + const TS_CONFIG = this.tsConfigLoader.load(tsConfigPath); await this.transformFiles(TS_CONFIG, options, INTENT_CONFIG); const onUpdate = () => { + const TS_CONFIG = this.tsConfigLoader.load(tsConfigPath); return this.transformFiles(TS_CONFIG, options, INTENT_CONFIG); }; @@ -34,7 +39,6 @@ export class SwcFileTransformer { const { fileNames = [] } = TS_CONFIG; const isWindows = process.platform === "win32"; const fileTransformationPromises = []; - for (const filePath of fileNames) { const fileTransformerPromise = (resolve: Function) => transformFile(filePath, { ...options, filename: filePath }) diff --git a/packages/cli/package.json b/packages/cli/package.json index a485993..013a51c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@intentjs/cli", - "version": "0.0.21", + "version": "0.0.22", "description": "Helper commands for building Intent application.", "repository": { "type": "git",