jiek 2.2.6 → 2.2.7-alpha.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.
Files changed (136) hide show
  1. package/bin/build.cjs +2 -0
  2. package/bin/index.cjs +2 -0
  3. package/bin-helper/index.cjs +31 -0
  4. package/bin-helper/index.d.cts +1 -0
  5. package/bin-helper/index.d.ts +1 -0
  6. package/bin-helper/package.json +5 -1
  7. package/dist/.internal/+/bin/parseArgv.cjs +33 -0
  8. package/dist/.internal/+/bin/parseArgv.d.cts +5 -0
  9. package/dist/.internal/+/bin/parseArgv.d.ts +5 -0
  10. package/dist/.internal/+/bin/parseArgv.js +27 -0
  11. package/dist/.internal/+/bridge.cjs +12 -0
  12. package/dist/.internal/+/bridge.d.cts +39 -0
  13. package/dist/.internal/+/bridge.d.ts +39 -0
  14. package/dist/.internal/+/bridge.js +9 -0
  15. package/dist/.internal/+/commands/build/analyzer.cjs +201 -0
  16. package/dist/.internal/+/commands/build/analyzer.d.cts +30 -0
  17. package/dist/.internal/+/commands/build/analyzer.d.ts +30 -0
  18. package/dist/.internal/+/commands/build/analyzer.js +195 -0
  19. package/dist/.internal/+/commands/descriptions.cjs +21 -0
  20. package/dist/.internal/+/commands/descriptions.d.cts +5 -0
  21. package/dist/.internal/+/commands/descriptions.d.ts +5 -0
  22. package/dist/.internal/+/commands/descriptions.js +17 -0
  23. package/dist/.internal/+/commands/meta.cjs +16 -0
  24. package/dist/.internal/+/commands/meta.d.cts +3 -0
  25. package/dist/.internal/+/commands/meta.d.ts +3 -0
  26. package/dist/.internal/+/commands/meta.js +15 -0
  27. package/dist/.internal/+/commands/utils/optionParser.cjs +8 -0
  28. package/dist/.internal/+/commands/utils/optionParser.d.cts +3 -0
  29. package/dist/.internal/+/commands/utils/optionParser.d.ts +3 -0
  30. package/dist/.internal/+/commands/utils/optionParser.js +6 -0
  31. package/dist/.internal/+/rollup/base.cjs +10 -0
  32. package/dist/{cli-only-build.d.cts → .internal/+/rollup/base.d.cts} +8 -15
  33. package/dist/{cli-only-build.d.ts → .internal/+/rollup/base.d.ts} +8 -15
  34. package/dist/.internal/+/rollup/base.js +7 -0
  35. package/dist/.internal/+/rollup/bundle-analyzer.cjs +51 -0
  36. package/dist/.internal/+/rollup/bundle-analyzer.d.cts +92 -0
  37. package/dist/.internal/+/rollup/bundle-analyzer.d.ts +92 -0
  38. package/dist/.internal/+/rollup/bundle-analyzer.js +45 -0
  39. package/dist/.internal/+/server.cjs +33 -0
  40. package/dist/.internal/+/server.d.cts +8 -0
  41. package/dist/.internal/+/server.d.ts +8 -0
  42. package/dist/.internal/+/server.js +27 -0
  43. package/dist/.internal/+/utils/checkDependency.cjs +39 -0
  44. package/dist/.internal/+/utils/checkDependency.d.cts +3 -0
  45. package/dist/.internal/+/utils/checkDependency.d.ts +3 -0
  46. package/dist/.internal/+/utils/checkDependency.js +34 -0
  47. package/dist/.internal/+/utils/filterSupport.cjs +20 -0
  48. package/dist/.internal/+/utils/filterSupport.d.cts +15 -0
  49. package/dist/.internal/+/utils/filterSupport.d.ts +15 -0
  50. package/dist/.internal/+/utils/filterSupport.js +10 -0
  51. package/dist/.internal/+/utils/getInternalModuleName.cjs +5 -0
  52. package/dist/.internal/+/utils/getInternalModuleName.d.cts +3 -0
  53. package/dist/.internal/+/utils/getInternalModuleName.d.ts +3 -0
  54. package/dist/.internal/+/utils/getInternalModuleName.js +3 -0
  55. package/dist/.internal/+/utils/getRoot.cjs +17 -0
  56. package/dist/.internal/+/utils/getRoot.d.cts +3 -0
  57. package/dist/.internal/+/utils/getRoot.d.ts +3 -0
  58. package/dist/.internal/+/utils/getRoot.js +11 -0
  59. package/dist/.internal/+/utils/getWD.cjs +15 -0
  60. package/dist/.internal/+/utils/getWD.d.cts +6 -0
  61. package/dist/.internal/+/utils/getWD.d.ts +6 -0
  62. package/dist/.internal/+/utils/getWD.js +10 -0
  63. package/dist/.internal/+/utils/intersection.cjs +5 -0
  64. package/dist/.internal/+/utils/intersection.d.cts +3 -0
  65. package/dist/.internal/+/utils/intersection.d.ts +3 -0
  66. package/dist/.internal/+/utils/intersection.js +3 -0
  67. package/dist/.internal/+/utils/loadConfig.cjs +100 -0
  68. package/dist/.internal/+/utils/loadConfig.d.cts +10 -0
  69. package/dist/.internal/+/utils/loadConfig.d.ts +10 -0
  70. package/dist/.internal/+/utils/loadConfig.js +94 -0
  71. package/dist/.internal/+/utils/recursiveListFiles.cjs +19 -0
  72. package/dist/.internal/+/utils/recursiveListFiles.d.cts +3 -0
  73. package/dist/.internal/+/utils/recursiveListFiles.d.ts +3 -0
  74. package/dist/.internal/+/utils/recursiveListFiles.js +13 -0
  75. package/dist/.internal/+/utils/resolveExports.cjs +118 -0
  76. package/dist/.internal/+/utils/resolveExports.d.cts +26 -0
  77. package/dist/.internal/+/utils/resolveExports.d.ts +26 -0
  78. package/dist/.internal/+/utils/resolveExports.js +111 -0
  79. package/dist/.internal/+/utils/ts.cjs +68 -0
  80. package/dist/.internal/+/utils/ts.d.cts +3 -0
  81. package/dist/.internal/+/utils/ts.d.ts +3 -0
  82. package/dist/.internal/+/utils/ts.js +62 -0
  83. package/dist/.internal/+/utils/tsRegister.cjs +25 -0
  84. package/dist/.internal/+/utils/tsRegister.d.cts +3 -0
  85. package/dist/.internal/+/utils/tsRegister.d.ts +3 -0
  86. package/dist/.internal/+/utils/tsRegister.js +26 -0
  87. package/dist/.internal/getWD-BRJ3PK1S.js +105 -0
  88. package/dist/.internal/getWD-Cmxzjf-f.js +95 -0
  89. package/dist/{cli.js → .internal/index-B6RQz1DZ.js} +1 -735
  90. package/dist/{cli.cjs → .internal/index-DlHFuTjM.js} +1 -757
  91. package/dist/.internal/jiek_create-require-CWFWNQHj.js +5 -0
  92. package/dist/.internal/jiek_create-require-CxSGbkTB.js +5 -0
  93. package/dist/.internal/package.json +10 -0
  94. package/dist/bin/build.cjs +505 -0
  95. package/dist/bin/index.cjs +488 -0
  96. package/dist/index.d.cts +1 -113
  97. package/dist/index.d.ts +1 -113
  98. package/dist/rollup/index.cjs +282 -4569
  99. package/dist/rollup/index.d.cts +7 -1
  100. package/dist/rollup/index.d.ts +7 -1
  101. package/dist/rollup/index.js +270 -4554
  102. package/package.json +25 -28
  103. package/src/bin/build.cts +11 -0
  104. package/src/bin/index.cts +6 -0
  105. package/src/bridge.ts +1 -1
  106. package/src/commands/base.ts +3 -3
  107. package/src/commands/build/analyzer.ts +5 -5
  108. package/src/commands/build/client/analyzer.tsx +1 -1
  109. package/src/commands/build/client/index.ts +5 -7
  110. package/src/commands/build.ts +218 -209
  111. package/src/commands/meta.ts +1 -1
  112. package/src/commands/publish.ts +87 -25
  113. package/src/rollup/base.ts +2 -2
  114. package/src/rollup/index.ts +309 -115
  115. package/src/rollup/plugins/with-external.ts +23 -0
  116. package/src/rollup/utils/externalResolver.ts +20 -8
  117. package/src/utils/checkDependency.ts +1 -1
  118. package/src/utils/filterSupport.ts +17 -16
  119. package/src/utils/getInternalModuleName.ts +5 -0
  120. package/src/utils/intersection.ts +1 -0
  121. package/src/utils/{recusiveListFiles.ts → recursiveListFiles.ts} +2 -2
  122. package/src/utils/{getExports.ts → resolveExports.ts} +16 -14
  123. package/bin/jiek-build.js +0 -16
  124. package/bin/jiek.js +0 -13
  125. package/bin-helper.cjs +0 -43
  126. package/cli/package.json +0 -1
  127. package/cli-only-build/package.json +0 -1
  128. package/dist/cli-only-build.cjs +0 -977
  129. package/dist/cli-only-build.js +0 -969
  130. package/dist/cli.d.cts +0 -14
  131. package/dist/cli.d.ts +0 -14
  132. package/src/bin/build.ts +0 -0
  133. package/src/cli-only-build.ts +0 -11
  134. package/src/cli.ts +0 -6
  135. /package/{bin-helper.js → bin-helper/index.js} +0 -0
  136. /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
