Skip to content

Commit

Permalink
fix: Don't use project outDir or outFile options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Nov 25, 2022
1 parent 596b65a commit d54e04f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/example-prj/src/__generated__/fabbrica/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 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,12 @@ 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,
declaration: true,
});
await Promise.all([
fs.writeFile(path.join(outputDirname, "index.js"), output.js, "utf8"),
Expand Down

0 comments on commit d54e04f

Please sign in to comment.