Skip to content

Commit

Permalink
compiler: Allow configuring target, lib, and strict
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Nov 18, 2022
1 parent 2467dc8 commit 2db8de4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,36 @@ export function queryDefaultAssets(projectRoot: string, sys: ts.System): Assets
function makeCompilerOptions(projectRoot: string, system: ts.System, options: OutputOptions): ts.CompilerOptions {
const defaultTsOptions = makeDefaultCompilerOptions();

const softOptionNames = ["target", "lib", "strict"];
const fixedTsOptions = Object.assign({}, defaultTsOptions);
for (const name of softOptionNames) {
delete fixedTsOptions[name];
}

let opts: ts.CompilerOptions;
const configFileHost = new FridaConfigFileHost(projectRoot, system);
const userOpts = ts.getParsedCommandLineOfConfigFile(crosspath.join(projectRoot, "tsconfig.json"), fixedTsOptions, configFileHost)?.options;
if (userOpts !== undefined) {
for (const name of softOptionNames) {
const val = userOpts[name];
if (val === undefined) {
userOpts[name] = defaultTsOptions[name];
}
}
delete userOpts.noEmit;
opts = userOpts;
} else {
opts = defaultTsOptions;
}

const opts = ts.getParsedCommandLineOfConfigFile(crosspath.join(projectRoot, "tsconfig.json"), defaultTsOptions, configFileHost)?.options ?? defaultTsOptions;
delete opts.noEmit;
opts.rootDir = projectRoot;
opts.outDir = "/";
if (options.sourceMaps === "included") {
opts.sourceRoot = projectRoot;
opts.sourceMap = true;
opts.inlineSourceMap = false;
}

return opts;
}

Expand Down

0 comments on commit 2db8de4

Please sign in to comment.