feat: use tsnapi for exports snapshoting

This commit is contained in:
Anthony Fu committed 2026-04-10 17:12:24 +09:00
1 parent 68c00a2b25
commit 83cf9c396b
9 files changed
+1550 -1712

No files matched your search

+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"> <p align="center">
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg"> <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> </a>
</p> </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", "name": "pkg-placeholder",
"type": "module", "type": "module",
"version": "0.0.0", "version": "0.0.0",
"packageManager": "pnpm@10.25.0", "packageManager": "pnpm@10.33.0",
"description": "_description_", "description": "_description_",
"author": "Anthony Fu <anthonyfu117@hotmail.com>", "author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT", "license": "MIT",
@@ -46,17 +46,15 @@
"lint-staged": "catalog:cli", "lint-staged": "catalog:cli",
"publint": "catalog:cli", "publint": "catalog:cli",
"simple-git-hooks": "catalog:cli", "simple-git-hooks": "catalog:cli",
"tinyexec": "catalog:testing",
"tsdown": "catalog:cli", "tsdown": "catalog:cli",
"tsnapi": "catalog:testing",
"tsx": "catalog:cli", "tsx": "catalog:cli",
"typescript": "catalog:cli", "typescript": "catalog:cli",
"vite": "catalog:cli", "vite": "catalog:cli",
"vitest": "catalog:testing", "vitest": "catalog:testing"
"vitest-package-exports": "catalog:testing",
"yaml": "catalog:testing"
}, },
"simple-git-hooks": { "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": { "lint-staged": {
"*": "eslint --fix" "*": "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: catalogs:
cli: cli:
'@antfu/eslint-config': ^6.6.1 '@antfu/eslint-config': ^8.1.1
'@antfu/ni': ^28.0.0 '@antfu/ni': ^30.0.0
bumpp: ^10.3.2 bumpp: ^11.0.1
eslint: ^9.39.2 eslint: ^10.2.0
lint-staged: ^16.2.7 lint-staged: ^16.4.0
publint: ^0.3.16 publint: ^0.3.18
simple-git-hooks: ^2.13.1 simple-git-hooks: ^2.13.1
tsdown: ^0.17.3 tsdown: ^0.17.3
tsx: ^4.21.0 tsx: ^4.21.0
typescript: ^5.9.3 typescript: ^6.0.2
vite: ^7.2.7 vite: ^8.0.8
inlined: inlined:
'@antfu/utils': ^9.3.0 '@antfu/utils': ^9.3.0
testing: testing:
tinyexec: ^1.0.2 tsnapi: ^0.1.1
vitest: ^4.0.15 vitest: ^4.1.4
vitest-package-exports: ^0.1.1
yaml: ^2.8.2
types: types:
'@types/node': ^25.0.1 '@types/node': ^25.6.0
onlyBuiltDependencies: onlyBuiltDependencies:
- esbuild - esbuild
- simple-git-hooks - 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 { defineConfig } from 'tsdown'
import ApiSnapshot from 'tsnapi/rolldown'
export default defineConfig({ export default defineConfig({
entry: [ entry: [
@@ -7,4 +9,10 @@ export default defineConfig({
dts: true, dts: true,
exports: true, exports: true,
publint: 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({ export default defineConfig({
test: { test: {
server: {
deps: {
inline: ['vitest-package-exports'],
},
},
}, },
}) })