Skip to content

Commit

Permalink
fix: Jsii projects don't have tsconfig.json
Browse files Browse the repository at this point in the history
Jsii generates tsconfig.json
  • Loading branch information
vincenthsh committed Jul 4, 2024
1 parent fd8f8d7 commit 7154aab
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/turbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
typescript,
Project,
javascript,
cdk,
JsonFile,
YamlFile,
JsonPatch,
Expand Down Expand Up @@ -355,9 +356,13 @@ export class TurborepoProject extends typescript.TypeScriptProject {
.filter(({ name }) => packageNames.includes(name))
.map(({ name }) => packageNameSubProjectMap[name]);

const references = depProjects
.map(({ outdir }) => path.relative(subProject.outdir, outdir))
.map((p) => ({ path: p }));
const references = [];
for (const depProject of depProjects) {
let relPath = path.relative(subProject.outdir, depProject.outdir);
if (ProjectUtils.isNamedInstanceOf(depProject, cdk.JsiiProject))
relPath = path.join(relPath, "tsconfig.dev.json");
references.push({ path: relPath });
}

const pathMappings: Record<string, string> = {};
for (const depProject of depProjects) {
Expand Down
33 changes: 31 additions & 2 deletions test/sub-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { javascript } from "projen";
import {
synthProjectSnapshot,
createSubProject,
createJSIISubProject,
createJSIISubProject as createJsiiSubProject,
createProject,
parseYaml,
} from "./util";
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("TurborepoProject", () => {
outdir: subProjectBarDir,
});
const subProjectFooDir = "packages/foo";
const subProjectFoo = createJSIISubProject({
const subProjectFoo = createJsiiSubProject({
parent: project,
outdir: subProjectFooDir,
deps: [subProjectBar.package.packageName],
Expand Down Expand Up @@ -147,6 +147,35 @@ describe("TurborepoProject", () => {
]);
});

it("should add JsiiProject references when turned on", () => {
expect.assertions(1);

const project = createProject({
projectReferences: true,
});

const subProjectBarDir = "packages/bar";
const subProjectBar = createJsiiSubProject({
parent: project,
outdir: subProjectBarDir,
});

const subProjectBazDir = "packages/baz";
createSubProject({
parent: project,
outdir: subProjectBazDir,
deps: [subProjectBar.package.packageName],
});

const synth = synthProjectSnapshot(project);

expect(synth["packages/baz/tsconfig.json"].references).toStrictEqual([
{
path: "../bar/tsconfig.dev.json", // JSII projects only have tsconfig.json
},
]);
});

it("should add moduleNameMapper for jest", () => {
expect.assertions(1);

Expand Down

0 comments on commit 7154aab

Please sign in to comment.