@savvy-web/rslib-builder 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,12 +50,6 @@ Install the required peer dependencies:
50
50
  pnpm add -D @rslib/core @microsoft/api-extractor @typescript/native-preview
51
51
  ```
52
52
 
53
- For TSDoc validation (optional):
54
-
55
- ```bash
56
- pnpm add -D eslint @typescript-eslint/parser eslint-plugin-tsdoc
57
- ```
58
-
59
53
  ## Quick Start
60
54
 
61
55
  Extend the provided tsconfig for optimal settings:
package/index.d.ts CHANGED
@@ -40,9 +40,7 @@
40
40
  */
41
41
 
42
42
  import type { ConfigParams } from '@rslib/core';
43
- import type { PackageJson } from 'type-fest';
44
43
  import type { PathLike } from 'node:fs';
45
- import type { RawCopyPattern } from '@rspack/binding';
46
44
  import type { RsbuildPlugin } from '@rsbuild/core';
47
45
  import type { RslibConfig } from '@rslib/core';
48
46
  import type { SourceConfig } from '@rsbuild/core';
@@ -121,6 +119,18 @@ export declare interface ApiModelOptions {
121
119
  * @defaultValue true (enabled when apiModel is enabled)
122
120
  */
123
121
  tsdocMetadata?: TsDocMetadataOptions | boolean;
122
+ /**
123
+ * Controls handling of API Extractor's "forgotten export" messages.
124
+ * A forgotten export occurs when a public API references a declaration
125
+ * that isn't exported from the entry point.
126
+ *
127
+ * - `"include"` (default): Log a warning, include in the API model
128
+ * - `"error"`: Fail the build with details about the forgotten exports
129
+ * - `"ignore"`: Turn off detection — suppress all messages
130
+ *
131
+ * @defaultValue "include"
132
+ */
133
+ forgottenExports?: "include" | "error" | "ignore";
124
134
  }
125
135
 
126
136
  /**
@@ -228,6 +238,52 @@ export declare interface AutoEntryPluginOptions {
228
238
  */
229
239
  export declare type BuildTarget = "dev" | "npm";
230
240
 
241
+ /**
242
+ * Configuration for copying files during the build process.
243
+ *
244
+ * @remarks
245
+ * This interface mirrors rspack's copy pattern configuration and is passed directly
246
+ * to the rspack CopyPlugin. All properties except `from` are optional.
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * // Copy a directory
251
+ * { from: "./public", to: "./", context: process.cwd() }
252
+ *
253
+ * // Copy specific files
254
+ * { from: "**\/*.json", to: "./config" }
255
+ * ```
256
+ *
257
+ * @public
258
+ */
259
+ export declare interface CopyPatternConfig {
260
+ /** Source path or glob pattern to copy from */
261
+ from: string;
262
+ /** Destination path (relative to output directory) */
263
+ to?: string;
264
+ /** Base directory for resolving `from` path */
265
+ context?: string;
266
+ /** Type of destination: "dir", "file", or "template" */
267
+ toType?: "dir" | "file" | "template";
268
+ /** If true, does not emit an error if the source is missing */
269
+ noErrorOnMissing?: boolean;
270
+ /** Glob options for pattern matching */
271
+ globOptions?: {
272
+ /** Patterns to ignore */
273
+ ignore?: string[];
274
+ /** Whether to match dotfiles */
275
+ dot?: boolean;
276
+ };
277
+ /** Filter function to include/exclude files */
278
+ filter?: (filepath: string) => boolean | Promise<boolean>;
279
+ /** Transform function to modify file contents */
280
+ transform?: {
281
+ transformer: (input: Buffer, absoluteFilename: string) => string | Buffer | Promise<string> | Promise<Buffer>;
282
+ } | ((input: Buffer, absoluteFilename: string) => string | Buffer | Promise<string> | Promise<Buffer>);
283
+ /** Priority for conflicting files (higher = higher priority) */
284
+ priority?: number;
285
+ }
286
+
231
287
  /**
232
288
  * Plugin to generate TypeScript declaration files using tsgo and emit them through Rslib's asset pipeline.
233
289
  *
@@ -827,6 +883,71 @@ export declare interface ImportGraphResult {
827
883
  errors: ImportGraphError[];
828
884
  }
829
885
 
886
+ /**
887
+ * Matches a JSON array.
888
+ *
889
+ * @public
890
+ */
891
+ export declare type JsonArray = JsonValue[] | readonly JsonValue[];
892
+
893
+ /**
894
+ * Matches a JSON object.
895
+ *
896
+ * @remarks
897
+ * This type can be useful to enforce some input to be JSON-compatible or as a
898
+ * super-type to be extended from.
899
+ *
900
+ * @public
901
+ */
902
+ export declare type JsonObject = {
903
+ [Key in string]: JsonValue;
904
+ };
905
+
906
+ /**
907
+ * Package.json type definitions.
908
+ *
909
+ * @remarks
910
+ * This is a local copy of type-fest's PackageJson types with TSDoc fixes.
911
+ * Original source: https://github.com/sindresorhus/type-fest
912
+ *
913
+ * TSDoc fixes applied:
914
+ * - Added deprecation messages to `@deprecated` tags
915
+ * - Fixed code fence formatting in `packageManager` docs
916
+ *
917
+ */
918
+ /**
919
+ * Matches any valid JSON primitive value.
920
+ *
921
+ * @public
922
+ */
923
+ export declare type JsonPrimitive = string | number | boolean | null;
924
+
925
+ /**
926
+ * Matches any valid JSON value.
927
+ *
928
+ * @public
929
+ */
930
+ export declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
931
+
932
+ /**
933
+ * Allows creating a union type by combining primitive types and literal types
934
+ * without sacrificing auto-completion in IDEs for the literal type part of the union.
935
+ *
936
+ * @remarks
937
+ * Currently, when a union type of a primitive type is combined with literal types,
938
+ * TypeScript loses all information about the combined literals. Thus, when such
939
+ * type is used in an IDE with autocompletion, no suggestions are made for the
940
+ * declared literals.
941
+ *
942
+ * This type is a workaround for Microsoft/TypeScript#29729.
943
+ *
944
+ * @typeParam LiteralType - The literal type(s) to include
945
+ * @typeParam BaseType - The base primitive type
946
+ *
947
+ * @public
948
+ */
949
+ export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
950
+
830
951
  /**
831
952
  * Builder for Node.js ESM libraries using RSlib.
832
953
  *
@@ -929,7 +1050,7 @@ export declare interface NodeLibraryBuilderOptions {
929
1050
  * ```
930
1051
  */
