Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't use project outDir or outFile options. #39

Merged
merged 2 commits into from
Nov 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/prisma-fabbrica/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function compile(fileName: string, content: string, options: ts.CompilerOptions)
program.emit();
const js = fileMap.get(fileName.replace(".ts", ".js"))!;
const dts = fileMap.get(fileName.replace(".ts", ".d.ts"))!;
if (!js || !dts) {
throw new Error('prisma-fabbrica: Failed to TypeScript transpilation. Please try "noTranspile = true"');
}
return { js, dts };
}

Expand All @@ -43,7 +46,7 @@ generatorHandler({
logger.error("No prisma client generator.");
return;
}
const noTranspile = options.generator.config.noTranspile ?? false;
const noTranspile = options.generator.config.noTranspile === "true" ?? false;
const outputDirname = options.generator.output?.value;
const clientGeneratorOutputPath = clientGeneratorConfig.output?.value;
if (!clientGeneratorOutputPath || !outputDirname) {
Expand Down Expand Up @@ -76,8 +79,14 @@ generatorHandler({
const compileOptions = readTsConfig(tsconfigPath);
const output = compile(path.join(outputDirname, "index.ts"), contents, {
...compileOptions,
declaration: true,
noEmit: false,
skipLibCheck: true,
incremental: false,
outDir: undefined,
outFile: undefined,
inlineSourceMap: undefined,
sourceMap: false,
declaration: true,
});
await Promise.all([
fs.writeFile(path.join(outputDirname, "index.js"), output.js, "utf8"),
Expand Down