dtsroll 1.4.1 → 1.5.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/dist/cli.mjs CHANGED
@@ -1,15 +1,18 @@
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-C9-38zEa.mjs';
3
+ import { b as bgYellow, a as black, d as dtsroll, l as logOutput } from './index-DfxmCmBK.mjs';
4
4
  import 'node:path';
5
5
  import 'node:fs/promises';
6
6
  import 'rollup';
7
7
  import 'rollup-plugin-dts';
8
8
  import '@rollup/plugin-node-resolve';
9
+ import 'node:fs';
10
+ import 'empathic/find';
11
+ import 'resolve-pkg-maps';
9
12
  import 'byte-size';
10
13
 
11
14
  var name = "dtsroll";
12
- var version = "1.4.1";
15
+ var version = "1.5.0";
13
16
  var description = "Bundle dts files";
14
17
 
15
18
  const argv = cli({
@@ -3,86 +3,64 @@ import fs from 'node:fs/promises';
3
3
  import { rollup } from 'rollup';
4
4
  import { dts } from 'rollup-plugin-dts';
5
5
  import nodeResolve from '@rollup/plugin-node-resolve';
6
+ import fs$1 from 'node:fs';
7
+ import { up } from 'empathic/find';
8
+ import { resolveImports } from 'resolve-pkg-maps';
6
9
  import byteSize from 'byte-size';
7
10
 
8
11
  let enabled = true;
9
- // Support both browser and node environments
10
- const globalVar = typeof self !== 'undefined'
11
- ? self
12
- : typeof window !== 'undefined'
13
- ? window
14
- : typeof global !== 'undefined'
15
- ? global
16
- : {};
17
- /**
18
- * Detect how much colors the current terminal supports
19
- */
20
- let supportLevel = 0 /* none */;
12
+ const globalVar = typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
13
+ let supportLevel = 0;
21
14
  if (globalVar.process && globalVar.process.env && globalVar.process.stdout) {
22
- const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env;
23
- if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') {
24
- enabled = false;
25
- }
26
- else if (FORCE_COLOR === '1' ||
27
- FORCE_COLOR === '2' ||
28
- FORCE_COLOR === '3') {
29
- enabled = true;
30
- }
31
- else if (TERM === 'dumb') {
32
- enabled = false;
33
- }
34
- else if ('CI' in globalVar.process.env &&
35
- [
36
- 'TRAVIS',
37
- 'CIRCLECI',
38
- 'APPVEYOR',
39
- 'GITLAB_CI',
40
- 'GITHUB_ACTIONS',
41
- 'BUILDKITE',
42
- 'DRONE',
43
- ].some(vendor => vendor in globalVar.process.env)) {
44
- enabled = true;
45
- }
46
- else {
47
- enabled = process.stdout.isTTY;
48
- }
49
- if (enabled) {
50
- // Windows supports 24bit True Colors since Windows 10 revision #14931,
51
- // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/
52
- if (process.platform === 'win32') {
53
- supportLevel = 3 /* trueColor */;
54
- }
55
- else {
56
- if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) {
57
- supportLevel = 3 /* trueColor */;
58
- }
59
- else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) {
60
- supportLevel = 2 /* ansi256 */;
61
- }
62
- else {
63
- supportLevel = 1 /* ansi */;
64
- }
65
- }
15
+ const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env;
16
+ if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === "0") {
17
+ enabled = false;
18
+ } else if (FORCE_COLOR === "1" || FORCE_COLOR === "2" || FORCE_COLOR === "3") {
19
+ enabled = true;
20
+ } else if (TERM === "dumb") {
21
+ enabled = false;
22
+ } else if ("CI" in globalVar.process.env && [
23
+ "TRAVIS",
24
+ "CIRCLECI",
25
+ "APPVEYOR",
26
+ "GITLAB_CI",
27
+ "GITHUB_ACTIONS",
28
+ "BUILDKITE",
29
+ "DRONE"
30
+ ].some((vendor) => vendor in globalVar.process.env)) {
31
+ enabled = true;
32
+ } else {
33
+ enabled = process.stdout.isTTY;
34
+ }
35
+ if (enabled) {
36
+ if (process.platform === "win32") {
37
+ supportLevel = 3;
38
+ } else {
39
+ if (COLORTERM && (COLORTERM === "truecolor" || COLORTERM === "24bit")) {
40
+ supportLevel = 3;
41
+ } else if (TERM && (TERM.endsWith("-256color") || TERM.endsWith("256"))) {
42
+ supportLevel = 2;
43
+ } else {
44
+ supportLevel = 1;
45
+ }
66
46
  }
47
+ }
67
48
  }
68
49
  let options = {
69
- enabled,
70
- supportLevel,
50
+ enabled,
51
+ supportLevel
71
52
  };
72
- function kolorist(start, end, level = 1 /* ansi */) {
73
- const open = `\x1b[${start}m`;
74
- const close = `\x1b[${end}m`;
75
- const regex = new RegExp(`\\x1b\\[${end}m`, 'g');
76
- return (str) => {
77
- return options.enabled && options.supportLevel >= level
78
- ? open + ('' + str).replace(regex, open) + close
79
- : '' + str;
80
- };
53
+ function kolorist(start, end, level = 1) {
54
+ const open = `\x1B[${start}m`;
55
+ const close = `\x1B[${end}m`;
56
+ const regex = new RegExp(`\\x1b\\[${end}m`, "g");
57
+ return (str) => {
58
+ return options.enabled && options.supportLevel >= level ? open + ("" + str).replace(regex, open) + close : "" + str;
59
+ };
81
60
  }
82
61
  const bold = kolorist(1, 22);
83
62
  const dim = kolorist(2, 22);
84
63
  const underline = kolorist(4, 24);
85
- // colors
86
64
  const black = kolorist(30, 39);
87
65
  const red = kolorist(31, 39);
88
66
  const green = kolorist(32, 39);
@@ -529,6 +507,58 @@ const removeBundledModulesPlugin = (outputDirectory, sizeRef) => {
529
507
  };
530
508
  };