931
1052
  exportsAsIndexes?: boolean;
932
- copyPatterns: (string | (Pick<RawCopyPattern, "from"> & Partial<Omit<RawCopyPattern, "from">>))[];
1053
+ copyPatterns: (string | CopyPatternConfig)[];
933
1054
  /** Additional plugins */
934
1055
  plugins: RsbuildPlugin[];
935
1056
  define: SourceConfig["define"];
@@ -1103,6 +1224,433 @@ export declare interface NodeLibraryBuilderOptions {
1103
1224
  tsdocLint?: TsDocLintPluginOptions | boolean;
1104
1225
  }
1105
1226
 
1227
+ /**
1228
+ * PackageJson namespace containing all sub-types.
1229
+ *
1230
+ * @public
1231
+ */
1232
+ export declare namespace PackageJson {
1233
+ /**
1234
+ * A person who has been involved in creating or maintaining the package.
1235
+ */
1236
+ export type Person = string | {
1237
+ name: string;
1238
+ url?: string;
1239
+ email?: string;
1240
+ };
1241
+ /**
1242
+ * Location for reporting bugs.
1243
+ */
1244
+ export type BugsLocation = string | {
1245
+ /** The URL to the package's issue tracker. */
1246
+ url?: string;
1247
+ /** The email address to which issues should be reported. */
1248
+ email?: string;
1249
+ };
1250
+ /**
1251
+ * Directory locations within the package.
1252
+ */
1253
+ export interface DirectoryLocations {
1254
+ [directoryType: string]: JsonValue | undefined;
1255
+ /** Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder. */
1256
+ bin?: string;
1257
+ /** Location for Markdown files. */
1258
+ doc?: string;
1259
+ /** Location for example scripts. */
1260
+ example?: string;
1261
+ /** Location for the bulk of the library. */
1262
+ lib?: string;
1263
+ /** Location for man pages. Sugar to generate a `man` array by walking the folder. */
1264
+ man?: string;
1265
+ /** Location for test files. */
1266
+ test?: string;
1267
+ }
1268
+ /**
1269
+ * Script commands that are run at various times in the lifecycle of the package.
1270
+ */
1271
+ export type Scripts = {
1272
+ /** Run before the package is published (Also run on local `npm install` without any arguments). */
1273
+ prepublish?: string;
1274
+ /** Run both before the package is packed and published, and on local `npm install` without any arguments. */
1275
+ prepare?: string;
1276
+ /** Run before the package is prepared and packed, only on `npm publish`. */
1277
+ prepublishOnly?: string;
1278
+ /** Run before a tarball is packed (on `npm pack`, `npm publish`, and when installing git dependencies). */
1279
+ prepack?: string;
1280
+ /** Run after the tarball has been generated and moved to its final destination. */
1281
+ postpack?: string;
1282
+ /** Run after the package is published. */
1283
+ publish?: string;
1284
+ /** Run after the package is published. */
1285
+ postpublish?: string;
1286
+ /** Run before the package is installed. */
1287
+ preinstall?: string;
1288
+ /** Run after the package is installed. */
1289
+ install?: string;
1290
+ /** Run after the package is installed and after `install`. */
1291
+ postinstall?: string;
1292
+ /** Run before the package is uninstalled and before `uninstall`. */
1293
+ preuninstall?: string;
1294
+ /** Run before the package is uninstalled. */
1295
+ uninstall?: string;
1296
+ /** Run after the package is uninstalled. */
1297
+ postuninstall?: string;
1298
+ /** Run before bump the package version and before `version`. */
1299
+ preversion?: string;
1300
+ /** Run before bump the package version. */
1301
+ version?: string;
1302
+ /** Run after bump the package version. */
1303
+ postversion?: string;
1304
+ /** Run with the `npm test` command, before `test`. */
1305
+ pretest?: string;
1306
+ /** Run with the `npm test` command. */
1307
+ test?: string;
1308
+ /** Run with the `npm test` command, after `test`. */
1309
+ posttest?: string;
1310
+ /** Run with the `npm stop` command, before `stop`. */
1311
+ prestop?: string;
1312
+ /** Run with the `npm stop` command. */
1313
+ stop?: string;
1314
+ /** Run with the `npm stop` command, after `stop`. */
1315
+ poststop?: string;
1316
+ /** Run with the `npm start` command, before `start`. */
1317
+ prestart?: string;
1318
+ /** Run with the `npm start` command. */
1319
+ start?: string;
1320
+ /** Run with the `npm start` command, after `start`. */
1321
+ poststart?: string;
1322
+ /** Run with the `npm restart` command, before `restart`. */
1323
+ prerestart?: string;
1324
+ /** Run with the `npm restart` command. */
1325
+ restart?: string;
1326
+ /** Run with the `npm restart` command, after `restart`. */
1327
+ postrestart?: string;
1328
+ } & Partial<Record<string, string>>;
1329
+ /**
1330
+ * Dependencies of the package. The version range is a string which has one or
1331
+ * more space-separated descriptors.
1332
+ */
1333
+ export type Dependency = Partial<Record<string, string>>;
1334
+ /**
1335
+ * Recursive map describing selective dependency version overrides supported by npm.
1336
+ */
1337
+ export type DependencyOverrides = {
1338
+ [packageName in string]: string | undefined | DependencyOverrides;
1339
+ };
1340
+ /**
1341
+ * Specifies requirements for development environment components.
1342
+ */
1343
+ export interface DevEngineDependency {
1344
+ name: string;
1345
+ version?: string;
1346
+ onFail?: "ignore" | "warn" | "error" | "download";
1347
+ }
1348
+ /**
1349
+ * A mapping of conditions and the paths to which they resolve.
1350
+ */
1351
+ export interface ExportConditions {
1352
+ [condition: string]: Exports;
1353
+ }
1354
+ /**
1355
+ * Entry points of a module, optionally with conditions and subpath exports.
1356
+ */
1357
+ export type Exports = null | string | Array<string | ExportConditions> | ExportConditions;
1358
+ /**
1359
+ * Import map entries of a module, optionally with conditions and subpath imports.
1360
+ */
1361
+ export interface Imports {
1362
+ [key: `#${string}`]: Exports;
1363
+ }
1364
+ /**
1365
+ * Non-standard entry point fields used by various bundlers.
1366
+ */
1367
+ export interface NonStandardEntryPoints {
1368
+ /** An ECMAScript module ID that is the primary entry point to the program. */
1369
+ module?: string;
1370
+ /** A module ID with untranspiled code that is the primary entry point to the program. */
1371
+ esnext?: string | {
1372
+ [moduleName: string]: string | undefined;
1373
+ main?: string;
1374
+ browser?: string;
1375
+ };
1376
+ /** A hint to JavaScript bundlers or component tools when packaging modules for client side use. */
1377
+ browser?: string | Partial<Record<string, string | false>>;
1378
+ /**
1379
+ * Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
1380
+ *
1381
+ * @see {@link https://webpack.js.org/guides/tree-shaking/ | Webpack Tree Shaking}
1382
+ */
1383
+ sideEffects?: boolean | string[];
1384
+ }
1385
+ /**
1386
+ * TypeScript-specific configuration fields.
1387
+ */
1388
+ export interface TypeScriptConfiguration {
1389
+ /** Location of the bundled TypeScript declaration file. */
1390
+ types?: string;
1391
+ /** Version selection map of TypeScript. */
1392
+ typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
1393
+ /** Location of the bundled TypeScript declaration file. Alias of `types`. */
1394
+ typings?: string;
1395
+ }
1396
+ /**
1397
+ * An alternative configuration for workspaces.
1398
+ */
1399
+ export interface WorkspaceConfig {
1400
+ /** An array of workspace pattern strings which contain the workspace packages. */
1401
+ packages?: WorkspacePattern[];
1402
+ /**
1403
+ * Designed to solve the problem of packages which break when their `node_modules`
1404
+ * are moved to the root workspace directory - a process known as hoisting.
1405
+ *
1406
+ * @see {@link https://classic.yarnpkg.com/blog/2018/02/15/nohoist/ | Yarn nohoist}
1407
+ */
1408
+ nohoist?: WorkspacePattern[];
1409
+ }
1410
+ /**
1411
+ * A workspace pattern points to a directory or group of directories which
1412
+ * contain packages that should be included in the workspace installation process.
1413
+ *
1414
+ * @example
1415
+ * `docs` - Include the docs directory and install its dependencies.
1416
+ *
1417
+ * @example
1418
+ * `packages/*` - Include all nested directories within the packages directory.
1419
+ */
1420
+ export type WorkspacePattern = string;
1421
+ /**
1422
+ * Yarn-specific configuration fields.
1423
+ */
1424
+ export interface YarnConfiguration {
1425
+ /**
1426
+ * If your package only allows one version of a given dependency, and you'd like
1427
+ * to enforce the same behavior as `yarn install --flat` on the command-line,
1428
+ * set this to `true`.
1429
+ */
1430
+ flat?: boolean;
1431
+ /** Selective version resolutions. Allows the definition of custom package versions inside dependencies. */
1432
+ resolutions?: Dependency;
1433
+ }
1434
+ /**
1435
+ * JSPM-specific configuration fields.
1436
+ */
1437
+ export interface JSPMConfiguration {
1438
+ /** JSPM configuration. */
1439
+ jspm?: PackageJson;
1440
+ }
1441
+ /**
1442
+ * Publish configuration options.
1443
+ */
1444
+ export interface PublishConfig {
1445
+ /** Additional properties from the npm docs on `publishConfig`. */
1446
+ [additionalProperties: string]: JsonValue | undefined;
1447
+ /**
1448
+ * When publishing scoped packages, the access level defaults to restricted.
1449
+ * If you want your scoped package to be publicly viewable set `--access=public`.
1450
+ */
1451
+ access?: "public" | "restricted";
1452
+ /**
1453
+ * The base URL of the npm registry.
1454
+ *
1455
+ * @defaultValue `'https://registry.npmjs.org/'`
1456
+ */
1457
+ registry?: string;
1458
+ /**
1459
+ * The tag to publish the package under.
1460
+ *
1461
+ * @defaultValue `'latest'`
1462
+ */
1463
+ tag?: string;
1464
+ }
1465
+ /**
1466
+ * Type for npm's `package.json` file containing standard npm properties.
1467
+ *
1468
+ * @see {@link https://docs.npmjs.com/creating-a-package-json-file | npm docs}
1469
+ */
1470
+ export interface PackageJsonStandard {
1471
+ /** The name of the package. */
1472
+ name?: string;
1473
+ /** Package version, parseable by `node-semver`. */
1474
+ version?: string;
1475
+ /** Package description, listed in `npm search`. */
1476
+ description?: string;
1477
+ /** Keywords associated with package, listed in `npm search`. */
1478
+ keywords?: string[];
1479
+ /** The URL to the package's homepage. */
1480
+ homepage?: LiteralUnion<".", string>;
1481
+ /** The URL to the package's issue tracker and/or the email address to which issues should be reported. */
1482
+ bugs?: BugsLocation;
1483
+ /** The license for the package. */
1484
+ license?: string;
1485
+ /** The licenses for the package. */
1486
+ licenses?: Array<{
1487
+ type?: string;
1488
+ url?: string;
1489
+ }>;
1490
+ /** The author of the package. */
1491
+ author?: Person;
1492
+ /** A list of people who contributed to the package. */
1493
+ contributors?: Person[];
1494
+ /** A list of people who maintain the package. */
1495
+ maintainers?: Person[];
1496
+ /** The files included in the package. */
1497
+ files?: string[];
1498
+ /**
1499
+ * Resolution algorithm for importing ".js" files from the package's scope.
1500
+ *
1501
+ * @see {@link https://nodejs.org/api/esm.html#esm_package_json_type_field | Node.js ESM docs}
1502
+ */
1503
+ type?: "module" | "commonjs";
1504
+ /** The module ID that is the primary entry point to the program. */
1505
+ main?: string;
1506
+ /**
1507
+ * Subpath exports to define entry points of the package.
1508
+ *
1509
+ * @see {@link https://nodejs.org/api/packages.html#subpath-exports | Node.js Subpath exports}
1510
+ */
1511
+ exports?: Exports;
1512
+ /**
1513
+ * Subpath imports to define internal package import maps.
1514
+ *
1515
+ * @see {@link https://nodejs.org/api/packages.html#subpath-imports | Node.js Subpath imports}
1516
+ */
1517
+ imports?: Imports;
1518
+ /** The executable files that should be installed into the `PATH`. */
1519
+ bin?: string | Partial<Record<string, string>>;
1520
+ /** Filenames to put in place for the `man` program to find. */
1521
+ man?: string | string[];
1522
+ /** Indicates the structure of the package. */
1523
+ directories?: DirectoryLocations;
1524
+ /** Location for the code repository. */
1525
+ repository?: string | {
1526
+ type: string;
1527
+ url: string;
1528
+ /** Relative path to package.json if it is placed in non-root directory (for monorepos). */
1529
+ directory?: string;
1530
+ };
1531
+ /** Script commands that are run at various times in the lifecycle of the package. */
1532
+ scripts?: Scripts;
1533
+ /** Is used to set configuration parameters used in package scripts that persist across upgrades. */
1534
+ config?: JsonObject;
1535
+ /** The dependencies of the package. */
1536
+ dependencies?: Dependency;
1537
+ /** Additional tooling dependencies that are not required for the package to work. */
1538
+ devDependencies?: Dependency;
1539
+ /** Dependencies that are skipped if they fail to install. */
1540
+ optionalDependencies?: Dependency;
1541
+ /** Dependencies that will usually be required by the package user directly or via another dependency. */
1542
+ peerDependencies?: Dependency;
1543
+ /** Indicate peer dependencies that are optional. */
1544
+ peerDependenciesMeta?: Partial<Record<string, {
1545
+ optional: true;
1546
+ }>>;
1547
+ /** Package names that are bundled when the package is published. */
1548
+ bundledDependencies?: string[];
1549
+ /** Alias of `bundledDependencies`. */
1550
+ bundleDependencies?: string[];
1551
+ /** Overrides is used to support selective version overrides using npm. */
1552
+ overrides?: DependencyOverrides;
1553
+ /** Engines that this package runs on. */
1554
+ engines?: {
1555
+ [EngineName in "npm" | "node" | string]?: string;
1556
+ };
1557
+ /**
1558
+ * Whether to enforce engine requirements strictly.
1559
+ *
1560
+ * @deprecated This field is no longer used by npm. Use the `engine-strict` npm config instead.
1561
+ */
1562
+ engineStrict?: boolean;
1563
+ /** Operating systems the module runs on. */
1564
+ os?: Array<LiteralUnion<"aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32" | "!aix" | "!darwin" | "!freebsd" | "!linux" | "!openbsd" | "!sunos" | "!win32", string>>;
1565
+ /** CPU architectures the module runs on. */
1566
+ cpu?: Array<LiteralUnion<"arm" | "arm64" | "ia32" | "mips" | "mipsel" | "ppc" | "ppc64" | "s390" | "s390x" | "x32" | "x64" | "!arm" | "!arm64" | "!ia32" | "!mips" | "!mipsel" | "!ppc" | "!ppc64" | "!s390" | "!s390x" | "!x32" | "!x64", string>>;
1567
+ /** Define the runtime and package manager for developing the current project. */
1568
+ devEngines?: {
1569
+ os?: DevEngineDependency | DevEngineDependency[];
1570
+ cpu?: DevEngineDependency | DevEngineDependency[];
1571
+ libc?: DevEngineDependency | DevEngineDependency[];
1572
+ runtime?: DevEngineDependency | DevEngineDependency[];
1573
+ packageManager?: DevEngineDependency | DevEngineDependency[];
1574
+ };
1575
+ /**
1576
+ * If set to `true`, a warning will be shown if package is installed locally.
1577
+ *
1578
+ * @deprecated This field is no longer used by npm. Use the `bin` field to create CLI tools instead.
1579
+ */
1580
+ preferGlobal?: boolean;
1581
+ /** If set to `true`, then npm will refuse to publish it. */
1582
+ private?: boolean;
1583
+ /** A set of config values that will be used at publish-time. */
1584
+ publishConfig?: PublishConfig;
1585
+ /**
1586
+ * Describes and notifies consumers of a package's monetary support information.
1587
+ *
1588
+ * @see {@link https://github.com/npm/rfcs/blob/main/implemented/0017-add-funding-support.md | npm funding RFC}
1589
+ */
1590
+ funding?: string | {
1591
+ /** The type of funding. */
1592
+ type?: LiteralUnion<"github" | "opencollective" | "patreon" | "individual" | "foundation" | "corporation", string>;
1593
+ /** The URL to the funding page. */
1594
+ url: string;
1595
+ };
1596
+ /**
1597
+ * Used to configure npm workspaces / Yarn workspaces.
1598
+ *
1599
+ * @remarks
1600
+ * Workspaces allow you to manage multiple packages within the same repository
1601
+ * in such a way that you only need to run your install command once in order
1602
+ * to install all of them in a single pass.
1603
+ *
1604
+ * Please note that the top-level `private` property of `package.json` must
1605
+ * be set to `true` in order to use workspaces.
1606
+ *
1607
+ * @see {@link https://docs.npmjs.com/cli/using-npm/workspaces | npm workspaces}
1608
+ * @see {@link https://classic.yarnpkg.com/docs/workspaces/ | Yarn workspaces}
1609
+ */
1610
+ workspaces?: WorkspacePattern[] | WorkspaceConfig;
1611
+ }
1612
+ /**
1613
+ * Type for `package.json` file used by the Node.js runtime.
1614
+ *
1615
+ * @see {@link https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions | Node.js docs}
1616
+ */
1617
+ export interface NodeJsStandard {
1618
+ /**
1619
+ * Defines which package manager is expected to be used when working on the current project.
1620
+ *
1621
+ * @remarks
1622
+ * It can be set to any of the supported package managers, and will ensure that
1623
+ * your teams use the exact same package manager versions without having to
1624
+ * install anything else other than Node.js.
1625
+ *
1626
+ * This field is currently experimental and needs to be opted-in; check the
1627
+ * Corepack page for details about the procedure.
1628
+ *
1629
+ * @example
1630
+ * ```json
1631
+ * {
1632
+ * "packageManager": "pnpm@8.0.0"
1633
+ * }
1634
+ * ```
1635
+ *
1636
+ * @see {@link https://nodejs.org/api/corepack.html | Node.js Corepack docs}
1637
+ */
1638
+ packageManager?: string;
1639
+ }
1640
+ }
1641
+
1642
+ /**
1643
+ * Type for npm's `package.json` file.
1644
+ *
1645
+ * @remarks
1646
+ * Also includes types for fields used by other popular projects, like TypeScript and Yarn.
1647
+ *
1648
+ * @see {@link https://docs.npmjs.com/creating-a-package-json-file | npm docs}
1649
+ *
1650
+ * @public
1651
+ */
1652
+ export declare type PackageJson = JsonObject & PackageJson.NodeJsStandard & PackageJson.PackageJsonStandard & PackageJson.NonStandardEntryPoints & PackageJson.TypeScriptConfiguration & PackageJson.YarnConfiguration & PackageJson.JSPMConfiguration;
1653
+
1106
1654
  /**
1107
1655
  * Plugin to transform package.json for distribution.
1108
1656
  *
@@ -1254,11 +1802,20 @@ export declare interface PackageJsonTransformPluginOptions {
1254
1802
  transform?: (pkg: PackageJson) => PackageJson;
1255
1803
  }
1256
1804
 
1805
+ /**
1806
+ * Matches any primitive value.
1807
+ *
1808
+ * @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive | MDN Primitive}
1809
+ *
1810
+ * @public
1811
+ */
1812
+ export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1813
+
1257
1814
  /**
1258
1815
  * Async RSLib configuration function type.
1259
1816
  * @public
1260
1817
  */
