Skip to content

Commit bd1a8dd

Browse files
committed
Fix package source map boundary
1 parent bc4c30e commit bd1a8dd

10 files changed

Lines changed: 56 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ jobs:
5454
- name: Security audit
5555
run: npm audit --omit=dev
5656

57-
- name: Package dry run
58-
run: npm pack --dry-run
57+
- name: Package boundary check
58+
run: npm run pack:check

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ jobs:
4848
- name: Build
4949
run: npm run build
5050

51-
- name: Preview package contents
52-
run: npm pack --dry-run
51+
- name: Package boundary check
52+
run: npm run pack:check
5353

5454
- name: Publish to npm
5555
run: npm publish --provenance --access public

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
## 目录导航
44

5+
- [1.0.1 - 2026-06-03](#101---2026-06-03)
56
- [1.0.0 - 2026-06-02](#100---2026-06-02)
67

8+
## 1.0.1 - 2026-06-03
9+
10+
- Remove source map files from npm package output.
11+
- Add a package boundary check that fails when `npm pack` includes `.map` files.
12+
- Run the package boundary check in CI, publish workflow, and `prepublishOnly`.
13+
714
## 1.0.0 - 2026-06-02
815

916
- Initialize `response-cache-kit` as a framework-agnostic response caching toolkit.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ npm run build
513513
npm run benchmark
514514
npm run benchmark:http
515515
npm run benchmark:compare
516+
npm run pack:check
516517
npm audit
517518
npm pack --dry-run
518519
```

docs/README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ npm run build
457457
npm run benchmark
458458
npm run benchmark:http
459459
npm run benchmark:compare
460+
npm run pack:check
460461
npm audit
461462
npm pack --dry-run
462463
```

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "response-cache-kit",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Framework-agnostic response caching toolkit for Node.js services.",
55
"type": "module",
66
"main": "./dist/cjs/index.cjs",
@@ -29,7 +29,8 @@
2929
"benchmark": "npm run build && node scripts/benchmark.mjs",
3030
"benchmark:http": "npm run build && node benchmarks/http.mjs",
3131
"benchmark:compare": "npm run build && node benchmarks/compare.mjs",
32-
"prepublishOnly": "npm run typecheck && npm run test:coverage && npm run build && npm audit --omit=dev && npm pack --dry-run"
32+
"pack:check": "node scripts/check-pack-contents.mjs",
33+
"prepublishOnly": "npm run typecheck && npm run test:coverage && npm run build && npm audit --omit=dev && npm run pack:check"
3334
},
3435
"keywords": [
3536
"response-cache",

scripts/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const shared = {
99
platform: "node",
1010
target: "node18",
1111
packages: "external",
12-
sourcemap: true,
12+
sourcemap: false,
1313
minify: false,
1414
logLevel: "info",
1515
};

scripts/check-pack-contents.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { execFile } from "node:child_process";
2+
import { promisify } from "node:util";
3+
4+
const execFileAsync = promisify(execFile);
5+
6+
const command =
7+
process.platform === "win32"
8+
? ["cmd.exe", ["/d", "/s", "/c", "npm pack --dry-run --json"]]
9+
: ["npm", ["pack", "--dry-run", "--json"]];
10+
11+
const { stdout } = await execFileAsync(command[0], command[1]);
12+
13+
const packs = JSON.parse(stdout);
14+
const files = packs.flatMap((pack) => pack.files ?? []);
15+
const paths = files.map((file) => file.path);
16+
const mapFiles = paths.filter((path) => path.endsWith(".map"));
17+
18+
if (mapFiles.length > 0) {
19+
console.error("Package contains source map files:");
20+
for (const path of mapFiles) {
21+
console.error(`- ${path}`);
22+
}
23+
process.exit(1);
24+
}
25+
26+
console.log(
27+
JSON.stringify(
28+
{
29+
package: packs[0]?.id,
30+
files: paths.length,
31+
sourceMaps: 0,
32+
},
33+
null,
34+
2,
35+
),
36+
);

tsconfig.types.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"noEmit": false,
55
"declaration": true,
6-
"declarationMap": true,
6+
"declarationMap": false,
77
"emitDeclarationOnly": true,
88
"declarationDir": "dist/types",
99
"rootDir": "src",

0 commit comments

Comments
 (0)