jiek 2.2.6 → 2.2.7-alpha.3

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/.chunks/getWD.D6wq8Qc2.js +95 -0
  8. package/dist/.internal/.chunks/getWD.ZF0avqDB.cjs +105 -0
  9. package/dist/{cli.js → .internal/.chunks/index.B6RQz1DZ.js} +1 -735
  10. package/dist/{cli.cjs → .internal/.chunks/index.DlHFuTjM.cjs} +1 -757
  11. package/dist/.internal/.chunks/jiek_create-require.CWFWNQHj.cjs +5 -0
  12. package/dist/.internal/.chunks/jiek_create-require.CxSGbkTB.js +5 -0
  13. package/dist/.internal/bin/parseArgv.cjs +33 -0
  14. package/dist/.internal/bin/parseArgv.d.cts +5 -0
  15. package/dist/.internal/bin/parseArgv.d.ts +5 -0
  16. package/dist/.internal/bin/parseArgv.js +27 -0
  17. package/dist/.internal/bridge.cjs +12 -0
  18. package/dist/.internal/bridge.d.cts +39 -0
  19. package/dist/.internal/bridge.d.ts +39 -0
  20. package/dist/.internal/bridge.js +9 -0
  21. package/dist/.internal/commands/build/analyzer.cjs +201 -0
  22. package/dist/.internal/commands/build/analyzer.d.cts +30 -0
  23. package/dist/.internal/commands/build/analyzer.d.ts +30 -0
  24. package/dist/.internal/commands/build/analyzer.js +195 -0
  25. package/dist/.internal/commands/descriptions.cjs +21 -0
  26. package/dist/.internal/commands/descriptions.d.cts +5 -0
  27. package/dist/.internal/commands/descriptions.d.ts +5 -0
  28. package/dist/.internal/commands/descriptions.js +17 -0
  29. package/dist/.internal/commands/meta.cjs +16 -0
  30. package/dist/.internal/commands/meta.d.cts +3 -0
  31. package/dist/.internal/commands/meta.d.ts +3 -0
  32. package/dist/.internal/commands/meta.js +15 -0
  33. package/dist/.internal/commands/utils/optionParser.cjs +8 -0
  34. package/dist/.internal/commands/utils/optionParser.d.cts +3 -0
  35. package/dist/.internal/commands/utils/optionParser.d.ts +3 -0
  36. package/dist/.internal/commands/utils/optionParser.js +6 -0
  37. package/dist/.internal/rollup/base.cjs +10 -0
  38. package/dist/{cli-only-build.d.cts → .internal/rollup/base.d.cts} +8 -15
  39. package/dist/{cli-only-build.d.ts → .internal/rollup/base.d.ts} +8 -15
  40. package/dist/.internal/rollup/base.js +7 -0
  41. package/dist/.internal/rollup/bundle-analyzer.cjs +51 -0
  42. package/dist/.internal/rollup/bundle-analyzer.d.cts +92 -0
  43. package/dist/.internal/rollup/bundle-analyzer.d.ts +92 -0
  44. package/dist/.internal/rollup/bundle-analyzer.js +45 -0
  45. package/dist/.internal/server.cjs +33 -0
  46. package/dist/.internal/server.d.cts +8 -0
  47. package/dist/.internal/server.d.ts +8 -0
  48. package/dist/.internal/server.js +27 -0
  49. package/dist/.internal/utils/checkDependency.cjs +39 -0
  50. package/dist/.internal/utils/checkDependency.d.cts +3 -0
  51. package/dist/.internal/utils/checkDependency.d.ts +3 -0
  52. package/dist/.internal/utils/checkDependency.js +34 -0
  53. package/dist/.internal/utils/filterSupport.cjs +20 -0
  54. package/dist/.internal/utils/filterSupport.d.cts +15 -0
  55. package/dist/.internal/utils/filterSupport.d.ts +15 -0
  56. package/dist/.internal/utils/filterSupport.js +10 -0
  57. package/dist/.internal/utils/getInternalModuleName.cjs +5 -0
  58. package/dist/.internal/utils/getInternalModuleName.d.cts +3 -0
  59. package/dist/.internal/utils/getInternalModuleName.d.ts +3 -0
  60. package/dist/.internal/utils/getInternalModuleName.js +3 -0
  61. package/dist/.internal/utils/getRoot.cjs +17 -0
  62. package/dist/.internal/utils/getRoot.d.cts +3 -0
  63. package/dist/.internal/utils/getRoot.d.ts +3 -0
  64. package/dist/.internal/utils/getRoot.js +11 -0
  65. package/dist/.internal/utils/getWD.cjs +15 -0
  66. package/dist/.internal/utils/getWD.d.cts +6 -0
  67. package/dist/.internal/utils/getWD.d.ts +6 -0
  68. package/dist/.internal/utils/getWD.js +10 -0
  69. package/dist/.internal/utils/intersection.cjs +5 -0
  70. package/dist/.internal/utils/intersection.d.cts +3 -0
  71. package/dist/.internal/utils/intersection.d.ts +3 -0
  72. package/dist/.internal/utils/intersection.js +3 -0
  73. package/dist/.internal/utils/loadConfig.cjs +100 -0
  74. package/dist/.internal/utils/loadConfig.d.cts +10 -0
  75. package/dist/.internal/utils/loadConfig.d.ts +10 -0
  76. package/dist/.internal/utils/loadConfig.js +94 -0
  77. package/dist/.internal/utils/recursiveListFiles.cjs +19 -0
  78. package/dist/.internal/utils/recursiveListFiles.d.cts +3 -0
  79. package/dist/.internal/utils/recursiveListFiles.d.ts +3 -0
  80. package/dist/.internal/utils/recursiveListFiles.js +13 -0
  81. package/dist/.internal/utils/resolveExports.cjs +118 -0
  82. package/dist/.internal/utils/resolveExports.d.cts +26 -0
  83. package/dist/.internal/utils/resolveExports.d.ts +26 -0
  84. package/dist/.internal/utils/resolveExports.js +111 -0
  85. package/dist/.internal/utils/ts.cjs +68 -0
  86. package/dist/.internal/utils/ts.d.cts +3 -0
  87. package/dist/.internal/utils/ts.d.ts +3 -0
  88. package/dist/.internal/utils/ts.js +62 -0
  89. package/dist/.internal/utils/tsRegister.cjs +25 -0
  90. package/dist/.internal/utils/tsRegister.d.cts +3 -0
  91. package/dist/.internal/utils/tsRegister.d.ts +3 -0
  92. package/dist/.internal/utils/tsRegister.js +26 -0
  93. package/dist/bin/build.cjs +515 -0
  94. package/dist/bin/index.cjs +497 -0
  95. package/dist/index.d.cts +12 -114
  96. package/dist/index.d.ts +12 -114
  97. package/dist/rollup/index.cjs +280 -4573
  98. package/dist/rollup/index.d.cts +7 -1
  99. package/dist/rollup/index.d.ts +7 -1
  100. package/dist/rollup/index.js +268 -4558
  101. package/package.json +20 -26
  102. package/src/bin/build.cts +11 -0
  103. package/src/bin/index.cts +6 -0
  104. package/src/bridge.ts +1 -1
  105. package/src/commands/base.ts +3 -3
  106. package/src/commands/build/analyzer.ts +5 -5
  107. package/src/commands/build/client/analyzer.tsx +1 -1
  108. package/src/commands/build/client/index.ts +5 -7
  109. package/src/commands/build.ts +226 -211
  110. package/src/commands/meta.ts +1 -1
  111. package/src/commands/publish.ts +112 -32
  112. package/src/index.ts +6 -1
  113. package/src/rollup/base.ts +2 -2
  114. package/src/rollup/index.ts +321 -124
  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,20 @@