1261
- declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
1818
+ export declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
1262
1819
 
1263
1820
  /**
1264
1821
  * Function to transform package.json during the build process.
@@ -1442,15 +1999,13 @@ export declare type TsDocLintErrorBehavior = "warn" | "error" | "throw";
1442
1999
  * | Local | `"error"` | Log and continue |
1443
2000
  * | CI | `"throw"` | Fail the build |
1444
2001
  *
1445
- * ## Required Dependencies
2002
+ * ## Dependencies
1446
2003
  *
1447
- * This plugin requires the following optional peer dependencies:
2004
+ * This plugin uses ESLint programmatically with the following packages:
1448
2005
  * - `eslint`
1449
2006
  * - `@typescript-eslint/parser`
1450
2007
  * - `eslint-plugin-tsdoc`
1451
2008
  *
1452
- * Install with: `pnpm add -D eslint @typescript-eslint/parser eslint-plugin-tsdoc`
1453
- *
1454
2009
  * @param options - Plugin configuration options
1455
2010
  * @returns An Rsbuild plugin that validates TSDoc comments before the build
1456
2011
  *
@@ -1663,6 +2218,11 @@ export declare interface TsDocOptions {
1663
2218
  * TSDoc warnings include unknown tags, malformed syntax, and other
1664
2219
  * documentation issues detected by API Extractor during processing.
1665
2220
  *
2221
+ * **Important:** This setting only applies to first-party warnings (from your
2222
+ * project's source code). Third-party warnings from dependencies in
2223
+ * `node_modules/` are always logged but never fail the build, since they
2224
+ * cannot be fixed by the consuming project.
2225
+ *
1666
2226
  * @defaultValue `"fail"` in CI environments (`CI` or `GITHUB_ACTIONS` env vars),
1667
2227
  * `"log"` otherwise
1668
2228
  */