531
509
 
510
+ const packageJsonCache = /* @__PURE__ */ new Map();
511
+ const findPackageJsonUp = (cwd) => {
512
+ const packageJsonPath = up("package.json", { cwd });
513
+ if (!packageJsonPath) {
514
+ return void 0;
515
+ }
516
+ const packageRoot = path.dirname(packageJsonPath);
517
+ let packageJson = packageJsonCache.get(packageRoot);
518
+ if (!packageJson) {
519
+ try {
520
+ const content = fs$1.readFileSync(packageJsonPath, "utf8");
521
+ packageJson = JSON.parse(content);
522
+ packageJsonCache.set(packageRoot, packageJson);
523
+ } catch {
524
+ return void 0;
525
+ }
526
+ }
527
+ if (packageJson.imports) {
528
+ return {
529
+ imports: packageJson.imports,
530
+ packageRoot
531
+ };
532
+ }
533
+ };
534
+ const resolveSubpathImportsPlugin = () => ({
535
+ name: "resolve-subpath-imports",
536
+ async resolveId(id, importer) {
537
+ if (id[0] !== "#" || !importer) {
538
+ return null;
539
+ }
540
+ const result = findPackageJsonUp(path.dirname(importer));
541
+ if (!result) {
542
+ return null;
543
+ }
544
+ const { imports, packageRoot } = result;
545
+ let resolvedPaths;
546
+ try {
547
+ resolvedPaths = resolveImports(imports, id, ["types", "import"]);
548
+ } catch {
549
+ return null;
550
+ }
551
+ if (resolvedPaths.length === 0) {
552
+ return null;
553
+ }
554
+ return this.resolve(
555
+ path.join(packageRoot, resolvedPaths[0]),
556
+ importer,
557
+ { skipSelf: true }
558
+ );
559
+ }
560
+ });
561
+
532
562
  const createInputMap = (input, outputDirectory) => Object.fromEntries(
533
563
  input.map((inputFile) => [
534
564
  inputFile.slice(outputDirectory.length + 1),
@@ -553,6 +583,7 @@ const build = async (input, outputDirectory, externals, mode, conditions) => {
553
583
  plugins: [
554
584
  externalizePlugin,
555
585
  removeBundledModulesPlugin(outputDirectory, sizeRef),
586
+ resolveSubpathImportsPlugin(),
556
587
  nodeResolve({
557
588
  extensions: [".ts", ...dtsExtensions],
558
589
  exportConditions: conditions
package/dist/index.d.ts CHANGED
@@ -40,4 +40,5 @@ type Options = {
40
40
  };
41
41
  declare const dtsroll: ({ cwd, inputs, external, conditions, dryRun, }?: Options) => Promise<DtsrollOutput>;
42
42
 
43
- export { type DtsrollOutput, type Options, dtsroll };
43
+ export { dtsroll };
44
+ export type { DtsrollOutput, Options };
package/dist/index.mjs CHANGED
@@ -1,7 +1,11 @@
1
+ #!/usr/bin/env node
1
2
  import 'node:path';
2
- export { d as dtsroll } from './index-C9-38zEa.mjs';
3
+ export { d as dtsroll } from './index-DfxmCmBK.mjs';
3
4
  import 'node:fs/promises';
4
5
  import 'rollup';
5
6
  import 'rollup-plugin-dts';
6
7
  import '@rollup/plugin-node-resolve';
8
+ import 'node:fs';
9
+ import 'empathic/find';
10
+ import 'resolve-pkg-maps';
7
11
  import 'byte-size';
package/dist/vite.mjs CHANGED
@@ -1,9 +1,13 @@
1
- import { d as dtsroll, l as logOutput } from './index-C9-38zEa.mjs';
1
+ #!/usr/bin/env node
2
+ import { d as dtsroll, l as logOutput } from './index-DfxmCmBK.mjs';
2
3
  import 'node:path';
3
4
  import 'node:fs/promises';
4
5
  import 'rollup';
5
6
  import 'rollup-plugin-dts';
6
7
  import '@rollup/plugin-node-resolve';
8
+ import 'node:fs';
9
+ import 'empathic/find';
10
+ import 'resolve-pkg-maps';
7
11
  import 'byte-size';
8
12
 
9
13
  const dtsrollPlugin = (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtsroll",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Bundle dts files",
5
5
  "keywords": [
6
6
  "bundle",
@@ -37,15 +37,17 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "dependencies": {
40
- "@rollup/plugin-node-resolve": "^16.0.0",
40
+ "@rollup/plugin-node-resolve": "^16.0.3",
41
41
  "byte-size": "^9.0.1",
42
- "cleye": "^1.3.2",
43
- "rollup": "^4.29.1",
44
- "rollup-plugin-dts": "6.1.1"
42
+ "cleye": "^2.2.1",
43
+ "empathic": "^2.0.0",
44
+ "resolve-pkg-maps": "^1.0.0",
45
+ "rollup": "^4.55.1",
46
+ "rollup-plugin-dts": "6.3.0"
45
47
  },
46
48
  "peerDependencies": {
47
49
  "typescript": "^4.5 || ^5.0",
48
- "vite": "5 || 6"
50
+ "vite": "5 || 6 || 7"
49
51
  },
50
52
  "peerDependenciesMeta": {
51
53
  "vite": {