From 8678f034511e97805ff77fdfee83c9b279c699f3 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 28 Jun 2024 19:02:03 +0000 Subject: [PATCH] Move @typespec/compiler from dependencies to peerDependencies --- packages/compiler/src/init/scaffold.ts | 4 +++- packages/compiler/test/init/init-template.test.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/compiler/src/init/scaffold.ts b/packages/compiler/src/init/scaffold.ts index f89e43e5ca0..6ed899aea7c 100644 --- a/packages/compiler/src/init/scaffold.ts +++ b/packages/compiler/src/init/scaffold.ts @@ -105,9 +105,10 @@ async function writePackageJson(host: CompilerHost, config: ScaffoldingConfig) { return; } const dependencies: Record = {}; + const peerDependencies: Record = {}; if (!config.template.skipCompilerPackage) { - dependencies["@typespec/compiler"] = "latest"; + peerDependencies["@typespec/compiler"] = "latest"; } for (const library of config.libraries) { @@ -119,6 +120,7 @@ async function writePackageJson(host: CompilerHost, config: ScaffoldingConfig) { version: "0.1.0", type: "module", dependencies, + peerDependencies, private: true, }; diff --git a/packages/compiler/test/init/init-template.test.ts b/packages/compiler/test/init/init-template.test.ts index d76f430223f..d619ae8c20b 100644 --- a/packages/compiler/test/init/init-template.test.ts +++ b/packages/compiler/test/init/init-template.test.ts @@ -45,11 +45,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'); }); });