From ddc23434dfc4728eb9a4aa693153e927fd4d0fb2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:20:53 +0000 Subject: [PATCH 1/4] Initial plan From 6b5b8693da382256991fd89bc10069ea4b8f963b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:35:34 +0000 Subject: [PATCH 2/4] fix: exclude build artifacts from npm packages Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com> --- eng/common/scripts/package-files.test.ts | 18 ++++++++++++++++++ packages/emitter-framework/package.json | 3 +++ packages/http-canonicalization/package.json | 3 +++ packages/http-client-js/package.json | 4 ++++ packages/http-client/package.json | 5 +++++ packages/http-server-js/package.json | 5 +++++ packages/http-specs/package.json | 5 +++++ packages/mutator-framework/package.json | 3 +++ packages/protobuf/package.json | 5 +++++ packages/spec-api/package.json | 3 +++ packages/spec-coverage-sdk/package.json | 3 +++ packages/spector/package.json | 6 ++++++ 12 files changed, 63 insertions(+) create mode 100644 eng/common/scripts/package-files.test.ts diff --git a/eng/common/scripts/package-files.test.ts b/eng/common/scripts/package-files.test.ts new file mode 100644 index 00000000000..353b17438ab --- /dev/null +++ b/eng/common/scripts/package-files.test.ts @@ -0,0 +1,18 @@ +import { readdirSync, readFileSync } from "node:fs"; +import { join } from "node:path"; +import { expect, it } from "vitest"; + +it("requires publishable packages to declare their published files", () => { + const packagesDir = new URL("../../../packages", import.meta.url); + const packagesWithoutFiles = readdirSync(packagesDir, { withFileTypes: true }) + .filter((entry) => entry.isDirectory()) + .filter((entry) => { + const packageJson = JSON.parse( + readFileSync(join(packagesDir.pathname, entry.name, "package.json"), "utf-8"), + ); + return packageJson.private !== true && packageJson.files === undefined; + }) + .map((entry) => entry.name); + + expect(packagesWithoutFiles).toEqual([]); +}); diff --git a/packages/emitter-framework/package.json b/packages/emitter-framework/package.json index d3c61094183..212b1e6c343 100644 --- a/packages/emitter-framework/package.json +++ b/packages/emitter-framework/package.json @@ -7,6 +7,9 @@ "type": "git", "url": "git+https://github.com/microsoft/typespec.git" }, + "files": [ + "dist/**" + ], "scripts": { "build": "alloy build", "clean": "rimraf ./dist", diff --git a/packages/http-canonicalization/package.json b/packages/http-canonicalization/package.json index 2270a2ef972..4fca5426a0b 100644 --- a/packages/http-canonicalization/package.json +++ b/packages/http-canonicalization/package.json @@ -26,6 +26,9 @@ "import": "./dist/src/index.js" } }, + "files": [ + "dist/**" + ], "keywords": [], "author": "", "license": "MIT", diff --git a/packages/http-client-js/package.json b/packages/http-client-js/package.json index dfd095a80ab..9e05a5f1256 100644 --- a/packages/http-client-js/package.json +++ b/packages/http-client-js/package.json @@ -36,6 +36,10 @@ "import": "./dist/src/components/index.js" } }, + "files": [ + "dist/**", + "!dist/test/**" + ], "keywords": [ "typespec", "javascript", diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 084ed248838..562d5c20d50 100644 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -22,6 +22,11 @@ "import": "./dist/src/components/index.js" } }, + "files": [ + "lib/*.tsp", + "dist/**", + "!dist/test/**" + ], "peerDependencies": { "@alloy-js/core": "catalog:", "@alloy-js/typescript": "catalog:", diff --git a/packages/http-server-js/package.json b/packages/http-server-js/package.json index 80657e3f9f2..00707aa7467 100644 --- a/packages/http-server-js/package.json +++ b/packages/http-server-js/package.json @@ -31,6 +31,11 @@ "bin": { "hsjs-scaffold": "./cmd/hsjs-scaffold.mjs" }, + "files": [ + "dist/**", + "cmd/**", + "!dist/test/**" + ], "scripts": { "clean": "rimraf ./dist ./temp", "build": "pnpm build:helpers && pnpm build:src", diff --git a/packages/http-specs/package.json b/packages/http-specs/package.json index c3800fc2371..3a651e7f290 100644 --- a/packages/http-specs/package.json +++ b/packages/http-specs/package.json @@ -5,6 +5,11 @@ "description": "Spec scenarios and mock apis", "main": "dist/index.js", "type": "module", + "files": [ + "dist/**", + "specs/**", + "assets/**" + ], "scripts": { "watch": "tsc -p ./tsconfig.build.json --watch", "build": "tsc -p ./tsconfig.build.json && pnpm validate-scenarios && pnpm build:smoke", diff --git a/packages/mutator-framework/package.json b/packages/mutator-framework/package.json index 23c927bdaae..b2f9c4f37ff 100644 --- a/packages/mutator-framework/package.json +++ b/packages/mutator-framework/package.json @@ -26,6 +26,9 @@ "import": "./dist/src/index.js" } }, + "files": [ + "dist/**" + ], "keywords": [], "author": "", "license": "MIT", diff --git a/packages/protobuf/package.json b/packages/protobuf/package.json index 3e8ed2d0272..3dcea13b9d7 100644 --- a/packages/protobuf/package.json +++ b/packages/protobuf/package.json @@ -29,6 +29,11 @@ }, "type": "module", "tspMain": "lib/proto.tsp", + "files": [ + "lib/*.tsp", + "dist/**", + "!dist/test/**" + ], "scripts": { "clean": "rimraf ./dist ./temp", "build": "pnpm gen-extern-signature && tsc -p tsconfig.build.json && pnpm lint-typespec-library", diff --git a/packages/spec-api/package.json b/packages/spec-api/package.json index ee932b2c7d7..f0e778d54a4 100644 --- a/packages/spec-api/package.json +++ b/packages/spec-api/package.json @@ -8,6 +8,9 @@ "import": "./dist/index.js" } }, + "files": [ + "dist/**" + ], "scripts": { "watch": "tsc -p ./tsconfig.build.json --watch", "build": "tsc -p ./tsconfig.build.json", diff --git a/packages/spec-coverage-sdk/package.json b/packages/spec-coverage-sdk/package.json index 7c391a29d46..69642b0397d 100644 --- a/packages/spec-coverage-sdk/package.json +++ b/packages/spec-coverage-sdk/package.json @@ -4,6 +4,9 @@ "description": "Spec utility to manage the reported coverage", "main": "dist/index.js", "type": "module", + "files": [ + "dist/**" + ], "scripts": { "watch": "tsc -p ./tsconfig.build.json --watch", "build": "tsc -p ./tsconfig.build.json", diff --git a/packages/spector/package.json b/packages/spector/package.json index ef98b4a546a..d1a7121285e 100644 --- a/packages/spector/package.json +++ b/packages/spector/package.json @@ -12,6 +12,12 @@ "bin": { "tsp-spector": "./cmd/cli.mjs" }, + "files": [ + "lib/*.tsp", + "dist/**", + "cmd/**", + "!dist/test/**" + ], "scripts": { "watch": "tsc -p ./tsconfig.build.json --watch", "build": "pnpm gen-extern-signature && tsc -p tsconfig.build.json", From cd48c2cc94366b53c0a7b7e37cecfc1609b6f88b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:44:20 +0000 Subject: [PATCH 3/4] chore: add package artifact changelog Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com> --- ...uild-artifacts-from-npm-2026-7-7-14-35-46.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .chronus/changes/copilot-remove-build-artifacts-from-npm-2026-7-7-14-35-46.md diff --git a/.chronus/changes/copilot-remove-build-artifacts-from-npm-2026-7-7-14-35-46.md b/.chronus/changes/copilot-remove-build-artifacts-from-npm-2026-7-7-14-35-46.md new file mode 100644 index 00000000000..c0e84aa8cbf --- /dev/null +++ b/.chronus/changes/copilot-remove-build-artifacts-from-npm-2026-7-7-14-35-46.md @@ -0,0 +1,17 @@ +--- +changeKind: fix +packages: + - "@typespec/emitter-framework" + - "@typespec/http-canonicalization" + - "@typespec/http-client" + - "@typespec/http-client-js" + - "@typespec/http-server-js" + - "@typespec/http-specs" + - "@typespec/mutator-framework" + - "@typespec/protobuf" + - "@typespec/spec-api" + - "@typespec/spec-coverage-sdk" + - "@typespec/spector" +--- + +Exclude build artifacts from published packages \ No newline at end of file From 17e3dcea35398f05429d294fee5f63b7d77a6bbb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:47:46 +0000 Subject: [PATCH 4/4] test: skip non-package directories Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com> --- eng/common/scripts/package-files.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/package-files.test.ts b/eng/common/scripts/package-files.test.ts index 353b17438ab..9db3aa7cebb 100644 --- a/eng/common/scripts/package-files.test.ts +++ b/eng/common/scripts/package-files.test.ts @@ -1,4 +1,4 @@ -import { readdirSync, readFileSync } from "node:fs"; +import { existsSync, readdirSync, readFileSync } from "node:fs"; import { join } from "node:path"; import { expect, it } from "vitest"; @@ -7,9 +7,10 @@ it("requires publishable packages to declare their published files", () => { const packagesWithoutFiles = readdirSync(packagesDir, { withFileTypes: true }) .filter((entry) => entry.isDirectory()) .filter((entry) => { - const packageJson = JSON.parse( - readFileSync(join(packagesDir.pathname, entry.name, "package.json"), "utf-8"), - ); + const packageJsonPath = join(packagesDir.pathname, entry.name, "package.json"); + if (!existsSync(packageJsonPath)) return false; + + const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8")); return packageJson.private !== true && packageJson.files === undefined; }) .map((entry) => entry.name);