Skip to content

Commit ee6f526

Browse files
authored
fix: TypeScript workspaces bring in conflicting projen dependencies (#847)
This only opens up the possibility of multiple projen versions across the monorepo, which is a source of bugs.
1 parent 18e1595 commit ee6f526

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
lines changed

src/yarn/typescript-workspace.ts

+3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ export class TypeScriptWorkspace extends typescript.TypeScriptProject implements
247247

248248
this.bundledDeps.push(...options.bundledDeps ?? []);
249249

250+
// Individual workspace packages shouldn't depend on "projen", it gets brought in at the monorepo root
251+
this.deps.removeDependency('projen');
252+
250253
options.parent.register(this);
251254
}
252255

test/__snapshots__/cdklabs-monorepo.test.ts.snap

+5-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cdklabs-monorepo.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ describe('CdkLabsMonorepo', () => {
2828
expect(outdir).toMatchSnapshot();
2929
});
3030

31+
test('workspaces dont have their own projen dependency', () => {
32+
new yarn.TypeScriptWorkspace({
33+
parent,
34+
name: '@cdklabs/one',
35+
});
36+
37+
const outdir = Testing.synth(parent);
38+
const deps = outdir['packages/@cdklabs/one/.projen/deps.json'];
39+
expect(deps.dependencies).not.toContain(expect.objectContaining({
40+
name: 'projen',
41+
}));
42+
});
43+
3144
test('bundled dependencies lead to a nohoist directive', () => {
3245
// GIVEN
3346
new yarn.TypeScriptWorkspace({

0 commit comments

Comments
 (0)