feat: use tsnapi for exports snapshoting

This commit is contained in:
Anthony Fu
2026-04-10 17:12:24 +09:00
parent 68c00a2b25
commit 83cf9c396b
9 changed files with 1550 additions and 1712 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ Then for the future releases, you can run `pnpm run release` to do the release a
<p align="center">
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
<img src="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg" alt="Sponsors"/>
</a>
</p>
+5
View File
@@ -0,0 +1,5 @@
/**
* Generated by tsnapi — public API snapshot of `pkg-placeholder` */
// Variables
export declare const one: number;
export declare const two: number;
+4
View File
@@ -0,0 +1,4 @@
/**
* Generated by tsnapi — public API snapshot of `pkg-placeholder` */
export var one /* const */
export var two /* const */
+4 -6
View File
@@ -2,7 +2,7 @@
"name": "pkg-placeholder",
"type": "module",
"version": "0.0.0",
"packageManager": "pnpm@10.25.0",
"packageManager": "pnpm@10.33.0",
"description": "_description_",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT",
@@ -46,17 +46,15 @@
"lint-staged": "catalog:cli",
"publint": "catalog:cli",
"simple-git-hooks": "catalog:cli",
"tinyexec": "catalog:testing",
"tsdown": "catalog:cli",
"tsnapi": "catalog:testing",
"tsx": "catalog:cli",
"typescript": "catalog:cli",
"vite": "catalog:cli",
"vitest": "catalog:testing",
"vitest-package-exports": "catalog:testing",
"yaml": "catalog:testing"
"vitest": "catalog:testing"
},
"simple-git-hooks": {
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && pnpm run build && npx lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
+1517 -1661
View File
File diff suppressed because it is too large Load Diff
+11 -13
View File
@@ -11,26 +11,24 @@ packages:
catalogs:
cli:
'@antfu/eslint-config': ^6.6.1
'@antfu/ni': ^28.0.0
bumpp: ^10.3.2
eslint: ^9.39.2
lint-staged: ^16.2.7
publint: ^0.3.16
'@antfu/eslint-config': ^8.1.1
'@antfu/ni': ^30.0.0
bumpp: ^11.0.1
eslint: ^10.2.0
lint-staged: ^16.4.0
publint: ^0.3.18
simple-git-hooks: ^2.13.1
tsdown: ^0.17.3
tsx: ^4.21.0
typescript: ^5.9.3
vite: ^7.2.7
typescript: ^6.0.2
vite: ^8.0.8
inlined:
'@antfu/utils': ^9.3.0
testing:
tinyexec: ^1.0.2
vitest: ^4.0.15
vitest-package-exports: ^0.1.1
yaml: ^2.8.2
tsnapi: ^0.1.1
vitest: ^4.1.4
types:
'@types/node': ^25.0.1
'@types/node': ^25.6.0
onlyBuiltDependencies:
- esbuild
- simple-git-hooks
-26
View File
@@ -1,26 +0,0 @@
import { x } from 'tinyexec'
import { describe, expect, it } from 'vitest'
import { getPackageExportsManifest } from 'vitest-package-exports'
import yaml from 'yaml'
// TODO: remove this when you are ready for the first release
const IS_READY = false
describe.runIf(IS_READY)('exports-snapshot', async () => {
const packages: { name: string, path: string, private?: boolean }[] = JSON.parse(
await x('pnpm', ['ls', '--only-projects', '-r', '--json']).then(r => r.stdout),
)
for (const pkg of packages) {
if (pkg.private)
continue
it(`${pkg.name}`, async () => {
const manifest = await getPackageExportsManifest({
importMode: 'src',
cwd: pkg.path,
})
await expect(yaml.stringify(manifest.exports))
.toMatchFileSnapshot(`./exports/${pkg.name}.yaml`)
})
}
})
+8
View File
@@ -1,4 +1,6 @@
import process from 'node:process'
import { defineConfig } from 'tsdown'
import ApiSnapshot from 'tsnapi/rolldown'
export default defineConfig({
entry: [
@@ -7,4 +9,10 @@ export default defineConfig({
dts: true,
exports: true,
publint: true,
plugins: [
ApiSnapshot({
// TODO: remove this when the library is stable to guard against breaking changes
update: !process.env.CI,
}),
],
})
-5
View File
@@ -2,10 +2,5 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
server: {
deps: {
inline: ['vitest-package-exports'],
},
},
},
})