@@ -0,0 +1,94 @@
1
+ import { r as require } from '../../jiek_create-require-CxSGbkTB.js';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { program } from 'commander';
5
+ import { load } from 'js-yaml';
6
+ import { g as getWD } from '../../getWD-Cmxzjf-f.js';
7
+ import { tsRegisterName } from './tsRegister.js';
8
+ import 'node:module';
9
+ import '@jiek/utils/getWorkspaceDir';
10
+ import 'node:process';
11
+ import './getRoot.js';
12
+
13
+ let configName = "jiek.config";
14
+ function getConfigPath(root, dir) {
15
+ const isSupportTsLoader = !!tsRegisterName;
16
+ function configWithExtIsExist(ext) {
17
+ const filenames = [
18
+ path.resolve(process.cwd(), `${configName}.${ext}`),
19
+ path.resolve(process.cwd(), `.${configName}.${ext}`),
20
+ path.resolve(root, `${configName}.${ext}`),
21
+ path.resolve(root, `.${configName}.${ext}`)
22
+ ];
23
+ if (dir) {
24
+ filenames.unshift(...[
25
+ path.resolve(dir, `${configName}.${ext}`),
26
+ path.resolve(dir, `.${configName}.${ext}`)
27
+ ]);
28
+ }
29
+ for (const filename of filenames) {
30
+ if (fs.existsSync(filename) && fs.lstatSync(filename).isFile()) {
31
+ return filename;
32
+ }
33
+ }
34
+ return;
35
+ }
36
+ configName = configWithExtIsExist("js") ?? configName;
37
+ configName = configWithExtIsExist("json") ?? configName;
38
+ configName = configWithExtIsExist("yaml") ?? configName;
39
+ if (isSupportTsLoader) {
40
+ configName = configWithExtIsExist("ts") ?? configName;
41
+ }
42
+ return path.resolve(root, configName);
43
+ }
44
+ function loadConfig(dirOrOptions) {
45
+ let dir;
46
+ let root;
47
+ if (typeof dirOrOptions === "object") {
48
+ dir = dirOrOptions.dir;
49
+ root = dirOrOptions.root ?? getWD().wd;
50
+ } else {
51
+ dir = dirOrOptions;
52
+ root = getWD().wd;
53
+ }
54
+ let configPath = program.getOptionValue("configPath");
55
+ if (!configPath) {
56
+ configPath = getConfigPath(root, dir);
57
+ } else {
58
+ if (!fs.existsSync(configPath)) {
59
+ throw new Error(`config file not found: ${configPath}`);
60
+ }
61
+ if (!path.isAbsolute(configPath)) {
62
+ configPath = path.resolve(root, configPath);
63
+ }
64
+ }
65
+ const ext = path.extname(configPath);
66
+ let module;
67
+ switch (ext) {
68
+ case ".js":
69
+ module = require(configPath);
70
+ break;
71
+ case ".json":
72
+ return require(configPath);
73
+ case ".yaml":
74
+ return load(fs.readFileSync(configPath, "utf-8"));
75
+ case ".ts":
76
+ if (tsRegisterName) {
77
+ require(tsRegisterName);
78
+ module = require(configPath);
79
+ break;
80
+ }
81
+ throw new Error(
82
+ "ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
83
+ );
84
+ case ".config":
85
+ module = {};
86
+ break;
87
+ default:
88
+ throw new Error(`unsupported config file type: ${ext}`);
89
+ }
90
+ if (!module) throw new Error("config file is empty");
91
+ return module.default ?? module;
92
+ }
93
+
94
+ export { loadConfig };
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
9
+
10
+ const recursiveListFiles = (dir) => fs__default.default.readdirSync(dir).reduce((acc, file) => {
11
+ const filePath = path.resolve(dir, file);
12
+ if (fs__default.default.statSync(filePath).isDirectory()) {
13
+ if (filePath.endsWith("/node_modules")) return acc;
14
+ return [...acc, ...recursiveListFiles(filePath)];
15
+ }
16
+ return [...acc, filePath];
17
+ }, []);
18
+
19
+ exports.recursiveListFiles = recursiveListFiles;
@@ -0,0 +1,3 @@
1
+ declare const recursiveListFiles: (dir: string) => string[];
2
+
3
+ export { recursiveListFiles };
@@ -0,0 +1,3 @@
1
+ declare const recursiveListFiles: (dir: string) => string[];
2
+
3
+ export { recursiveListFiles };
@@ -0,0 +1,13 @@
1
+ import fs from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ const recursiveListFiles = (dir) => fs.readdirSync(dir).reduce((acc, file) => {
5
+ const filePath = resolve(dir, file);
6
+ if (fs.statSync(filePath).isDirectory()) {
7
+ if (filePath.endsWith("/node_modules")) return acc;
8
+ return [...acc, ...recursiveListFiles(filePath)];
9
+ }
10
+ return [...acc, filePath];
11
+ }, []);
12
+
13
+ export { recursiveListFiles };
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var path = require('node:path');
4
+ var process = require('node:process');
5
+ var entrypoints = require('@jiek/pkger/entrypoints');
6
+ var index = require('../../index-DlHFuTjM.js');
7
+ var intersection = require('./intersection.cjs');
8
+ require('util');
9
+ require('path');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var process__default = /*#__PURE__*/_interopDefault(process);
14
+
15
+ const {
16
+ JIEK_OUT_DIR,
17
+ JIEK_CROSS_MODULE_CONVERTOR
18
+ } = process__default.default.env;
19
+ const OUTDIR = JIEK_OUT_DIR ?? "dist";
20
+ const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
21
+ function getOutDirs({
22
+ cwd = process__default.default.cwd(),
23
+ defaultOutdir = OUTDIR,
24
+ config,
25
+ pkgName
26
+ }) {
27
+ const { build = {} } = config ?? {};
28
+ const outdir = build?.output?.dir;
29
+ function resolveOutdir(type) {
30
+ const dir = (typeof outdir === "object" ? outdir[type] ?? outdir[{
31
+ js: "dts",
32
+ dts: "js"
33
+ }[type]] : outdir) ?? defaultOutdir;
34
+ return (path.isAbsolute(dir) ? dir : `./${path.relative(cwd, path.resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
35
+ }
36
+ return {
37
+ js: resolveOutdir("js"),
38
+ dts: resolveOutdir("dts")
39
+ };
40
+ }
41
+ function resolveExports({
42
+ entrypoints: entrypoints$1,
43
+ pkgName,
44
+ pkgIsModule,
45
+ entries,
46
+ config,
47
+ dir,
48
+ defaultOutdir = OUTDIR,
49
+ // FIXME dts support
50
+ outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
51
+ noFilter,
52
+ isPublish
53
+ }) {
54
+ const {
55
+ build = {},
56
+ publish: {
57
+ withSuffix = false,
58
+ withSource = true
59
+ } = {}
60
+ } = config ?? {};
61
+ const {
62
+ crossModuleConvertor = crossModuleConvertorDefault
63
+ } = build;
64
+ const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
65
+ if (entries) {
66
+ Object.entries(resolvedEntrypoints).forEach(([key]) => {
67
+ if (!entries.some((e) => index.micromatchExports.isMatch(key, e, { matchBase: true }))) {
68
+ delete resolvedEntrypoints[key];
69
+ }
70
+ });
71
+ }
72
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : entrypoints.filterLeafs(
73
+ resolvedEntrypoints,
74
+ {
75
+ skipValue: [
76
+ // ignore values that filename starts with `.jk-noentry`
77
+ /(^|\/)\.jk-noentry/,
78
+ ...entrypoints.DEFAULT_SKIP_VALUES
79
+ ]
80
+ }
81
+ );
82
+ const crossModuleWithConditional = crossModuleConvertor ? {
83
+ import: (opts) => {
84
+ if (pkgIsModule) return false;
85
+ if (opts.src.endsWith(".cts")) return false;
86
+ if (intersection.intersection(
87
+ new Set(opts.conditionals),
88
+ /* @__PURE__ */ new Set(["import", "module"])
89
+ ).size !== 0) return false;
90
+ return opts.dist.replace(/\.js$/, ".mjs");
91
+ },
92
+ require: (opts) => {
93
+ if (!pkgIsModule) return false;
94
+ if (opts.src.endsWith(".mts")) return false;
95
+ if (intersection.intersection(
96
+ new Set(opts.conditionals),
97
+ /* @__PURE__ */ new Set(["require", "node"])
98
+ ).size !== 0) return false;
99
+ return opts.dist.replace(/\.js$/, ".cjs");
100
+ }
101
+ } : {};
102
+ return [
103
+ filteredResolvedEntrypoints,
104
+ entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
105
+ outdir,
106
+ sourceTag: pkgName,
107
+ withSuffix: isPublish ? withSuffix : void 0,
108
+ withSource: isPublish ? withSource : void 0,
109
+ withConditional: {
110
+ ...crossModuleWithConditional
111
+ }
112
+ }),
113
+ outdir
114
+ ];
115
+ }
116
+
117
+ exports.getOutDirs = getOutDirs;
118
+ exports.resolveExports = resolveExports;
@@ -0,0 +1,26 @@
1
+ import { Config } from 'jiek';
2
+
3
+ declare function getOutDirs({ cwd, defaultOutdir, config, pkgName }: {
4
+ cwd?: string;
5
+ defaultOutdir?: string;
6
+ config?: Config;
7
+ pkgName?: string;
8
+ }): {
9
+ js: string;
10
+ dts: string;
11
+ };
12
+ interface ResolveExportsOptions {
13
+ entrypoints: string | string[] | Record<string, unknown>;
14
+ pkgName: string;
15
+ pkgIsModule: boolean;
16
+ entries?: string[];
17
+ config?: Config;
18
+ dir?: string;
19
+ outdir?: string;
20
+ defaultOutdir?: string;
21
+ noFilter?: boolean;
22
+ isPublish?: boolean;
23
+ }
24
+ declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
25
+
26
+ export { type ResolveExportsOptions, getOutDirs, resolveExports };
@@ -0,0 +1,26 @@
1
+ import { Config } from 'jiek';
2
+
3
+ declare function getOutDirs({ cwd, defaultOutdir, config, pkgName }: {
4
+ cwd?: string;
5
+ defaultOutdir?: string;
6
+ config?: Config;
7
+ pkgName?: string;
8
+ }): {
9
+ js: string;
10
+ dts: string;
11
+ };
12
+ interface ResolveExportsOptions {
13
+ entrypoints: string | string[] | Record<string, unknown>;
14
+ pkgName: string;
15
+ pkgIsModule: boolean;
16
+ entries?: string[];
17
+ config?: Config;
18
+ dir?: string;
19
+ outdir?: string;
20
+ defaultOutdir?: string;
21
+ noFilter?: boolean;
22
+ isPublish?: boolean;
23
+ }
24
+ declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
25
+
26
+ export { type ResolveExportsOptions, getOutDirs, resolveExports };
@@ -0,0 +1,111 @@
1
+ import { isAbsolute, relative, resolve } from 'node:path';
2
+ import process from 'node:process';
3
+ import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports } from '@jiek/pkger/entrypoints';
4
+ import { m as micromatchExports } from '../../index-B6RQz1DZ.js';
5
+ import { intersection } from './intersection.js';
6
+ import 'util';
7
+ import 'path';
8
+
9
+ const {
10
+ JIEK_OUT_DIR,
11
+ JIEK_CROSS_MODULE_CONVERTOR
12
+ } = process.env;
13
+ const OUTDIR = JIEK_OUT_DIR ?? "dist";
14
+ const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
15
+ function getOutDirs({
16
+ cwd = process.cwd(),
17
+ defaultOutdir = OUTDIR,
18
+ config,
19
+ pkgName
20
+ }) {
21
+ const { build = {} } = config ?? {};
22
+ const outdir = build?.output?.dir;
23
+ function resolveOutdir(type) {
24
+ const dir = (typeof outdir === "object" ? outdir[type] ?? outdir[{
25
+ js: "dts",
26
+ dts: "js"
27
+ }[type]] : outdir) ?? defaultOutdir;
28
+ return (isAbsolute(dir) ? dir : `./${relative(cwd, resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
29
+ }
30
+ return {
31
+ js: resolveOutdir("js"),
32
+ dts: resolveOutdir("dts")
33
+ };
34
+ }
35
+ function resolveExports({
36
+ entrypoints,
37
+ pkgName,
38
+ pkgIsModule,
39
+ entries,
40
+ config,
41
+ dir,
42
+ defaultOutdir = OUTDIR,
43
+ // FIXME dts support
44
+ outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
45
+ noFilter,
46
+ isPublish
47
+ }) {
48
+ const {
49
+ build = {},
50
+ publish: {
51
+ withSuffix = false,
52
+ withSource = true
53
+ } = {}
54
+ } = config ?? {};
55
+ const {
56
+ crossModuleConvertor = crossModuleConvertorDefault
57
+ } = build;
58
+ const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
59
+ if (entries) {
60
+ Object.entries(resolvedEntrypoints).forEach(([key]) => {
61
+ if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
62
+ delete resolvedEntrypoints[key];
63
+ }
64
+ });
65
+ }
66
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : filterLeafs(
67
+ resolvedEntrypoints,
68
+ {
69
+ skipValue: [
70
+ // ignore values that filename starts with `.jk-noentry`
71
+ /(^|\/)\.jk-noentry/,
72
+ ...DEFAULT_SKIP_VALUES
73
+ ]
74
+ }
75
+ );
76
+ const crossModuleWithConditional = crossModuleConvertor ? {
77
+ import: (opts) => {
78
+ if (pkgIsModule) return false;
79
+ if (opts.src.endsWith(".cts")) return false;
80
+ if (intersection(
81
+ new Set(opts.conditionals),
82
+ /* @__PURE__ */ new Set(["import", "module"])
83
+ ).size !== 0) return false;
84
+ return opts.dist.replace(/\.js$/, ".mjs");
85
+ },
86
+ require: (opts) => {
87
+ if (!pkgIsModule) return false;
88
+ if (opts.src.endsWith(".mts")) return false;
89
+ if (intersection(
90
+ new Set(opts.conditionals),
91
+ /* @__PURE__ */ new Set(["require", "node"])
92
+ ).size !== 0) return false;
93
+ return opts.dist.replace(/\.js$/, ".cjs");
94
+ }
95
+ } : {};
96
+ return [
97
+ filteredResolvedEntrypoints,
98
+ entrypoints2Exports(filteredResolvedEntrypoints, {
99
+ outdir,
100
+ sourceTag: pkgName,
101
+ withSuffix: isPublish ? withSuffix : void 0,
102
+ withSource: isPublish ? withSource : void 0,
103
+ withConditional: {
104
+ ...crossModuleWithConditional
105
+ }
106
+ }),
107
+ outdir
108
+ ];
109
+ }
110
+
111
+ export { getOutDirs, resolveExports };
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var jsoncParser = require('jsonc-parser');
6
+ var index = require('../../index-DlHFuTjM.js');
7
+ require('util');
8
+ require('path');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
13
+
14
+ const getTSConfig = (p) => !fs__default.default.existsSync(p) || !fs__default.default.statSync(p).isFile() ? {} : jsoncParser.parse(fs__default.default.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
15
+ const getExtendTSConfig = (tsconfigPath) => {
16
+ tsconfigPath = path.resolve(tsconfigPath);
17
+ const tsconfigPathDirname = path.dirname(tsconfigPath);
18
+ const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
19
+ const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
20
+ const extendsPaths = resolvePaths(
21
+ exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
22
+ );
23
+ if (extendsPaths.length === 0) return tsconfig;
24
+ return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
25
+ ...acc,
26
+ ...curr,
27
+ compilerOptions: {
28
+ ...acc.compilerOptions,
29
+ ...compilerOptions
30
+ }
31
+ }), {});
32
+ };
33
+ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
34
+ tsconfigPath = path.resolve(tsconfigPath);
35
+ filePath = path.resolve(filePath);
36
+ const tsconfigPathDirname = path.dirname(tsconfigPath);
37
+ const tsconfig = getExtendTSConfig(tsconfigPath);
38
+ const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
39
+ const [
40
+ references,
41
+ files,
42
+ include,
43
+ exclude
44
+ ] = [
45
+ tsconfig.references?.map(({ path }) => path),
46
+ tsconfig.files,
47
+ tsconfig.include,
48
+ tsconfig.exclude
49
+ ].map(resolvePaths);
50
+ if (exclude.length > 0 && exclude.some((i) => index.micromatchExports.isMatch(filePath, i))) return;
51
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
52
+ let isInclude = false;
53
+ isInclude || (isInclude = files.length > 0 && files.includes(filePath));
54
+ isInclude || (isInclude = include.length > 0 && include.some((i) => index.micromatchExports.isMatch(filePath, i)));
55
+ if (isInclude) {
56
+ return tsconfig.compilerOptions ?? {};
57
+ } else {
58
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
59
+ }
60
+ references.reverse();
61
+ for (const ref of references) {
62
+ const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
63
+ if (compilerOptions) return compilerOptions;
64
+ }
65
+ return tsconfig.compilerOptions;
66
+ };
67
+
68
+ exports.getCompilerOptionsByFilePath = getCompilerOptionsByFilePath;
@@ -0,0 +1,3 @@
1
+ declare const getCompilerOptionsByFilePath: (tsconfigPath: string, filePath: string) => Record<string, unknown> | undefined;
2
+
3
+ export { getCompilerOptionsByFilePath };
@@ -0,0 +1,3 @@
1
+ declare const getCompilerOptionsByFilePath: (tsconfigPath: string, filePath: string) => Record<string, unknown> | undefined;
2
+
3
+ export { getCompilerOptionsByFilePath };
@@ -0,0 +1,62 @@
1
+ import fs from 'node:fs';
2
+ import { resolve, dirname } from 'node:path';
3
+ import { parse } from 'jsonc-parser';
4
+ import { m as micromatchExports } from '../../index-B6RQz1DZ.js';
5
+ import 'util';
6
+ import 'path';
7
+
8
+ const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
9
+ const getExtendTSConfig = (tsconfigPath) => {
10
+ tsconfigPath = resolve(tsconfigPath);
11
+ const tsconfigPathDirname = dirname(tsconfigPath);
12
+ const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
13
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
14
+ const extendsPaths = resolvePaths(
15
+ exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
16
+ );
17
+ if (extendsPaths.length === 0) return tsconfig;
18
+ return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
19
+ ...acc,
20
+ ...curr,
21
+ compilerOptions: {
22
+ ...acc.compilerOptions,
23
+ ...compilerOptions
24
+ }
25
+ }), {});
26
+ };
27
+ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
28
+ tsconfigPath = resolve(tsconfigPath);
29
+ filePath = resolve(filePath);
30
+ const tsconfigPathDirname = dirname(tsconfigPath);
31
+ const tsconfig = getExtendTSConfig(tsconfigPath);
32
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
33
+ const [
34
+ references,
35
+ files,
36
+ include,
37
+ exclude
38
+ ] = [
39
+ tsconfig.references?.map(({ path }) => path),
40
+ tsconfig.files,
41
+ tsconfig.include,
42
+ tsconfig.exclude
43
+ ].map(resolvePaths);
44
+ if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
45
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
46
+ let isInclude = false;
47
+ isInclude || (isInclude = files.length > 0 && files.includes(filePath));
48
+ isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
49
+ if (isInclude) {
50
+ return tsconfig.compilerOptions ?? {};
51
+ } else {
52
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
53
+ }
54
+ references.reverse();
55
+ for (const ref of references) {
56
+ const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
57
+ if (compilerOptions) return compilerOptions;
58
+ }
59
+ return tsconfig.compilerOptions;
60
+ };
61
+
62
+ export { getCompilerOptionsByFilePath };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var jiek_createRequire = require('../../jiek_create-require-CWFWNQHj.js');
4
+
5
+ function packageIsExist(name) {
6
+ try {
7
+ jiek_createRequire.require.resolve(name);
8
+ return true;
9
+ } catch (e) {
10
+ return false;
11
+ }
12
+ }
13
+ exports.tsRegisterName = void 0;
14
+ const registers = [
15
+ process.env.JIEK_TS_REGISTER,
16
+ "esbuild-register",
17
+ "@swc-node/register",
18
+ "ts-node/register"
19
+ ].filter(Boolean);
20
+ for (const register of registers) {
21
+ if (packageIsExist(register)) {
22
+ exports.tsRegisterName = register;
23
+ break;
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ declare let tsRegisterName: string | undefined;
2
+
3
+ export { tsRegisterName };
@@ -0,0 +1,3 @@
1
+ declare let tsRegisterName: string | undefined;
2
+
3
+ export { tsRegisterName };
@@ -0,0 +1,26 @@
1
+ import { r as require } from '../../jiek_create-require-CxSGbkTB.js';
2
+ import 'node:module';
3
+
4
+ function packageIsExist(name) {
5
+ try {
6
+ require.resolve(name);
7
+ return true;
8
+ } catch (e) {
9
+ return false;
10
+ }
11
+ }
12
+ let tsRegisterName;
13
+ const registers = [
14
+ process.env.JIEK_TS_REGISTER,
15
+ "esbuild-register",
16
+ "@swc-node/register",
17
+ "ts-node/register"
18
+ ].filter(Boolean);
19
+ for (const register of registers) {
20
+ if (packageIsExist(register)) {
21
+ tsRegisterName = register;
22
+ break;
23
+ }
24
+ }
25
+
26
+ export { tsRegisterName };