rolldown-plugin-dts 0.9.0 → 0.9.1

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
@@ -31,6 +31,11 @@ You can find a real demo in [here](./rolldown.config.ts).
31
31
 
32
32
  ```ts
33
33
  interface Options {
34
+ /**
35
+ * The directory where the the plugin will look for the `tsconfig.json` file.
36
+ */
37
+ cwd?: string
38
+
34
39
  /**
35
40
  * When entries are `.d.ts` files (instead of `.ts` files), this option should be set to `true`.
36
41
  *
@@ -72,6 +77,11 @@ interface Options {
72
77
  | boolean
73
78
  | Omit<IsolatedDeclarationsOptions, 'sourcemap'>
74
79
 
80
+ /**
81
+ * When `true`, the plugin will generate declaration maps for `.d.ts` files.
82
+ */
83
+ sourcemap?: boolean
84
+
75
85
  /** Resolve external types used in dts files from `node_modules` */
76
86
  resolve?: boolean | (string | RegExp)[]
77
87
  }
package/dist/index.d.ts CHANGED
@@ -21,6 +21,9 @@ declare function createGeneratePlugin({
21
21
  //#endregion
22
22
  //#region src/index.d.ts
23
23
  interface Options {
24
+ /**
25
+ * The directory where the the plugin will look for the `tsconfig.json` file.
26
+ */
24
27
  cwd?: string;
25
28
  /**
26
29
  * When entries are `.d.ts` files (instead of `.ts` files), this option should be set to `true`.
package/dist/index.js CHANGED
@@ -717,11 +717,17 @@ function createTsProgram(compilerOptions, dtsMap, id) {
717
717
  function tscEmit(module) {
718
718
  const { program, file } = module;
719
719
  let dtsCode;
720
+ let map;
720
721
  const { emitSkipped, diagnostics } = program.emit(
721
722
  file,
722
- (_, code) => {
723
- debug(`emit dts: ${file.fileName}`);
724
- dtsCode = code;
723
+ (fileName, code) => {
724
+ if (fileName.endsWith(".map")) {
725
+ debug(`emit dts sourcemap: ${fileName}`);
726
+ map = JSON.parse(code);
727
+ } else {
728
+ debug(`emit dts: ${fileName}`);
729
+ dtsCode = code;
730
+ }
725
731
  },
726
732
  void 0,
727
733
  true,
@@ -730,7 +736,10 @@ function tscEmit(module) {
730
736
  true
731
737
  );
732
738
  if (emitSkipped && diagnostics.length) return { error: ts.formatDiagnostics(diagnostics, formatHost) };
733
- return { code: dtsCode };
739
+ return {
740
+ code: dtsCode,
741
+ map
742
+ };
734
743
  }
735
744
  function getTsModule(dtsMap, tsId) {
736
745
  const module = Array.from(dtsMap.values()).find((dts$1) => dts$1.id === tsId);
@@ -889,6 +898,7 @@ function createGeneratePlugin({ tsconfig, compilerOptions = {}, isolatedDeclarat
889
898
  const result = tscEmit(module);
890
899
  if (result.error) return this.error(result.error);
891
900
  dtsCode = result.code;
901
+ map = result.map;
892
902
  }
893
903
  if (!dtsCode) return this.error(new Error(`Failed to generate dts for ${id}`));
894
904
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-plugin-dts",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "A Rolldown plugin to bundle dts files",
5
5
  "type": "module",
6
6
  "license": "MIT",