jsr-exports-lint
raw JSON → 0.4.2 verified Fri May 01 auth: no javascript
A linting tool for validating the `exports` field in JSR's `jsr.json` manifest files, designed to be used as a build hook in `tsdown` or `unbuild`. Current stable version is 0.4.2. Released under MIT license with active development. Key differentiator: unlike `publint` which lints npm `package.json` exports, this tool specifically targets JSR's `jsr.json` exports, making it essential for library authors distributing via both npm and JSR. It fully supports TypeScript and requires Node >= 20. The lint runs after the build is done, checking that all exported entries match the actual built files.
Common errors
error Error: Cannot find module 'jsr-exports-lint' ↓
cause Importing from the package root instead of the subpath.
fix
Import from 'jsr-exports-lint/tsdown' or 'jsr-exports-lint/unbuild'.
error Error: 'undefined' is not a function (evaluating 'lintJsrExports()') ↓
cause Passing lintJsrExports as a reference without calling it.
fix
Call it: hooks: { 'build:done': lintJsrExports() }.
error TypeError: (0 , _jsr_exports_lint_tsdown.lintJsrExports) is not a function ↓
cause Using default import instead of named import.
fix
Use named import: import { lintJsrExports } from 'jsr-exports-lint/tsdown'.
Warnings
breaking Package renamed in v0.2.0 from 'tsdown-jsr-exports-lint' to 'jsr-exports-lint'. Old imports break. ↓
fix Update import paths from 'tsdown-jsr-exports-lint' to 'jsr-exports-lint'.
deprecated Support for tsdown <0.9.6 and unbuild <1.0.0 was dropped. ↓
fix Upgrade tsdown to >=0.9.6 and unbuild to >=1.0.0.
gotcha The lintJsrExports function must be called (invoked) in the hook, not just passed as a reference. ↓
fix Use hooks: { 'build:done': lintJsrExports() } — with parentheses.
Install
npm install jsr-exports-lint yarn add jsr-exports-lint pnpm add jsr-exports-lint Imports
- lintJsrExports wrong
import { lintJsrExports } from 'jsr-exports-lint'correctimport { lintJsrExports } from 'jsr-exports-lint/tsdown' - lintJsrExports wrong
import { lintJsrExports } from 'jsr-exports-lint'correctimport { lintJsrExports } from 'jsr-exports-lint/unbuild' - lintJsrExports wrong
const lintJsrExports = require('jsr-exports-lint')correctconst { lintJsrExports } = require('jsr-exports-lint/tsdown')
Quickstart
// Install: npm install --save-dev jsr-exports-lint
// tsdown.config.ts
import { defineConfig } from 'tsdown'
import { lintJsrExports } from 'jsr-exports-lint/tsdown'
export default defineConfig({
entry: ['./src/index.ts', './src/features/a.ts'],
publint: true,
dts: true,
hooks: {
'build:done': lintJsrExports()
}
})
// Run: npx tsdown build