package/index.js CHANGED
@@ -265,7 +265,7 @@ const AutoEntryPlugin = (options)=>{
265
265
  }
266
266
  };
267
267
  };
268
- var lib_namespaceObject = JSON.parse('{"$schema":"https://json.schemastore.org/tsconfig.json","compilerOptions":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"${configDir}/dist","declarationMap":false,"emitDeclarationOnly":false,"esModuleInterop":true,"explainFiles":false,"forceConsistentCasingInFileNames":true,"incremental":true,"isolatedDeclarations":true,"isolatedModules":true,"jsx":"preserve","lib":["esnext"],"module":"nodenext","moduleResolution":"nodenext","outDir":"${configDir}/dist","resolveJsonModule":true,"rootDir":"${configDir}","skipLibCheck":true,"sourceMap":false,"strict":true,"strictNullChecks":true,"target":"es2023","tsBuildInfoFile":"${configDir}/dist/.tsbuildinfo.lib","typeRoots":["${configDir}/node_modules/@types","${configDir}/types"],"verbatimModuleSyntax":true},"exclude":["${configDir}/node_modules","${configDir}/dist/**/*"],"include":["${configDir}/types/*.ts","${configDir}/package.json","${configDir}/*.ts","${configDir}/*.cts","${configDir}/*.mts","${configDir}/src/**/*.ts","${configDir}/src/**/*.tsx","${configDir}/src/**/*.cts","${configDir}/src/**/*.mts","${configDir}/lib/**/*.ts","${configDir}/lib/**/*.tsx","${configDir}/lib/**/*.cts","${configDir}/lib/**/*.mts","${configDir}/public/**/*.json"]}');
268
+ var lib_namespaceObject = JSON.parse('{"$schema":"https://json.schemastore.org/tsconfig.json","compilerOptions":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"${configDir}/dist","declarationMap":false,"emitDeclarationOnly":false,"esModuleInterop":true,"explainFiles":false,"forceConsistentCasingInFileNames":true,"incremental":true,"isolatedDeclarations":false,"isolatedModules":true,"jsx":"preserve","lib":["esnext"],"module":"nodenext","moduleResolution":"nodenext","outDir":"${configDir}/dist","resolveJsonModule":true,"rootDir":"${configDir}","skipLibCheck":true,"sourceMap":false,"strict":true,"strictNullChecks":true,"target":"es2023","tsBuildInfoFile":"${configDir}/dist/.tsbuildinfo.lib","typeRoots":["${configDir}/node_modules/@types","${configDir}/types"],"verbatimModuleSyntax":true},"exclude":["${configDir}/node_modules","${configDir}/dist/**/*"],"include":["${configDir}/types/*.ts","${configDir}/package.json","${configDir}/*.ts","${configDir}/*.cts","${configDir}/*.mts","${configDir}/src/**/*.ts","${configDir}/src/**/*.tsx","${configDir}/src/**/*.cts","${configDir}/src/**/*.mts","${configDir}/lib/**/*.ts","${configDir}/lib/**/*.tsx","${configDir}/lib/**/*.cts","${configDir}/lib/**/*.mts","${configDir}/public/**/*.json"]}');
269
269
  const requireCJS = createRequire(import.meta.url);
