dtsroll 1.7.7 → 1.7.9

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/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { cli } from 'cleye';
3
- import { b as bgYellow, a as black, d as dtsroll, l as logOutput } from './index-CqO1yLQ_.mjs';
3
+ import { b as bgYellow, a as black, d as dtsroll, l as logOutput } from './index-CwhQAGPV.mjs';
4
4
  import { patchErrorWithTrace } from 'rollup-plugin-import-trace';
5
5
  import 'node:path';
6
6
  import 'node:fs/promises';
@@ -14,7 +14,7 @@ import 'resolve-pkg-maps';
14
14
  import 'byte-size';
15
15
 
16
16
  var name = "dtsroll";
17
- var version = "1.7.7";
17
+ var version = "1.7.9";
18
18
  var description = "Bundle dts files";
19
19
 
20
20
  const argv = cli({
@@ -2430,8 +2430,15 @@ class NamespaceFixer {
2430
2430
  });
2431
2431
  }
2432
2432
  }
2433
- if (ts.isModuleDeclaration(node) && node.body && ts.isModuleBlock(node.body)) {
2434
- for (const stmt of node.body.statements) {
2433
+ if (ts.isModuleDeclaration(node) && node.body) {
2434
+ let body = node.body;
2435
+ while (ts.isModuleDeclaration(body) && body.body) {
2436
+ body = body.body;
2437
+ }
2438
+ if (!ts.isModuleBlock(body)) {
2439
+ continue;
2440
+ }
2441
+ for (const stmt of body.statements) {
2435
2442
  if (ts.isExportDeclaration(stmt) && stmt.exportClause) {
2436
2443
  if (ts.isNamespaceExport(stmt.exportClause)) {
2437
2444
  continue;
@@ -2938,9 +2945,15 @@ function getNodeIndent(node) {
2938
2945
  return " ".repeat(match?.[1]?.length || 0);
2939
2946
  }
2940
2947
  function preProcessNamespaceBody(body, code, sourceFile) {
2948
+ if (ts.isModuleDeclaration(body)) {
2949
+ if (body.body && (ts.isModuleBlock(body.body) || ts.isModuleDeclaration(body.body))) {
2950
+ preProcessNamespaceBody(body.body, code);
2951
+ }
2952
+ return;
2953
+ }
2941
2954
  for (const stmt of body.statements) {
2942
2955
  fixModifiers(code, stmt);
2943
- if (ts.isModuleDeclaration(stmt) && stmt.body && ts.isModuleBlock(stmt.body)) {
2956
+ if (ts.isModuleDeclaration(stmt) && stmt.body && (ts.isModuleBlock(stmt.body) || ts.isModuleDeclaration(stmt.body))) {
2944
2957
  preProcessNamespaceBody(stmt.body, code);
2945
2958
  }
2946
2959
  }
@@ -2976,7 +2989,8 @@ function preProcess({ sourceFile, isEntry, isJSON }) {
2976
2989
  if (node.name) {
2977
2990
  const name = node.name.getText();
2978
2991
  declaredNames.add(name);
2979
- if (matchesModifier(node, ts.ModifierFlags.ExportDefault)) {
2992
+ if (node.flags & ts.NodeFlags.GlobalAugmentation) ;
2993
+ else if (matchesModifier(node, ts.ModifierFlags.ExportDefault)) {
2980
2994
  defaultExport = name;
2981
2995
  } else if (treatAsGlobalModule && ts.isIdentifier(node.name) || matchesModifier(node, ts.ModifierFlags.Export)) {
2982
2996
  exportedNames.add(name);
@@ -2986,7 +3000,7 @@ function preProcess({ sourceFile, isEntry, isJSON }) {
2986
3000
  }
2987
3001
  }
2988
3002
  if (ts.isModuleDeclaration(node)) {
2989
- if (node.body && ts.isModuleBlock(node.body)) {
3003
+ if (node.body && (ts.isModuleBlock(node.body) || ts.isModuleDeclaration(node.body))) {
2990
3004
  preProcessNamespaceBody(node.body, code);
2991
3005
  }
2992
3006
  duplicateExports(code, node);
@@ -3240,7 +3254,14 @@ function fixModifiers(code, node) {
3240
3254
  }
3241
3255
  }
3242
3256
  function duplicateExports(code, module) {
3243
- if (!module.body || !ts.isModuleBlock(module.body)) {
3257
+ if (!module.body) {
3258
+ return;
3259
+ }
3260
+ if (ts.isModuleDeclaration(module.body)) {
3261
+ duplicateExports(code, module.body);
3262
+ return;
3263
+ }
3264
+ if (!ts.isModuleBlock(module.body)) {
3244
3265
  return;
3245
3266
  }
3246
3267
  for (const node of module.body.statements) {
@@ -3736,7 +3757,7 @@ class Transformer {
3736
3757
  }
3737
3758
  const scope = this.createDeclaration(node, node.name);
3738
3759
  scope.pushIdentifierReference(node.name);
3739
- scope.convertNamespace(node);
3760
+ scope.convertNamespace(node, true);
3740
3761
  }
3741
3762
  convertEnumDeclaration(node) {
3742
3763
  const scope = this.createDeclaration(node, node.name);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import 'node:path';
3
- export { d as dtsroll } from './index-CqO1yLQ_.mjs';
3
+ export { d as dtsroll } from './index-CwhQAGPV.mjs';
4
4
  import 'node:fs/promises';
5
5
  import 'rollup';
6
6
  import 'typescript';
package/dist/vite.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as dtsroll, l as logOutput } from './index-CqO1yLQ_.mjs';
2
+ import { d as dtsroll, l as logOutput } from './index-CwhQAGPV.mjs';
3
3
  import 'node:path';
4
4
  import 'node:fs/promises';
5
5
  import 'rollup';
@@ -20,7 +20,7 @@ const dtsrollPlugin = (options) => {
20
20
  name: "dtsroll",
21
21
  apply: "build",
22
22
  enforce: "post",
23
- config: ({ root, logLevel }) => {
23
+ configResolved: ({ root, logLevel }) => {
24
24
  cwd = root;
25
25
  noLog = logLevel === "silent";
26
26
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtsroll",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Bundle dts files",
5
5
  "keywords": [
6
6
  "bundle",
@@ -44,7 +44,7 @@
44
44
  "empathic": "^2.0.0",
45
45
  "resolve-pkg-maps": "^1.0.0",
46
46
  "rollup": "^4.55.3",
47
- "rollup-plugin-import-trace": "^1.0.0"
47
+ "rollup-plugin-import-trace": "^1.0.1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "typescript": "^4.5 || ^5.0",