rsbuild-plugin-publint

raw JSON →
0.3.4 verified Fri May 01 auth: no javascript

Rsbuild plugin that runs publint to lint npm packages after the build process. It helps library authors catch compatibility issues early by validating package exports, detecting incorrect module formats, and ensuring proper CJS/ESM interop. Version 0.3.4 is the current stable release; maintained actively with frequent updates. Key differentiators: seamless integration with Rsbuild/Rslib, configurable severity thresholds via throwOn option, and ability to run conditionally with enable option. Unlike manual publint invocation, this runs automatically on each build, preventing publishing broken packages.

error TypeError: pluginPublint is not a function
cause Using default import instead of named import.
fix
Change import to: import { pluginPublint } from 'rsbuild-plugin-publint'
error Error: Cannot find module 'rsbuild-plugin-publint'
cause Package not installed or missing from node_modules.
fix
Run: npm install rsbuild-plugin-publint -D
error Error: Expected options to be an object, got undefined
cause Passing nothing to pluginPublint() is allowed, but if you pass undefined explicitly, it may error. Also if you call pluginPublint without parentheses.
fix
Call pluginPublint() with or without options object, e.g., pluginPublint() or pluginPublint({})
error Error: publint failed with errors
cause publint found errors in the built package.
fix
Check publint output for details; you can set throwOn to 'never' to avoid build failure.
gotcha pluginPublint() must be called; passing the function reference without parentheses will not register the plugin.
fix Use pluginPublint() with parentheses.
gotcha In watch mode, errors are printed instead of thrown, even if throwOn is set to 'error'.
fix Do not rely on throw behavior in watch mode; check console output.
deprecated The level option in publintOptions may be deprecated in future publint versions; prefer using throwOn for severity control.
fix Use throwOn instead of setting level in publintOptions.
breaking In v0.3.0, pluginPublint changed from running on every build to only on first build to improve watch mode. If you relied on it running every time, update your workflow.
fix Upgrade to >=0.3.1 which restored per-build behavior for non-watch.
npm install rsbuild-plugin-publint
yarn add rsbuild-plugin-publint
pnpm add rsbuild-plugin-publint

Demonstrates basic usage with CI-only enable and strict error handling.

import { defineConfig } from '@rsbuild/core';
import { pluginPublint } from 'rsbuild-plugin-publint';

export default defineConfig({
  plugins: [pluginPublint({
    enable: Boolean(process.env.CI ?? false),
    throwOn: 'error',
    publintOptions: {
      level: 'error',
    },
  })],
});