Skip to content

Commit

Permalink
Move @typespec/compiler from dependencies to peerDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sarangan12 committed Jul 3, 2024
1 parent 1f8b85c commit 522fe47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/compiler/src/init/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ async function writePackageJson(host: CompilerHost, config: ScaffoldingConfig) {
return;
}
const dependencies: Record<string, string> = {};
const peerDependencies: Record<string, string> = {};

if (!config.template.skipCompilerPackage) {
dependencies["@typespec/compiler"] = "latest";
peerDependencies["@typespec/compiler"] = "latest";
}

for (const library of config.libraries) {
Expand All @@ -112,6 +113,7 @@ async function writePackageJson(host: CompilerHost, config: ScaffoldingConfig) {
version: "0.1.0",
type: "module",
dependencies,
peerDependencies,
private: true,
};

Expand Down
5 changes: 4 additions & 1 deletion packages/compiler/test/init/init-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ describe("compiler: init: templates", () => {
});

deepStrictEqual(JSON.parse(getOutputFile("package.json")!).dependencies, {
"@typespec/compiler": "latest",
foo: "~1.2.3",
bar: "latest",
});

deepStrictEqual(JSON.parse(getOutputFile("package.json")!).peerDependencies, {
"@typespec/compiler": "latest",
});

strictEqual(getOutputFile("main.tsp")!, 'import "foo";\nimport "bar";\n');
});
});
Expand Down

0 comments on commit 522fe47

Please sign in to comment.