1
+ 'use strict';
2
+
3
+ require('../.chunks/jiek_create-require.CWFWNQHj.cjs');
4
+ require('node:fs');
5
+ require('node:path');
6
+ require('node:process');
7
+ require('commander');
8
+ require('js-yaml');
9
+ require('./getRoot.cjs');
10
+ var filterSupport = require('../.chunks/getWD.ZF0avqDB.cjs');
11
+ require('@jiek/utils/getWorkspaceDir');
12
+
13
+
14
+
15
+ exports.filterPackagesGraph = filterSupport.filterPackagesGraph;
16
+ exports.getSelectedProjectsGraph = filterSupport.getSelectedProjectsGraph;
17
+ Object.defineProperty(exports, "type", {
18
+ enumerable: true,
19
+ get: function () { return filterSupport.type; }
20
+ });
@@ -0,0 +1,15 @@
1
+ declare let type: string;
2
+ interface Manifest {
3
+ name?: string;
4
+ type?: string;
5
+ exports?: string | string[] | Record<string, unknown>;
6
+ imports?: Record<string, unknown>;
7
+ }
8
+ interface ProjectsGraph {
9
+ root?: string;
10
+ value?: Record<string, Manifest>;
11
+ }
12
+ declare function filterPackagesGraph(filters: string[]): Promise<ProjectsGraph[]>;
13
+ declare function getSelectedProjectsGraph(filter?: string | undefined): Promise<ProjectsGraph>;
14
+
15
+ export { type Manifest, type ProjectsGraph, filterPackagesGraph, getSelectedProjectsGraph, type };
@@ -0,0 +1,15 @@
1
+ declare let type: string;
2
+ interface Manifest {
3
+ name?: string;
4
+ type?: string;
5
+ exports?: string | string[] | Record<string, unknown>;
6
+ imports?: Record<string, unknown>;
7
+ }
8
+ interface ProjectsGraph {
9
+ root?: string;
10
+ value?: Record<string, Manifest>;
11
+ }
12
+ declare function filterPackagesGraph(filters: string[]): Promise<ProjectsGraph[]>;
13
+ declare function getSelectedProjectsGraph(filter?: string | undefined): Promise<ProjectsGraph>;
14
+
15
+ export { type Manifest, type ProjectsGraph, filterPackagesGraph, getSelectedProjectsGraph, type };
@@ -0,0 +1,10 @@
1
+ import '../.chunks/jiek_create-require.CxSGbkTB.js';
2
+ import 'node:fs';
3
+ import 'node:path';
4
+ import 'node:process';
5
+ import 'commander';
6
+ import 'js-yaml';
7
+ import './getRoot.js';
8
+ export { f as filterPackagesGraph, a as getSelectedProjectsGraph, t as type } from '../.chunks/getWD.D6wq8Qc2.js';
9
+ import 'node:module';
10
+ import '@jiek/utils/getWorkspaceDir';
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const getInternalModuleName = (pkgName) => `${(pkgName.startsWith("@") ? pkgName : `@${pkgName}`).replace("/", "+")}/__internal__`;
4
+
5
+ exports.getInternalModuleName = getInternalModuleName;
@@ -0,0 +1,3 @@
1
+ declare const getInternalModuleName: (pkgName: string) => string;
2
+
3
+ export { getInternalModuleName };
@@ -0,0 +1,3 @@
1
+ declare const getInternalModuleName: (pkgName: string) => string;
2
+
3
+ export { getInternalModuleName };
@@ -0,0 +1,3 @@
1
+ const getInternalModuleName = (pkgName) => `${(pkgName.startsWith("@") ? pkgName : `@${pkgName}`).replace("/", "+")}/__internal__`;
2
+
3
+ export { getInternalModuleName };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var path = require('node:path');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var path__default = /*#__PURE__*/_interopDefault(path);
8
+
9
+ let root;
10
+ function getRoot() {
11
+ if (root) return root;
12
+ const rootOption = process.env.JIEK_ROOT;
13
+ root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
14
+ return root;
15
+ }
16
+
17
+ exports.getRoot = getRoot;
@@ -0,0 +1,3 @@
1
+ declare function getRoot(): string | undefined;
2
+
3
+ export { getRoot };
@@ -0,0 +1,3 @@
1
+ declare function getRoot(): string | undefined;
2
+
3
+ export { getRoot };
@@ -0,0 +1,11 @@
1
+ import path from 'node:path';
2
+
3
+ let root;
4
+ function getRoot() {
5
+ if (root) return root;
6
+ const rootOption = process.env.JIEK_ROOT;
7
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
8
+ return root;
9
+ }
10
+
11
+ export { getRoot };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ require('@jiek/utils/getWorkspaceDir');
4
+ var filterSupport = require('../.chunks/getWD.ZF0avqDB.cjs');
5
+ require('./getRoot.cjs');
6
+ require('../.chunks/jiek_create-require.CWFWNQHj.cjs');
7
+ require('node:fs');
8
+ require('node:path');
9
+ require('node:process');
10
+ require('commander');
11
+ require('js-yaml');
12
+
13
+
14
+
15
+ exports.getWD = filterSupport.getWD;
@@ -0,0 +1,6 @@
1
+ declare function getWD(): {
2
+ wd: string;
3
+ notWorkspace: boolean;
4
+ };
5
+
6
+ export { getWD };
@@ -0,0 +1,6 @@
1
+ declare function getWD(): {
2
+ wd: string;
3
+ notWorkspace: boolean;
4
+ };
5
+
6
+ export { getWD };
@@ -0,0 +1,10 @@
1
+ import '@jiek/utils/getWorkspaceDir';
2
+ export { g as getWD } from '../.chunks/getWD.D6wq8Qc2.js';
3
+ import './getRoot.js';
4
+ import '../.chunks/jiek_create-require.CxSGbkTB.js';
5
+ import 'node:module';
6
+ import 'node:fs';
7
+ import 'node:path';
8
+ import 'node:process';
9
+ import 'commander';
10
+ import 'js-yaml';
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4
+
5
+ exports.intersection = intersection;
@@ -0,0 +1,3 @@
1
+ declare const intersection: <T>(a: Iterable<T>, b: Set<T>) => Set<T>;
2
+
3
+ export { intersection };
@@ -0,0 +1,3 @@
1
+ declare const intersection: <T>(a: Iterable<T>, b: Set<T>) => Set<T>;
2
+
3
+ export { intersection };
@@ -0,0 +1,3 @@
1
+ const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
2
+
3
+ export { intersection };
@@ -0,0 +1,100 @@
1
+ 'use strict';
2
+
3
+ var jiek_createRequire = require('../.chunks/jiek_create-require.CWFWNQHj.cjs');
4
+ var fs = require('node:fs');
5
+ var path = require('node:path');
6
+ var commander = require('commander');
7
+ var jsYaml = require('js-yaml');
8
+ var filterSupport = require('../.chunks/getWD.ZF0avqDB.cjs');
9
+ var tsRegister = require('./tsRegister.cjs');
10
+ require('@jiek/utils/getWorkspaceDir');
11
+ require('node:process');
12
+ require('./getRoot.cjs');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
+
16
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
17
+ var path__default = /*#__PURE__*/_interopDefault(path);
18
+
19
+ let configName = "jiek.config";
20
+ function getConfigPath(root, dir) {
21
+ const isSupportTsLoader = !!tsRegister.tsRegisterName;
22
+ function configWithExtIsExist(ext) {
23
+ const filenames = [
24
+ path__default.default.resolve(process.cwd(), `${configName}.${ext}`),
25
+ path__default.default.resolve(process.cwd(), `.${configName}.${ext}`),
26
+ path__default.default.resolve(root, `${configName}.${ext}`),
27
+ path__default.default.resolve(root, `.${configName}.${ext}`)
28
+ ];
29
+ if (dir) {
30
+ filenames.unshift(...[
31
+ path__default.default.resolve(dir, `${configName}.${ext}`),
32
+ path__default.default.resolve(dir, `.${configName}.${ext}`)
33
+ ]);
34
+ }
35
+ for (const filename of filenames) {
36
+ if (fs__default.default.existsSync(filename) && fs__default.default.lstatSync(filename).isFile()) {
37
+ return filename;
38
+ }
39
+ }
40
+ return;
41
+ }
42
+ configName = configWithExtIsExist("js") ?? configName;
43
+ configName = configWithExtIsExist("json") ?? configName;
44
+ configName = configWithExtIsExist("yaml") ?? configName;
45
+ if (isSupportTsLoader) {
46
+ configName = configWithExtIsExist("ts") ?? configName;
47
+ }
48
+ return path__default.default.resolve(root, configName);
49
+ }
50
+ function loadConfig(dirOrOptions) {
51
+ let dir;
52
+ let root;
53
+ if (typeof dirOrOptions === "object") {
54
+ dir = dirOrOptions.dir;
55
+ root = dirOrOptions.root ?? filterSupport.getWD().wd;
56
+ } else {
57
+ dir = dirOrOptions;
58
+ root = filterSupport.getWD().wd;
59
+ }
60
+ let configPath = commander.program.getOptionValue("configPath");
61
+ if (!configPath) {
62
+ configPath = getConfigPath(root, dir);
63
+ } else {
64
+ if (!fs__default.default.existsSync(configPath)) {
65
+ throw new Error(`config file not found: ${configPath}`);
66
+ }
67
+ if (!path__default.default.isAbsolute(configPath)) {
68
+ configPath = path__default.default.resolve(root, configPath);
69
+ }
70
+ }
71
+ const ext = path__default.default.extname(configPath);
72
+ let module;
73
+ switch (ext) {
74
+ case ".js":
75
+ module = jiek_createRequire.require(configPath);
76
+ break;
77
+ case ".json":
78
+ return jiek_createRequire.require(configPath);
79
+ case ".yaml":
80
+ return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
81
+ case ".ts":
82
+ if (tsRegister.tsRegisterName) {
83
+ jiek_createRequire.require(tsRegister.tsRegisterName);
84
+ module = jiek_createRequire.require(configPath);
85
+ break;
86
+ }
87
+ throw new Error(
88
+ "ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
89
+ );
90
+ case ".config":
91
+ module = {};
92
+ break;
93
+ default:
94
+ throw new Error(`unsupported config file type: ${ext}`);
95
+ }
96
+ if (!module) throw new Error("config file is empty");
97
+ return module.default ?? module;
98
+ }
99
+
100
+ exports.loadConfig = loadConfig;
@@ -0,0 +1,10 @@
1
+ import { Config } from 'jiek';
2
+
3
+ interface LoadConfigOptions {
4
+ dir?: string;
5
+ root?: string;
6
+ }
7
+ declare function loadConfig(options?: LoadConfigOptions): Config;
8
+ declare function loadConfig(dir?: string): Config;
9
+
10
+ export { loadConfig };
@@ -0,0 +1,10 @@
1
+ import { Config } from 'jiek';
2
+
3
+ interface LoadConfigOptions {
4
+ dir?: string;
5
+ root?: string;
6
+ }
7
+ declare function loadConfig(options?: LoadConfigOptions): Config;
8
+ declare function loadConfig(dir?: string): Config;
9
+
10
+ export { loadConfig };
@@ -0,0 +1,94 @@
1
+ import { r as require } from '../.chunks/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 '../.chunks/getWD.D6wq8Qc2.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('../.chunks/index.DlHFuTjM.cjs');
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 };