@savvy-web/rslib-builder 0.5.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/index.d.ts CHANGED
@@ -119,6 +119,18 @@ export declare interface ApiModelOptions {
119
119
  * @defaultValue true (enabled when apiModel is enabled)
120
120
  */
121
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";
122
134
  }
123
135
 
124
136
  /**
@@ -934,7 +946,7 @@ export declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
934
946
  *
935
947
  * @public
936
948
  */
937
- declare type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
949
+ export declare type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
938
950
 
939
951
  /**
940
952
  * Builder for Node.js ESM libraries using RSlib.
@@ -1797,13 +1809,13 @@ export declare interface PackageJsonTransformPluginOptions {
1797
1809
  *
1798
1810
  * @public
1799
1811
  */
1800
- declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1812
+ export declare type Primitive = null | undefined | string | number | boolean | symbol | bigint;
1801
1813
 
1802
1814
  /**
1803
1815
  * Async RSLib configuration function type.
1804
1816
  * @public
1805
1817
  */
1806
- declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
1818
+ export declare type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
1807
1819
 
1808
1820
  /**
1809
1821
  * Function to transform package.json during the build process.
package/index.js CHANGED
@@ -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,27 @@ 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
637
  const isThirdParty = (warning)=>warning.sourceFilePath?.includes("node_modules/") ?? false;
621
638
  const firstPartyWarnings = collectedTsdocWarnings.filter((w)=>!isThirdParty(w));
622
639
  const thirdPartyWarnings = collectedTsdocWarnings.filter(isThirdParty);
623
- const formatWarning = (warning)=>{
624
- const location = warning.sourceFilePath ? `${picocolors.cyan((0, external_node_path_.relative)(cwd, warning.sourceFilePath))}${warning.sourceFileLine ? `:${warning.sourceFileLine}` : ""}${warning.sourceFileColumn ? `:${warning.sourceFileColumn}` : ""}` : null;
625
- return location ? `${location}: ${picocolors.yellow(warning.text)}` : picocolors.yellow(warning.text);
626
- };
627
640
  if (thirdPartyWarnings.length > 0) {
628
641
  const thirdPartyMessages = thirdPartyWarnings.map(formatWarning).join("\n ");
629
642
  core_logger.warn(`TSDoc warnings from dependencies for entry "${entryName}" (cannot be fixed, bundled types may have documentation issues):\n ${thirdPartyMessages}`);
@@ -634,6 +647,11 @@ async function bundleDtsFiles(options) {
634
647
  if ("log" === tsdocWarnings) core_logger.warn(`TSDoc warnings for entry "${entryName}":\n ${firstPartyMessages}`);
635
648
  }
636
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}`);
654
+ }
637
655
  if (generateApiModel && tempApiModelPath) apiModelPath = tempApiModelPath;
638
656
  if (generateTsdocMetadata && tempTsdocMetadataPath) tsdocMetadataPath = tempTsdocMetadataPath;
639
657
  if (banner || footer) {
@@ -885,7 +903,7 @@ function runTsgo(options) {
885
903
  if (apiModelPath) {
886
904
  const defaultApiModelFilename = packageJson.name ? `${getUnscopedPackageName(packageJson.name)}.api.json` : "api.json";
887
905
  const apiModelFilename = "object" == typeof options.apiModel && options.apiModel.filename ? options.apiModel.filename : defaultApiModelFilename;
888
- const apiModelContent = await readFile(apiModelPath, "utf-8");
906
+ const apiModelContent = (await readFile(apiModelPath, "utf-8")).replaceAll("\r\n", "\n");
889
907
  const apiModelSource = new context.sources.OriginalSource(apiModelContent, apiModelFilename);
890
908
  context.compilation.emitAsset(apiModelFilename, apiModelSource);
891
909
  if (filesArray) filesArray.add(`!${apiModelFilename}`);
@@ -908,14 +926,14 @@ function runTsgo(options) {
908
926
  if (tsdocMetadataPath) {
909
927
  const tsdocMetadataOption = "object" == typeof options.apiModel ? options.apiModel.tsdocMetadata : void 0;
910
928
  const tsdocMetadataFilename = "object" == typeof tsdocMetadataOption && tsdocMetadataOption.filename ? tsdocMetadataOption.filename : "tsdoc-metadata.json";
911
- const tsdocMetadataContent = await readFile(tsdocMetadataPath, "utf-8");
929
+ const tsdocMetadataContent = (await readFile(tsdocMetadataPath, "utf-8")).replaceAll("\r\n", "\n");
912
930
  const tsdocMetadataSource = new context.sources.OriginalSource(tsdocMetadataContent, tsdocMetadataFilename);
913
931
  context.compilation.emitAsset(tsdocMetadataFilename, tsdocMetadataSource);
914
932
  if (filesArray) filesArray.add(tsdocMetadataFilename);
915
933
  core_logger.info(`${picocolors.dim(`[${envId}]`)} Emitted TSDoc metadata: ${tsdocMetadataFilename}`);
916
934
  }
917
935
  if (tsdocConfigPath) {
918
- const tsdocConfigContent = await readFile(tsdocConfigPath, "utf-8");
936
+ const tsdocConfigContent = (await readFile(tsdocConfigPath, "utf-8")).replaceAll("\r\n", "\n");
919
937
  const tsdocConfigSource = new context.sources.OriginalSource(tsdocConfigContent, "tsdoc.json");
920
938
  context.compilation.emitAsset("tsdoc.json", tsdocConfigSource);
921
939
  if (filesArray) filesArray.add("!tsdoc.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/rslib-builder",
3
- "version": "0.5.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",
@@ -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
+ }