270
270
  const jsonImports = new Map([
271
271
  [
@@ -528,6 +528,7 @@ async function bundleDtsFiles(options) {
528
528
  const tsdocOptions = "object" == typeof apiModel ? apiModel.tsdoc : void 0;
529
529
  const tsdocMetadataOption = "object" == typeof apiModel ? apiModel.tsdocMetadata : void 0;
530
530
  const tsdocWarnings = tsdocOptions?.warnings ?? (TsDocConfigBuilder.isCI() ? "fail" : "log");
531
+ const forgottenExports = ("object" == typeof apiModel ? apiModel.forgottenExports : void 0) ?? "include";
531
532
  const tsdocMetadataEnabled = apiModelEnabled && (void 0 === tsdocMetadataOption || true === tsdocMetadataOption || "object" == typeof tsdocMetadataOption && false !== tsdocMetadataOption.enabled);
532
533
  const tsdocMetadataFilename = "object" == typeof tsdocMetadataOption && tsdocMetadataOption.filename ? tsdocMetadataOption.filename : "tsdoc-metadata.json";
533
534
  getApiExtractorPath();
@@ -568,6 +569,7 @@ async function bundleDtsFiles(options) {
568
569
  configObject: {
569
570
  projectFolder: cwd,
570
571
  mainEntryPointFilePath: tempDtsPath,
572
+ enumMemberOrder: "preserve",
571
573
  compiler: {
572
574
  tsconfigFilePath: tsconfigPath
573
575
  },
@@ -590,6 +592,7 @@ async function bundleDtsFiles(options) {
590
592
  tsdocConfigFile: tsdocConfigFile
591
593
  });
592
594
  const collectedTsdocWarnings = [];
595
+ const collectedForgottenExports = [];
593
596
  const extractorResult = Extractor.invoke(extractorConfig, {
594
597
  localBuild: true,
595
598
  showVerboseMessages: false,
@@ -613,17 +616,41 @@ async function bundleDtsFiles(options) {
613
616
  });
614
617
  message.logLevel = "none";
615
618
  }
619
+ if ("ae-forgotten-export" === message.messageId && message.text) if ("ignore" === forgottenExports) message.logLevel = "none";
620
+ else {
621
+ collectedForgottenExports.push({
622
+ text: message.text,
623
+ sourceFilePath: message.sourceFilePath,
624
+ sourceFileLine: message.sourceFileLine,
625
+ sourceFileColumn: message.sourceFileColumn
626
+ });
627
+ message.logLevel = "none";
628
+ }
616
629
  }
617
630
  });
618
631
  if (!extractorResult.succeeded) throw new Error(`API Extractor failed for entry "${entryName}"`);
632
+ const formatWarning = (warning)=>{
633
+ const location = warning.sourceFilePath ? `${picocolors.cyan((0, external_node_path_.relative)(cwd, warning.sourceFilePath))}${warning.sourceFileLine ? `:${warning.sourceFileLine}` : ""}${warning.sourceFileColumn ? `:${warning.sourceFileColumn}` : ""}` : null;
634
+ return location ? `${location}: ${picocolors.yellow(warning.text)}` : picocolors.yellow(warning.text);
635
+ };
619
636
  if (collectedTsdocWarnings.length > 0) {
620
- const formatWarning = (warning)=>{
621
- const location = warning.sourceFilePath ? `${picocolors.cyan((0, external_node_path_.relative)(cwd, warning.sourceFilePath))}${warning.sourceFileLine ? `:${warning.sourceFileLine}` : ""}${warning.sourceFileColumn ? `:${warning.sourceFileColumn}` : ""}` : null;
622
- return location ? `${location}: ${picocolors.yellow(warning.text)}` : picocolors.yellow(warning.text);
623
- };
624
- const warningMessages = collectedTsdocWarnings.map(formatWarning).join("\n ");
625
- if ("fail" === tsdocWarnings) throw new Error(`TSDoc validation failed for entry "${entryName}":\n ${warningMessages}`);
626
- if ("log" === tsdocWarnings) core_logger.warn(`TSDoc warnings for entry "${entryName}":\n ${warningMessages}`);
637
+ const isThirdParty = (warning)=>warning.sourceFilePath?.includes("node_modules/") ?? false;
638
+ const firstPartyWarnings = collectedTsdocWarnings.filter((w)=>!isThirdParty(w));
639
+ const thirdPartyWarnings = collectedTsdocWarnings.filter(isThirdParty);
640
+ if (thirdPartyWarnings.length > 0) {
641
+ const thirdPartyMessages = thirdPartyWarnings.map(formatWarning).join("\n ");
642
+ core_logger.warn(`TSDoc warnings from dependencies for entry "${entryName}" (cannot be fixed, bundled types may have documentation issues):\n ${thirdPartyMessages}`);
643
+ }
644
+ if (firstPartyWarnings.length > 0) {
645
+ const firstPartyMessages = firstPartyWarnings.map(formatWarning).join("\n ");
646
+ if ("fail" === tsdocWarnings) throw new Error(`TSDoc validation failed for entry "${entryName}":\n ${firstPartyMessages}`);
647
+ if ("log" === tsdocWarnings) core_logger.warn(`TSDoc warnings for entry "${entryName}":\n ${firstPartyMessages}`);
648
+ }
649
+ }
650
+ if (collectedForgottenExports.length > 0) {
651
+ const forgottenMessages = collectedForgottenExports.map(formatWarning).join("\n ");
652
+ if ("error" === forgottenExports) throw new Error(`Forgotten exports detected for entry "${entryName}":\n ${forgottenMessages}`);
653
+ if ("include" === forgottenExports) core_logger.warn(`Forgotten exports for entry "${entryName}":\n ${forgottenMessages}`);
627
654
  }
628
655
  if (generateApiModel && tempApiModelPath) apiModelPath = tempApiModelPath;
629
656
  if (generateTsdocMetadata && tempTsdocMetadataPath) tsdocMetadataPath = tempTsdocMetadataPath;
@@ -876,7 +903,7 @@ function runTsgo(options) {
876
903
  if (apiModelPath) {
877
904
  const defaultApiModelFilename = packageJson.name ? `${getUnscopedPackageName(packageJson.name)}.api.json` : "api.json";
878
905
  const apiModelFilename = "object" == typeof options.apiModel && options.apiModel.filename ? options.apiModel.filename : defaultApiModelFilename;
879
- const apiModelContent = await readFile(apiModelPath, "utf-8");
906
+ const apiModelContent = (await readFile(apiModelPath, "utf-8")).replaceAll("\r\n", "\n");
880
907
  const apiModelSource = new context.sources.OriginalSource(apiModelContent, apiModelFilename);
881
908
  context.compilation.emitAsset(apiModelFilename, apiModelSource);
882
909
  if (filesArray) filesArray.add(`!${apiModelFilename}`);
@@ -899,14 +926,14 @@ function runTsgo(options) {
899
926
  if (tsdocMetadataPath) {
900
927
  const tsdocMetadataOption = "object" == typeof options.apiModel ? options.apiModel.tsdocMetadata : void 0;
901
928
  const tsdocMetadataFilename = "object" == typeof tsdocMetadataOption && tsdocMetadataOption.filename ? tsdocMetadataOption.filename : "tsdoc-metadata.json";
902
- const tsdocMetadataContent = await readFile(tsdocMetadataPath, "utf-8");
929
+ const tsdocMetadataContent = (await readFile(tsdocMetadataPath, "utf-8")).replaceAll("\r\n", "\n");
903
930
  const tsdocMetadataSource = new context.sources.OriginalSource(tsdocMetadataContent, tsdocMetadataFilename);
904
931
  context.compilation.emitAsset(tsdocMetadataFilename, tsdocMetadataSource);
905
932
  if (filesArray) filesArray.add(tsdocMetadataFilename);
906
933
  core_logger.info(`${picocolors.dim(`[${envId}]`)} Emitted TSDoc metadata: ${tsdocMetadataFilename}`);
907
934
  }
908
935
  if (tsdocConfigPath) {
909
- const tsdocConfigContent = await readFile(tsdocConfigPath, "utf-8");
936
+ const tsdocConfigContent = (await readFile(tsdocConfigPath, "utf-8")).replaceAll("\r\n", "\n");
910
937
  const tsdocConfigSource = new context.sources.OriginalSource(tsdocConfigContent, "tsdoc.json");
911
938
  context.compilation.emitAsset("tsdoc.json", tsdocConfigSource);
912
939
  if (filesArray) filesArray.add("!tsdoc.json");
@@ -1714,27 +1741,10 @@ async function runTsDocLint(options, cwd) {
1714
1741
  const shouldPersist = TsDocConfigBuilder.shouldPersist(persistConfig);
1715
1742
  const tsdocConfigOutputPath = TsDocConfigBuilder.getConfigPath(persistConfig, cwd);
1716
1743
  const tsdocConfigPath = await TsDocConfigBuilder.writeConfigFile(tsdocOptions, (0, external_node_path_.dirname)(tsdocConfigOutputPath));
1717
- let ESLint;
1718
- let tsParserModule;
1719
- let tsdocPluginModule;
1720
- const missingPackages = [];
1721
- try {
1722
- const eslintModule = await import("eslint");
1723
- ESLint = eslintModule.ESLint;
1724
- } catch {
1725
- missingPackages.push("eslint");
1726
- }
1727
- try {
1728
- tsParserModule = await import("@typescript-eslint/parser");
1729
- } catch {
1730
- missingPackages.push("@typescript-eslint/parser");
1731
- }
1732
- try {
1733
- tsdocPluginModule = await import("eslint-plugin-tsdoc");
1734
- } catch {
1735
- missingPackages.push("eslint-plugin-tsdoc");
1736
- }
1737
- if (missingPackages.length > 0 || !ESLint) throw new Error(`TsDocLintPlugin requires: ${missingPackages.join(", ")}\nInstall with: pnpm add -D ${missingPackages.join(" ")}`);
1744
+ const eslintModule = await import("eslint");
1745
+ const tsParserModule = await import("@typescript-eslint/parser");
1746
+ const tsdocPluginModule = await import("eslint-plugin-tsdoc");
1747
+ const { ESLint } = eslintModule;
1738
1748
  const tsParser = tsParserModule.default ?? tsParserModule;
1739
1749
  const tsdocPlugin = tsdocPluginModule.default ?? tsdocPluginModule;
1740
1750
  const discovery = discoverFilesToLint(options, cwd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/rslib-builder",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "private": false,
5
5
  "description": "RSlib-based build system for Node.js libraries with automatic package.json transformation, TypeScript declaration bundling, and multi-target support",
6
6
  "homepage": "https://github.com/savvy-web/rslib-builder",
@@ -27,22 +27,22 @@
27
27
  "@microsoft/tsdoc": "^0.16.0",
28
28
  "@microsoft/tsdoc-config": "^0.18.0",
29
29
  "@pnpm/exportable-manifest": "^1000.3.1",
30
+ "@typescript-eslint/parser": "^8.53.1",
30
31
  "deep-equal": "^2.2.3",
32
+ "eslint": "^9.39.2",
33
+ "eslint-plugin-tsdoc": "^0.5.0",
31
34
  "glob": "^13.0.0",
32
35
  "picocolors": "^1.1.1",
33
- "sort-package-json": "^3.6.0",
36
+ "sort-package-json": "^3.6.1",
34
37
  "tmp": "^0.2.5",
35
- "workspace-tools": "^0.40.3",
38
+ "workspace-tools": "^0.40.4",
36
39
  "yaml": "^2.8.2"
37
40
  },
38
41
  "peerDependencies": {
39
42
  "@microsoft/api-extractor": "^7.55.2",
40
- "@rslib/core": "^0.19.2",
41
- "@types/node": "^25.0.9",
42
- "@typescript-eslint/parser": "^8.0.0",
43
- "@typescript/native-preview": "^7.0.0-dev.20260120.1",
44
- "eslint": "^9.0.0",
45
- "eslint-plugin-tsdoc": "^0.5.0",
43
+ "@rslib/core": "^0.19.3",
44
+ "@types/node": "^25.0.10",
45
+ "@typescript/native-preview": "^7.0.0-dev.20260124.1",
46
46
  "typescript": "^5.9.3"
47
47
  },
48
48
  "peerDependenciesMeta": {
@@ -52,20 +52,14 @@
52
52
  "@rslib/core": {
53
53
  "optional": false
54
54
  },
55
- "@typescript-eslint/parser": {
56
- "optional": true
55
+ "@types/node": {
56
+ "optional": false
57
57
  },
58
58
  "@typescript/native-preview": {
59
59
  "optional": false
60
60
  },
61
- "eslint": {
62
- "optional": true
63
- },
64
- "eslint-plugin-tsdoc": {
65
- "optional": true
66
- },
67
61
  "typescript": {
68
- "optional": false
62
+ "optional": true
69
63
  }
70
64
  },
71
65
  "files": [
@@ -11,7 +11,7 @@
11
11
  "explainFiles": false,
12
12
  "forceConsistentCasingInFileNames": true,
13
13
  "incremental": true,
14
- "isolatedDeclarations": true,
14
+ "isolatedDeclarations": false,
15
15
  "isolatedModules": true,
16
16
  "jsx": "preserve",
17
17
  "lib": ["esnext"],
@@ -1,11 +1,11 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.55.2"
9
- }
10
- ]
11
- }
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.55.2"
9
+ }
10
+ ]
11
+ }