diff --git a/packages/compiler/src/CompilerArguments.ts b/packages/compiler/src/CompilerArguments.ts index eb717861..f6d13e24 100644 --- a/packages/compiler/src/CompilerArguments.ts +++ b/packages/compiler/src/CompilerArguments.ts @@ -6,7 +6,7 @@ import { CompilerOptions } from "@quatico/websmith-core"; * Licensed under the MIT License. See LICENSE in the project root for license information. * --------------------------------------------------------------------------------------------- */ -export interface CompilerArguments extends Partial> { +export interface CompilerArguments extends Partial> { targets?: string; files?: string[]; project?: string; diff --git a/packages/compiler/src/command.spec.ts b/packages/compiler/src/command.spec.ts index 21c21701..1f76e6a0 100644 --- a/packages/compiler/src/command.spec.ts +++ b/packages/compiler/src/command.spec.ts @@ -66,7 +66,7 @@ describe("addCompileCommand", () => { outDir: "/lib", sourceMap: false, }; - expect(actual.project).toEqual(compilerOptions); + expect(actual.tsConfig).toEqual(compilerOptions); expect({ wildcardDirectories: {}, ...actual.cliArgs }).toEqual({ options: compilerOptions, @@ -116,7 +116,7 @@ describe("addCompileCommand", () => { addCompileCommand(new Command(), target).parse(["--project", "expected/tsconfig.json"], { from: "user" }); - expect(target.getOptions().project.configFilePath).toEqual(expect.stringContaining("/expected/tsconfig.json")); + expect(target.getOptions().tsConfig.configFilePath).toEqual(expect.stringContaining("/expected/tsconfig.json")); }); it("should yield sourceMap option w/ --sourceMap cli argument", () => { diff --git a/packages/compiler/src/options.spec.ts b/packages/compiler/src/options.spec.ts index 2b162363..195ae369 100644 --- a/packages/compiler/src/options.spec.ts +++ b/packages/compiler/src/options.spec.ts @@ -28,7 +28,7 @@ describe("createOptions", () => { }, }); - const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).project; + const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).tsConfig; expect(actual).toEqual({ configFilePath: "/expected/tsconfig.json", @@ -109,7 +109,7 @@ describe("createOptions", () => { addons: ["one", "two"], addonsDir: "/expected", }, - project: { + tsConfig: { configFilePath: "/tsconfig.json", outDir: "/lib", }, diff --git a/packages/compiler/src/options.ts b/packages/compiler/src/options.ts index 5fe1e5e7..5b23f755 100644 --- a/packages/compiler/src/options.ts +++ b/packages/compiler/src/options.ts @@ -53,7 +53,7 @@ export const createOptions = (args: CompilerArguments, reporter = new NoReporter // TODO: Do we need lib files, or is injecting them into the system sufficient? // files?: Record; cliArgs: tsConfig, - project: tsConfig.options, + tsConfig: tsConfig.options, reporter, sourceMap: args.sourceMap ?? DEFAULTS.sourceMap, targets: resolveTargets(targets, compilationConfig, reporter), diff --git a/packages/core/src/compiler/Compiler.e2e.spec.ts b/packages/core/src/compiler/Compiler.e2e.spec.ts index 7db37499..1e4bec20 100644 --- a/packages/core/src/compiler/Compiler.e2e.spec.ts +++ b/packages/core/src/compiler/Compiler.e2e.spec.ts @@ -11,7 +11,7 @@ describe("end-2-end compile", () => { const actual = new Compiler( compileOptions(target, { - project: { outDir: "./bin" }, + tsConfig: { outDir: "./bin" }, }), target ).compile(); diff --git a/packages/core/src/compiler/Compiler.spec.ts b/packages/core/src/compiler/Compiler.spec.ts index 4d62bc8a..f21b4ce7 100644 --- a/packages/core/src/compiler/Compiler.spec.ts +++ b/packages/core/src/compiler/Compiler.spec.ts @@ -60,7 +60,7 @@ describe("getSystem", () => { describe("setOptions", () => { it("replaces compiler options", () => { const expected = { - project: { + tsConfig: { react: 1, }, } as unknown as CompilerOptions; @@ -78,7 +78,7 @@ describe("setOptions", () => { }).getSourceFile("src/target.ts"); new CompilerTestClass( - compileOptions(target, { project: { outDir: "/expected" }, cliArgs: { fileNames: [entry!.fileName] } }), + compileOptions(target, { tsConfig: { outDir: "/expected" }, cliArgs: { fileNames: [entry!.fileName] } }), target ).watch(); @@ -183,7 +183,7 @@ describe("compile", () => { sourceMap: false, transpileOnly: false, watch: false, - project: { + tsConfig: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.Latest, configFilePath: "./tsconfig.json", @@ -212,7 +212,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true }, + tsConfig: { declaration: true }, cliArgs: { fileNames: [entry!.fileName] }, }); @@ -235,7 +235,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true }, + tsConfig: { declaration: true }, cliArgs: { fileNames: [entry!.fileName] }, }); @@ -258,7 +258,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, sourceMap: false }, + tsConfig: { declaration: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, transpileOnly: true, }); @@ -279,7 +279,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true, declarationMap: false, sourceMap: false }, + tsConfig: { declaration: true, declarationMap: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, transpileOnly: true, @@ -301,7 +301,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true, declarationMap: true, sourceMap: false }, + tsConfig: { declaration: true, declarationMap: true, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, transpileOnly: true, @@ -323,7 +323,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, declarationMap: false, sourceMap: true }, + tsConfig: { declaration: false, declarationMap: false, sourceMap: true }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, transpileOnly: true, @@ -348,7 +348,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, sourceMap: false }, + tsConfig: { declaration: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, }); @@ -368,7 +368,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true, declarationMap: false, sourceMap: false }, + tsConfig: { declaration: true, declarationMap: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, }); @@ -393,7 +393,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: true, declarationMap: true, sourceMap: false }, + tsConfig: { declaration: true, declarationMap: true, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, }); @@ -421,7 +421,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, declarationMap: false, sourceMap: true }, + tsConfig: { declaration: false, declarationMap: false, sourceMap: true }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, }); @@ -445,7 +445,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, declarationMap: false, sourceMap: false }, + tsConfig: { declaration: false, declarationMap: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, transpileOnly: true, @@ -467,7 +467,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("src/target.ts"); const target = compileOptions(fileSystem, { - project: { declaration: false, declarationMap: false, sourceMap: false }, + tsConfig: { declaration: false, declarationMap: false, sourceMap: false }, cliArgs: { fileNames: [entry!.fileName] }, sourceMap: true, }); @@ -486,7 +486,7 @@ describe("emitSourceFile", () => { "src/config.json": `{"name":"test"}`, }).getSourceFile("src/config.json"); const target = compileOptions(fileSystem, { - project: { + tsConfig: { declaration: false, declarationMap: false, sourceMap: false, @@ -509,7 +509,7 @@ describe("emitSourceFile", () => { "src/config.json": `{"name":"test"}`, }).getSourceFile("src/config.json"); const target = compileOptions(fileSystem, { - project: { + tsConfig: { declaration: false, declarationMap: false, sourceMap: false, @@ -538,7 +538,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("types/style.d.ts"); const target = compileOptions(fileSystem, { - project: { + tsConfig: { declaration: false, declarationMap: false, sourceMap: false, @@ -567,7 +567,7 @@ describe("emitSourceFile", () => { `, }).getSourceFile("types/style.d.ts"); const target = compileOptions(fileSystem, { - project: { + tsConfig: { declaration: false, declarationMap: false, sourceMap: false, @@ -675,7 +675,7 @@ describe("watch", () => { configFilePath: "/fake/websmith.config.json", targets: { "*": { writeFile: true } }, }, - project: { declaration: true, outDir: "/build" }, + tsConfig: { declaration: true, outDir: "/build" }, cliArgs: { fileNames: [entry!.fileName] }, watch: true, }); @@ -707,7 +707,7 @@ describe("watch", () => { configFilePath: "/fake/websmith.config.json", targets: { "*": { writeFile: true, options: { outDir: "/build" } } }, }, - project: { declaration: true }, + tsConfig: { declaration: true }, cliArgs: { options: { outDir: "/build" }, fileNames: [entry!.fileName] }, watch: true, }); @@ -742,7 +742,7 @@ describe("watch", () => { target2: { writeFile: true, options: { outDir: "/target2", declaration: false } }, }, }, - project: { declaration: true }, + tsConfig: { declaration: true }, targets: ["target1", "target2"], cliArgs: { options: { outDir: "/build" }, fileNames: [entry!.fileName] }, watch: true, @@ -786,7 +786,7 @@ describe("watch", () => { }, }, }, - project: { declaration: true }, + tsConfig: { declaration: true }, targets: ["target1", "target2"], cliArgs: { options: { outDir: "/build" }, fileNames: [entry!.fileName] }, transpileOnly: true, @@ -837,7 +837,7 @@ describe("watch", () => { target1: { writeFile: true, options: { outDir: "/target1" } }, }, }, - project: { declaration: true }, + tsConfig: { declaration: true }, targets: ["target1"], cliArgs: { options: { outDir: "/build" }, @@ -889,7 +889,7 @@ describe("watch", () => { target1: { writeFile: true, options: { outDir: "/target1" } }, }, }, - project: { declaration: true }, + tsConfig: { declaration: true }, targets: ["target1"], cliArgs: { options: { outDir: "/build" }, fileNames: [entry!.fileName] }, watch: true, diff --git a/packages/core/src/compiler/Compiler.ts b/packages/core/src/compiler/Compiler.ts index 7da0c39e..87bb392b 100644 --- a/packages/core/src/compiler/Compiler.ts +++ b/packages/core/src/compiler/Compiler.ts @@ -227,15 +227,15 @@ export class Compiler { target?: string, registerDependencyCallback?: (filePath: string) => void ): CompilationContext { - const { buildDir, config, configFile, project, cliArgs, watch } = compileOptions; + const { buildDir, config, configFile, tsConfig, cliArgs, watch } = compileOptions; const { options = {}, config: targetConfig } = getTargetConfig(target, config); return new CompilationContext({ buildDir, - project: { ...project, ...options }, + tsConfig: { ...tsConfig, ...options }, projectDir: dirname(configFile ?? cliArgs.raw?.configFilePath ?? this.system.getCurrentDirectory()), system: this.system, - program: ts.createProgram({ rootNames: this.getRootFiles(), options: project, host: createCompileHost(project) }), - cliArgs: { ...cliArgs, options: { ...project, ...options } }, + program: ts.createProgram({ rootNames: this.getRootFiles(), options: tsConfig, host: createCompileHost(tsConfig) }), + cliArgs: { ...cliArgs, options: { ...tsConfig, ...options } }, rootFiles: this.getRootFiles(), reporter: this.reporter, ...(!!targetConfig && { config: targetConfig }), @@ -344,7 +344,7 @@ export class Compiler { private transpileJson({ ctx, fileName, content }: CompilationFragment) { // JSON are only output by TypoScript if an outDir is provided, otherwise they are ignored. - if (this.options.project.outDir !== undefined) { + if (this.options.tsConfig.outDir !== undefined) { const fileNames = ts.getOutputFileNames(ctx.getConfig(), fileName, !this.system.useCaseSensitiveFileNames); return { outputFiles: [{ name: fileNames[0], text: content, writeByteOrderMark: false }], emitSkipped: false }; } diff --git a/packages/core/src/compiler/CompilerOptions.ts b/packages/core/src/compiler/CompilerOptions.ts index 5a13370f..667b2766 100644 --- a/packages/core/src/compiler/CompilerOptions.ts +++ b/packages/core/src/compiler/CompilerOptions.ts @@ -15,7 +15,7 @@ export interface CompilerOptions { configFile?: string; debug?: boolean; cliArgs: ts.ParsedCommandLine; - project: ts.CompilerOptions; + tsConfig: ts.CompilerOptions; reporter: Reporter; sourceMap?: boolean; /** diff --git a/packages/core/src/compiler/compilation/CompilationContext.spec.ts b/packages/core/src/compiler/compilation/CompilationContext.spec.ts index cdcbff14..d0fbb7ce 100644 --- a/packages/core/src/compiler/compilation/CompilationContext.spec.ts +++ b/packages/core/src/compiler/compilation/CompilationContext.spec.ts @@ -55,7 +55,7 @@ beforeEach(() => { testProgram = ts.createProgram({ options: {}, rootNames: [] }); testObj = new CompilationContextTestClass({ buildDir: "", - project: {}, + tsConfig: {}, projectDir: testSystem.getCurrentDirectory(), reporter: new ReporterMock(testSystem), rootFiles: [], @@ -182,7 +182,7 @@ describe("resolvePath", () => { beforeEach(() => { testObj = new CompilationContextTestClass({ buildDir: "", - project: {}, + tsConfig: {}, projectDir: "/expected", reporter: new ReporterMock(testSystem), rootFiles: [], @@ -271,7 +271,7 @@ describe("addAssetDependency", () => { const target = jest.fn(); testObj = new CompilationContextTestClass({ buildDir: "", - project: {}, + tsConfig: {}, projectDir: testSystem.getCurrentDirectory(), reporter: new ReporterMock(testSystem), rootFiles: [], diff --git a/packages/core/src/compiler/compilation/CompilationContext.ts b/packages/core/src/compiler/compilation/CompilationContext.ts index a26f2ed9..05d6f29b 100644 --- a/packages/core/src/compiler/compilation/CompilationContext.ts +++ b/packages/core/src/compiler/compilation/CompilationContext.ts @@ -15,7 +15,7 @@ export type CompilationContextOptions = { buildDir: string; config?: unknown; program: ts.Program; - project: ts.CompilerOptions; + tsConfig: ts.CompilerOptions; projectDir: string; reporter: Reporter; rootFiles: string[]; @@ -50,7 +50,7 @@ export class CompilationContext implements AddonContext { private assetCodeDependency: Map = new Map(); constructor(options: CompilationContextOptions) { - const { buildDir, config, program, project, projectDir, rootFiles, system, target, cliArgs, watchCallback, registerDependencyCallback } = + const { buildDir, config, program, tsConfig, projectDir, rootFiles, system, target, cliArgs, watchCallback, registerDependencyCallback } = options; this.buildDir = buildDir; this.rootFiles = rootFiles; @@ -61,7 +61,7 @@ export class CompilationContext implements AddonContext { this.generators = []; this.languageHost = this.createLanguageServiceHost({ system, - options: project, + options: tsConfig, target, }); this.cache = new FileCache(system); diff --git a/packages/core/test/compile-options.ts b/packages/core/test/compile-options.ts index 302c407f..99fed265 100644 --- a/packages/core/test/compile-options.ts +++ b/packages/core/test/compile-options.ts @@ -21,11 +21,11 @@ export const compileOptions = ( transpileOnly: false, watch: false, ...overrides, - project: { + tsConfig: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.Latest, configFilePath: "./tsconfig.json", - ...overrides?.project, + ...overrides?.tsConfig, }, targets: overrides?.targets ?? ["*"], cliArgs: { diff --git a/packages/examples/tests/export-yaml-generator.test.ts b/packages/examples/tests/export-yaml-generator.test.ts index 152cdc6b..89f8bbf1 100644 --- a/packages/examples/tests/export-yaml-generator.test.ts +++ b/packages/examples/tests/export-yaml-generator.test.ts @@ -11,7 +11,7 @@ describe("export-yaml-generator", () => { let testObj: CompilationEnv; beforeAll(() => { testObj = compilationEnv("./__TEST__/export-yaml-generator", { - compilerOptions: { project: { outDir: "dist" } }, + compilerOptions: { tsConfig: { outDir: "dist" } }, virtual: false, }).addAddon("export-yaml-generator", join(__dirname, "../addons")); }); diff --git a/packages/examples/tests/foobar-replace-processor.test.ts b/packages/examples/tests/foobar-replace-processor.test.ts index 62089f7f..8acca459 100644 --- a/packages/examples/tests/foobar-replace-processor.test.ts +++ b/packages/examples/tests/foobar-replace-processor.test.ts @@ -11,7 +11,7 @@ describe("foobar-replace-processor", () => { let testObj: CompilationEnv; beforeAll(() => { testObj = compilationEnv("./__TEST__/foobar-replace-processor", { - compilerOptions: { project: { outDir: "dist" } }, + compilerOptions: { tsConfig: { outDir: "dist" } }, virtual: false, }).addAddon("foobar-replace-processor", join(__dirname, "../addons")); }); diff --git a/packages/examples/tests/foobar-replace-transformer.test.ts b/packages/examples/tests/foobar-replace-transformer.test.ts index d996dafc..ba1011d1 100644 --- a/packages/examples/tests/foobar-replace-transformer.test.ts +++ b/packages/examples/tests/foobar-replace-transformer.test.ts @@ -11,7 +11,7 @@ describe("foobar-replace-transformer", () => { let testObj: CompilationEnv; beforeAll(() => { testObj = compilationEnv("./__TEST__/foobar-replace-transformer", { - compilerOptions: { project: { outDir: "dist" } }, + compilerOptions: { tsConfig: { outDir: "dist" } }, virtual: false, }).addAddon("foobar-replace-transformer", join(__dirname, "../addons")); }); diff --git a/packages/testing/src/compilation/environment.spec.ts b/packages/testing/src/compilation/environment.spec.ts index 27633094..e69b67dd 100644 --- a/packages/testing/src/compilation/environment.spec.ts +++ b/packages/testing/src/compilation/environment.spec.ts @@ -42,7 +42,7 @@ describe("compilationEnv", () => { expect(actual).toMatchObject({ buildDir: "/target/src", - project: { + tsConfig: { configFilePath: "/target/tsconfig.json", module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ESNext, @@ -59,13 +59,13 @@ describe("compilationEnv", () => { }); it("should yield custom compiler options with custom overrides", () => { - const testObj = compilationEnv("/target", { compilerOptions: { buildDir: "./expected-src", project: { outDir: "./expected-out" } } }); + const testObj = compilationEnv("/target", { compilerOptions: { buildDir: "./expected-src", tsConfig: { outDir: "./expected-out" } } }); const actual = testObj.getCompilerOptions(); expect(actual).toMatchObject({ buildDir: "./expected-src", - project: { + tsConfig: { configFilePath: "./tsconfig.json", module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ESNext, @@ -380,7 +380,7 @@ describe("compilationEnv#compiled", () => { it("should yield compilation errors with illegal project files", () => { const testObj = compilationEnv("/target", { - compilerOptions: { project: { noEmitOnError: true } }, + compilerOptions: { tsConfig: { noEmitOnError: true } }, }) .addProjectFromSource({ "index.ts": `export * from './target';`, diff --git a/packages/testing/src/compilation/environment.ts b/packages/testing/src/compilation/environment.ts index 5b09b904..907915a5 100644 --- a/packages/testing/src/compilation/environment.ts +++ b/packages/testing/src/compilation/environment.ts @@ -45,7 +45,7 @@ export class CompilationEnv { this.system = this.virtual ? createBrowserSystem(undefined, useCaseSensitiveFileNames) : ts.sys; this.rootDir = resolvePath(this.system, rootDir ?? DEFAULT_ROOT_DIR); this.buildDir = resolvePath(this.system, this.rootDir, options?.compilerOptions?.buildDir ?? DEFAULT_BUILD_DIR); - const outDir = resolvePath(this.system, this.rootDir, options?.compilerOptions?.project?.outDir ?? DEFAULT_OUT_DIR); + const outDir = resolvePath(this.system, this.rootDir, options?.compilerOptions?.tsConfig?.outDir ?? DEFAULT_OUT_DIR); if (!this.system.directoryExists(this.rootDir)) { getSubPaths(this.rootDir).forEach(it => !!it && !this.system.directoryExists(it) && this.system.createDirectory(it)); @@ -70,7 +70,7 @@ export class CompilationEnv { }, }, }, - project: { configFilePath: `${this.rootDir}/tsconfig.json`, outDir }, + tsConfig: { configFilePath: `${this.rootDir}/tsconfig.json`, outDir }, ...compilerOptions, }); @@ -95,7 +95,7 @@ export class CompilationEnv { } public getOutDir(): string { - return resolveProjectPath(this.system, this.rootDir, this.compilerOptions.project.outDir ?? DEFAULT_OUT_DIR); + return resolveProjectPath(this.system, this.rootDir, this.compilerOptions.tsConfig.outDir ?? DEFAULT_OUT_DIR); } public getCompilerOptions(): CompilerOptions { @@ -277,7 +277,7 @@ export class CompilationEnv { } public getCompiledDir(): string { - return resolveProjectPath(this.system, this.rootDir, this.getCompilerOptions().project.outDir ?? DEFAULT_OUT_DIR); + return resolveProjectPath(this.system, this.rootDir, this.getCompilerOptions().tsConfig.outDir ?? DEFAULT_OUT_DIR); } public getCompiledFiles(): ProjectFiles { @@ -323,7 +323,7 @@ export class CompilationEnv { ...compileOptions(this.system, { buildDir: curDir, }), - project: { + tsConfig: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES5, esModuleInterop: true, diff --git a/packages/testing/src/compile-options.spec.ts b/packages/testing/src/compile-options.spec.ts index 391ba6d2..3610ed85 100644 --- a/packages/testing/src/compile-options.spec.ts +++ b/packages/testing/src/compile-options.spec.ts @@ -19,7 +19,7 @@ describe("compileOptions", () => { sourceMap: false, transpileOnly: false, watch: false, - project: { + tsConfig: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.Latest, configFilePath: "./tsconfig.json", diff --git a/packages/testing/src/compile-options.ts b/packages/testing/src/compile-options.ts index 68ffcc92..2cdd0b66 100644 --- a/packages/testing/src/compile-options.ts +++ b/packages/testing/src/compile-options.ts @@ -27,15 +27,15 @@ export const compileOptions = ( transpileOnly: false, watch: false, ...overrides, - project: { + tsConfig: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.Latest, configFilePath: `./tsconfig.json`, - ...overrides?.project, + ...overrides?.tsConfig, }, targets: overrides?.targets ?? [], cliArgs: { - options: { outDir: overrides?.project?.outDir ?? DEFAULT_OUT_DIR }, + options: { outDir: overrides?.tsConfig?.outDir ?? DEFAULT_OUT_DIR }, fileNames: system.readDirectory(buildDir), errors: [], ...overrides?.cliArgs, diff --git a/packages/webpack/src/TsCompiler.spec.ts b/packages/webpack/src/TsCompiler.spec.ts index 820bebdd..595d7660 100644 --- a/packages/webpack/src/TsCompiler.spec.ts +++ b/packages/webpack/src/TsCompiler.spec.ts @@ -53,7 +53,7 @@ describe("TsCompiler", () => { testObj = new TestCompiler( { buildDir: resolve("./__TEMP__"), - project: { declaration: true, target: 99, noEmitOnError: true }, + tsConfig: { declaration: true, target: 99, noEmitOnError: true }, reporter, targets: ["*"], cliArgs: { options: {}, fileNames: [expected], errors: [] }, @@ -113,7 +113,7 @@ describe("Transpilation", () => { testObj = new TestCompiler( { buildDir: resolve("./__TEMP__"), - project: { declaration: true, target: 99, noEmitOnError: true }, + tsConfig: { declaration: true, target: 99, noEmitOnError: true }, reporter, targets: ["*"], cliArgs: { options: { declaration: true, target: 99 }, fileNames: [expected], errors: [] }, @@ -148,7 +148,7 @@ describe("Transpilation", () => { write: { writeFile: true, options: { module: 1, target: 1 } }, }, }, - project: { target: 99, outDir: resolve("./__TEMP__/.build"), noEmitOnError: true }, + tsConfig: { target: 99, outDir: resolve("./__TEMP__/.build"), noEmitOnError: true }, reporter, targets: ["fragment", "write"], cliArgs: { options: { target: 99 }, fileNames: [expected], errors: [] }, diff --git a/packages/webpack/src/instance-cache.spec.ts b/packages/webpack/src/instance-cache.spec.ts index beff4cff..a68c8b2a 100644 --- a/packages/webpack/src/instance-cache.spec.ts +++ b/packages/webpack/src/instance-cache.spec.ts @@ -25,7 +25,7 @@ beforeEach(() => { tsCompiler = new TsCompiler( { buildDir: "./src", - project: {}, + tsConfig: {}, reporter, cliArgs: { options: { outDir: ".build" }, fileNames: [], errors: [] }, debug: false, @@ -49,7 +49,7 @@ describe("initializeInstance", () => { const actual = initializeInstance( target, - { config: join(projectDir, "websmith.config.json"), project: join(projectDir, "tsconfig.json") }, + { configFile: join(projectDir, "websmith.config.json"), project: join(projectDir, "tsconfig.json") }, path => console.info(`dependency ${path} added`) ); diff --git a/packages/webpack/src/options.spec.ts b/packages/webpack/src/options.spec.ts index 760bb396..a2790d79 100644 --- a/packages/webpack/src/options.spec.ts +++ b/packages/webpack/src/options.spec.ts @@ -14,7 +14,7 @@ describe("createOptions", () => { expect(actual).toEqual({ buildDir: expect.any(String), - project: expect.any(Object), + tsConfig: expect.any(Object), reporter: expect.any(NoReporter), cliArgs: expect.any(Object), debug: false, @@ -28,7 +28,7 @@ describe("createOptions", () => { it("should return project config w/ custom but empty tsconfig.json", () => { const { fileSystem: target } = compileSystem({ files: { "./expected/tsconfig.json": "{}" } }); - const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).project; + const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).tsConfig; expect(actual).toEqual({ configFilePath: "/expected/tsconfig.json", @@ -42,7 +42,7 @@ describe("createOptions", () => { files: { "./expected/tsconfig.json": `${JSON.stringify({ compilerOptions: { strict: true } })}` }, }); - const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).project; + const actual = createOptions({ project: "./expected/tsconfig.json" }, new NoReporter(), target).tsConfig; expect(actual).toEqual({ configFilePath: "/expected/tsconfig.json", @@ -57,7 +57,7 @@ describe("createOptions", () => { files: { "./expected/tsconfig.json": `${JSON.stringify({ compileOptions: { strict: false } })}` }, }); - const actual = createOptions({ project: "./expected/tsconfig.json", tsConfig: { strict: true } }, new NoReporter(), target).project; + const actual = createOptions({ project: "./expected/tsconfig.json", tsConfig: { strict: true } }, new NoReporter(), target).tsConfig; expect(actual).toEqual({ configFilePath: "/expected/tsconfig.json", @@ -136,7 +136,7 @@ describe("createOptions", () => { addons: ["one", "two"], addonsDir: "/expected", }, - project: { + tsConfig: { configFilePath: "/tsconfig.json", outDir: "/lib", }, diff --git a/packages/webpack/src/options.ts b/packages/webpack/src/options.ts index dc6dcd5b..5a84c676 100644 --- a/packages/webpack/src/options.ts +++ b/packages/webpack/src/options.ts @@ -58,7 +58,7 @@ export const createOptions = ( ...(configFile && { configFile }), debug, cliArgs, - project: cliArgs.options, + tsConfig: cliArgs.options, reporter, sourceMap, targets: resolveTargets(targets, compilationConfig, reporter),