jiek 0.4.5 → 0.4.7-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/README.md +22 -1
  2. package/bin/jiek.js +2 -1
  3. package/dist/cli.d.mts +97 -0
  4. package/dist/cli.d.mts.map +1 -0
  5. package/dist/cli.d.ts +96 -1
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/{cli.cjs → cli.js} +361 -226
  8. package/dist/cli.js.map +1 -0
  9. package/dist/cli.min.js +1 -0
  10. package/dist/cli.min.js.map +1 -0
  11. package/dist/cli.min.mjs +1 -0
  12. package/dist/cli.min.mjs.map +1 -0
  13. package/dist/cli.mjs +803 -0
  14. package/dist/cli.mjs.map +1 -0
  15. package/dist/index.d.mts +58 -0
  16. package/dist/index.d.mts.map +1 -0
  17. package/dist/index.d.ts +47 -46
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/{index.cjs → index.js} +0 -1
  20. package/dist/index.js.map +1 -0
  21. package/dist/{index.min.cjs → index.min.js} +0 -1
  22. package/dist/index.min.js.map +1 -0
  23. package/dist/index.min.mjs +1 -0
  24. package/dist/index.min.mjs.map +1 -0
  25. package/dist/{index.esm.js → index.mjs} +0 -1
  26. package/dist/index.mjs.map +1 -0
  27. package/dist/rollup/index.d.mts +53 -0
  28. package/dist/rollup/index.d.mts.map +1 -0
  29. package/dist/rollup/index.d.ts +53 -0
  30. package/dist/rollup/index.d.ts.map +1 -0
  31. package/dist/rollup/index.js +553 -0
  32. package/dist/rollup/index.js.map +1 -0
  33. package/dist/rollup/index.min.js +1 -0
  34. package/dist/rollup/index.min.js.map +1 -0
  35. package/dist/rollup/index.min.mjs +1 -0
  36. package/dist/rollup/index.min.mjs.map +1 -0
  37. package/dist/rollup/index.mjs +551 -0
  38. package/dist/rollup/index.mjs.map +1 -0
  39. package/package.json +52 -35
  40. package/src/cli.ts +9 -0
  41. package/src/commands/base.ts +9 -0
  42. package/src/commands/build.ts +156 -0
  43. package/src/commands/init.ts +373 -0
  44. package/src/commands/publish.ts +156 -0
  45. package/src/index.ts +8 -0
  46. package/src/inner.ts +11 -0
  47. package/src/merge-package-json.ts +75 -0
  48. package/src/pkg.ts +1 -0
  49. package/src/rollup/base.ts +72 -0
  50. package/src/rollup/index.ts +420 -0
  51. package/src/rollup/plugins/globals.ts +34 -0
  52. package/src/rollup/plugins/progress.ts +26 -0
  53. package/src/rollup/plugins/skip.ts +23 -0
  54. package/src/rollup/utils/commonOptions.ts +9 -0
  55. package/src/rollup/utils/externalResolver.ts +21 -0
  56. package/src/rollup/utils/globalResolver.ts +13 -0
  57. package/src/rollup/utils/withMinify.ts +18 -0
  58. package/src/utils/filterSupport.ts +82 -0
  59. package/src/utils/getExports.ts +100 -0
  60. package/src/utils/getRoot.ts +16 -0
  61. package/src/utils/getWD.ts +31 -0
  62. package/src/utils/loadConfig.ts +93 -0
  63. package/src/utils/tsRegister.ts +22 -0
  64. package/dist/base.esm.d.ts +0 -55
  65. package/dist/cli.cjs.map +0 -1
  66. package/dist/cli.esm.d.ts +0 -2
  67. package/dist/cli.esm.js +0 -9
  68. package/dist/cli.esm.js.map +0 -1
  69. package/dist/cli.esm.min.js +0 -2
  70. package/dist/cli.esm.min.js.map +0 -1
  71. package/dist/cli.min.cjs +0 -2
  72. package/dist/cli.min.cjs.map +0 -1
  73. package/dist/commands/base.esm.js +0 -5
  74. package/dist/commands/base.esm.js.map +0 -1
  75. package/dist/commands/base.esm.min.js +0 -2
  76. package/dist/commands/base.esm.min.js.map +0 -1
  77. package/dist/commands/build.esm.js +0 -58
  78. package/dist/commands/build.esm.js.map +0 -1
  79. package/dist/commands/build.esm.min.js +0 -2
  80. package/dist/commands/build.esm.min.js.map +0 -1
  81. package/dist/commands/init.esm.js +0 -271
  82. package/dist/commands/init.esm.js.map +0 -1
  83. package/dist/commands/init.esm.min.js +0 -2
  84. package/dist/commands/init.esm.min.js.map +0 -1
  85. package/dist/commands/publish.esm.js +0 -76
  86. package/dist/commands/publish.esm.js.map +0 -1
  87. package/dist/commands/publish.esm.min.js +0 -2
  88. package/dist/commands/publish.esm.min.js.map +0 -1
  89. package/dist/index.cjs.map +0 -1
  90. package/dist/index.esm.d.ts +0 -6
  91. package/dist/index.esm.js.map +0 -1
  92. package/dist/index.esm.min.js +0 -2
  93. package/dist/index.esm.min.js.map +0 -1
  94. package/dist/index.min.cjs.map +0 -1
  95. package/dist/inner.esm.js +0 -10
  96. package/dist/inner.esm.js.map +0 -1
  97. package/dist/inner.esm.min.js +0 -2
  98. package/dist/inner.esm.min.js.map +0 -1
  99. package/dist/merge-package-json.esm.js +0 -64
  100. package/dist/merge-package-json.esm.js.map +0 -1
  101. package/dist/merge-package-json.esm.min.js +0 -2
  102. package/dist/merge-package-json.esm.min.js.map +0 -1
  103. package/dist/pkg.esm.js +0 -4
  104. package/dist/pkg.esm.js.map +0 -1
  105. package/dist/pkg.esm.min.js +0 -2
  106. package/dist/pkg.esm.min.js.map +0 -1
  107. package/dist/rollup/plugins/globals.esm.js +0 -31
  108. package/dist/rollup/plugins/globals.esm.js.map +0 -1
  109. package/dist/rollup/plugins/globals.esm.min.js +0 -2
  110. package/dist/rollup/plugins/globals.esm.min.js.map +0 -1
  111. package/dist/rollup/plugins/skip.esm.js +0 -16
  112. package/dist/rollup/plugins/skip.esm.js.map +0 -1
  113. package/dist/rollup/plugins/skip.esm.min.js +0 -2
  114. package/dist/rollup/plugins/skip.esm.min.js.map +0 -1
  115. package/dist/rollup/utils/commonOptions.esm.js +0 -9
  116. package/dist/rollup/utils/commonOptions.esm.js.map +0 -1
  117. package/dist/rollup/utils/commonOptions.esm.min.js +0 -2
  118. package/dist/rollup/utils/commonOptions.esm.min.js.map +0 -1
  119. package/dist/rollup/utils/externalResolver.esm.js +0 -12
  120. package/dist/rollup/utils/externalResolver.esm.js.map +0 -1
  121. package/dist/rollup/utils/externalResolver.esm.min.js +0 -2
  122. package/dist/rollup/utils/externalResolver.esm.min.js.map +0 -1
  123. package/dist/rollup/utils/globalResolver.esm.js +0 -9
  124. package/dist/rollup/utils/globalResolver.esm.js.map +0 -1
  125. package/dist/rollup/utils/globalResolver.esm.min.js +0 -2
  126. package/dist/rollup/utils/globalResolver.esm.min.js.map +0 -1
  127. package/dist/rollup/utils/withMinify.esm.js +0 -15
  128. package/dist/rollup/utils/withMinify.esm.js.map +0 -1
  129. package/dist/rollup/utils/withMinify.esm.min.js +0 -2
  130. package/dist/rollup/utils/withMinify.esm.min.js.map +0 -1
  131. package/dist/rollup.cjs +0 -330
  132. package/dist/rollup.cjs.map +0 -1
  133. package/dist/rollup.d.ts +0 -23
  134. package/dist/rollup.esm.d.ts +0 -23
  135. package/dist/rollup.esm.js +0 -248
  136. package/dist/rollup.esm.js.map +0 -1
  137. package/dist/rollup.esm.min.js +0 -2
  138. package/dist/rollup.esm.min.js.map +0 -1
  139. package/dist/rollup.min.cjs +0 -2
  140. package/dist/rollup.min.cjs.map +0 -1
  141. package/dist/utils/commondir.esm.js +0 -25
  142. package/dist/utils/commondir.esm.js.map +0 -1
  143. package/dist/utils/commondir.esm.min.js +0 -2
  144. package/dist/utils/commondir.esm.min.js.map +0 -1
  145. package/dist/utils/filterSupport.esm.js +0 -67
  146. package/dist/utils/filterSupport.esm.js.map +0 -1
  147. package/dist/utils/filterSupport.esm.min.js +0 -2
  148. package/dist/utils/filterSupport.esm.min.js.map +0 -1
  149. package/dist/utils/getRoot.esm.js +0 -14
  150. package/dist/utils/getRoot.esm.js.map +0 -1
  151. package/dist/utils/getRoot.esm.min.js +0 -2
  152. package/dist/utils/getRoot.esm.min.js.map +0 -1
  153. package/dist/utils/getWD.esm.js +0 -31
  154. package/dist/utils/getWD.esm.js.map +0 -1
  155. package/dist/utils/getWD.esm.min.js +0 -2
  156. package/dist/utils/getWD.esm.min.js.map +0 -1
  157. package/dist/utils/loadConfig.esm.js +0 -75
  158. package/dist/utils/loadConfig.esm.js.map +0 -1
  159. package/dist/utils/loadConfig.esm.min.js +0 -2
  160. package/dist/utils/loadConfig.esm.min.js.map +0 -1
  161. package/dist/utils/tsRegister.esm.js +0 -24
  162. package/dist/utils/tsRegister.esm.js.map +0 -1
  163. package/dist/utils/tsRegister.esm.min.js +0 -2
  164. package/dist/utils/tsRegister.esm.min.js.map +0 -1
@@ -0,0 +1,551 @@
1
+ import fs from 'node:fs';
2
+ import path, { resolve, relative, dirname } from 'node:path';
3
+ import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports, getAllLeafs } from '@jiek/pkger/entrypoints';
4
+ import { dts } from '@jiek/rollup-plugin-dts';
5
+ import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
6
+ import json from '@rollup/plugin-json';
7
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
8
+ import terser from '@rollup/plugin-terser';
9
+ import { sendMessage } from 'execa';
10
+ import { parse } from 'jsonc-parser';
11
+ import { isMatch } from 'micromatch';
12
+ import esbuild from 'rollup-plugin-esbuild';
13
+ import ts from 'typescript';
14
+ import { program } from 'commander';
15
+ import { load } from 'js-yaml';
16
+ import '@pnpm/filter-workspace-packages';
17
+
18
+ const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
19
+ function getExports({
20
+ entrypoints,
21
+ pkgIsModule,
22
+ entries,
23
+ config,
24
+ dir,
25
+ noFilter
26
+ }) {
27
+ const dirResolve = (...paths) => resolve(dir ?? process.cwd(), ...paths);
28
+ const dirRelative = (path) => relative(dir ?? process.cwd(), path);
29
+ const { build = {} } = config ?? {};
30
+ const {
31
+ crossModuleConvertor = true
32
+ } = build;
33
+ const jsOutdir = `./${dirRelative(dirResolve(
34
+ (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
35
+ ))}`;
36
+ const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
37
+ if (entries) {
38
+ Object.entries(resolvedEntrypoints).forEach(([key]) => {
39
+ if (!entries.some((e) => isMatch(key, e, { matchBase: true }))) {
40
+ delete resolvedEntrypoints[key];
41
+ }
42
+ });
43
+ }
44
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : filterLeafs(
45
+ resolvedEntrypoints,
46
+ {
47
+ skipValue: [
48
+ // ignore values that filename starts with `.jk-noentry`
49
+ /(^|\/)\.jk-noentry/,
50
+ ...DEFAULT_SKIP_VALUES
51
+ ]
52
+ }
53
+ );
54
+ const crossModuleWithConditional = crossModuleConvertor ? {
55
+ import: (opts) => !pkgIsModule && intersection(
56
+ new Set(opts.conditionals),
57
+ /* @__PURE__ */ new Set(["import", "module"])
58
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".mjs") : false,
59
+ require: (opts) => pkgIsModule && intersection(
60
+ new Set(opts.conditionals),
61
+ /* @__PURE__ */ new Set(["require", "node"])
62
+ ).size === 0 ? opts.dist.replace(/\.js$/, ".cjs") : false
63
+ } : {};
64
+ return [
65
+ filteredResolvedEntrypoints,
66
+ entrypoints2Exports(filteredResolvedEntrypoints, {
67
+ outdir: jsOutdir,
68
+ withConditional: {
69
+ ...crossModuleWithConditional
70
+ }
71
+ })
72
+ ];
73
+ }
74
+
75
+ let root;
76
+ function getRoot() {
77
+ if (root)
78
+ return root;
79
+ const rootOption = program.getOptionValue("root");
80
+ root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
81
+ return root;
82
+ }
83
+
84
+ let type = "";
85
+ try {
86
+ require.resolve("@pnpm/filter-workspace-packages");
87
+ type = "pnpm";
88
+ } catch {
89
+ }
90
+ if (type !== "") {
91
+ program.option("-f, --filter <filter>", "filter packages");
92
+ }
93
+
94
+ let wd;
95
+ let notWorkspace = false;
96
+ function getWD() {
97
+ if (wd)
98
+ return { wd, notWorkspace };
99
+ const root = getRoot();
100
+ if (root !== void 0) {
101
+ const isWorkspace = isWorkspaceDir(root, type);
102
+ notWorkspace = !isWorkspace;
103
+ wd = root;
104
+ return { wd, notWorkspace };
105
+ }
106
+ try {
107
+ wd = getWorkspaceDir(type);
108
+ } catch (e) {
109
+ if ("message" in e && e.message === "workspace root not found") {
110
+ wd = root;
111
+ notWorkspace = true;
112
+ } else {
113
+ throw e;
114
+ }
115
+ }
116
+ return { wd, notWorkspace };
117
+ }
118
+
119
+ function packageIsExist(name) {
120
+ try {
121
+ require.resolve(name);
122
+ return true;
123
+ } catch (e) {
124
+ return false;
125
+ }
126
+ }
127
+ let tsRegisterName;
128
+ const registers = [
129
+ process.env.JIEK_TS_REGISTER,
130
+ "esbuild-register",
131
+ "@swc-node/register",
132
+ "ts-node/register"
133
+ ].filter(Boolean);
134
+ for (const register of registers) {
135
+ if (packageIsExist(register)) {
136
+ tsRegisterName = register;
137
+ break;
138
+ }
139
+ }
140
+
141
+ let configName = "jiek.config";
142
+ function getConfigPath(root, dir) {
143
+ const isSupportTsLoader = !!tsRegisterName;
144
+ function configWithExtIsExist(ext) {
145
+ const filenames = [
146
+ path.resolve(process.cwd(), `${configName}.${ext}`),
147
+ path.resolve(process.cwd(), `.${configName}.${ext}`),
148
+ path.resolve(root, `${configName}.${ext}`),
149
+ path.resolve(root, `.${configName}.${ext}`)
150
+ ];
151
+ if (dir) {
152
+ filenames.unshift(...[
153
+ path.resolve(dir, `${configName}.${ext}`),
154
+ path.resolve(dir, `.${configName}.${ext}`)
155
+ ]);
156
+ }
157
+ for (const filename of filenames) {
158
+ if (fs.existsSync(filename) && fs.lstatSync(filename).isFile()) {
159
+ return filename;
160
+ }
161
+ }
162
+ return;
163
+ }
164
+ configName = configWithExtIsExist("js") ?? configName;
165
+ configName = configWithExtIsExist("json") ?? configName;
166
+ configName = configWithExtIsExist("yaml") ?? configName;
167
+ if (isSupportTsLoader) {
168
+ configName = configWithExtIsExist("ts") ?? configName;
169
+ }
170
+ return path.resolve(root, configName);
171
+ }
172
+ function loadConfig(dir) {
173
+ const { wd: root } = getWD();
174
+ let configPath = program.getOptionValue("configPath");
175
+ if (!configPath) {
176
+ configPath = getConfigPath(root, dir);
177
+ } else {
178
+ if (!fs.existsSync(configPath)) {
179
+ throw new Error(`config file not found: ${configPath}`);
180
+ }
181
+ if (!path.isAbsolute(configPath)) {
182
+ configPath = path.resolve(root, configPath);
183
+ }
184
+ }
185
+ const ext = path.extname(configPath);
186
+ let module;
187
+ switch (ext) {
188
+ case ".js":
189
+ module = require(configPath);
190
+ break;
191
+ case ".json":
192
+ return require(configPath);
193
+ case ".yaml":
194
+ return load(fs.readFileSync(configPath, "utf-8"));
195
+ case ".ts":
196
+ if (tsRegisterName) {
197
+ require(tsRegisterName);
198
+ module = require(configPath);
199
+ break;
200
+ }
201
+ throw new Error(
202
+ "ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
203
+ );
204
+ case ".config":
205
+ module = {};
206
+ break;
207
+ default:
208
+ throw new Error(`unsupported config file type: ${ext}`);
209
+ }
210
+ if (!module)
211
+ throw new Error("config file is empty");
212
+ return module.default ?? module;
213
+ }
214
+
215
+ var progress = (options = {}) => {
216
+ const { onEvent } = options;
217
+ return {
218
+ name: "progress",
219
+ buildStart: () => onEvent?.("start", "Start building..."),
220
+ buildEnd: () => onEvent?.("end", "Build completed!"),
221
+ resolveId: {
222
+ order: "post",
223
+ handler: (source) => onEvent?.("resolve", `Resolving ${source}...`)
224
+ },
225
+ load: {
226
+ order: "post",
227
+ handler: (id) => onEvent?.("load", `Loading ${id}...`)
228
+ },
229
+ transform: {
230
+ order: "post",
231
+ handler: (_, id) => onEvent?.("transform", `Transforming ${id}...`)
232
+ }
233
+ };
234
+ };
235
+
236
+ var skip = (options = {}) => {
237
+ return {
238
+ name: "skip",
239
+ // skip the specified files by `options.patterns`
240
+ load(id) {
241
+ if (options.patterns?.some(
242
+ (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
243
+ )) {
244
+ return "";
245
+ }
246
+ }
247
+ };
248
+ };
249
+
250
+ function externalResolver(jsonOrPath = process.cwd()) {
251
+ const pkg = typeof jsonOrPath === "string" ? fs.existsSync(`${jsonOrPath}/package.json`) ? JSON.parse(fs.readFileSync(`${jsonOrPath}/package.json`, "utf-8")) : {} : jsonOrPath;
252
+ const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
253
+ const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
254
+ return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
255
+ /^node:/
256
+ ]);
257
+ }
258
+
259
+ const {
260
+ JIEK_ROOT,
261
+ JIEK_ENTRIES
262
+ } = process.env;
263
+ const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir();
264
+ const COMMON_OPTIONS = {};
265
+ const COMMON_PLUGINS = [
266
+ json()
267
+ ];
268
+ const config = loadConfig() ?? {};
269
+ const { build = {} } = config;
270
+ const jsOutdir = `./${relative(
271
+ process.cwd(),
272
+ resolve(
273
+ (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
274
+ )
275
+ )}`;
276
+ const STYLE_REGEXP = /\.(css|s[ac]ss|less|styl)$/;
277
+ const resolveWorkspacePath = (p) => resolve(WORKSPACE_ROOT, p);
278
+ const pascalCase = (str) => str.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()).replace(/(?:^|-)(\w)/g, (_, $1) => $1.toUpperCase());
279
+ const reveal = (obj, keys) => keys.reduce((acc, key) => {
280
+ if (typeof acc === "string")
281
+ throw new Error("key not found in exports");
282
+ if (!(key in acc))
283
+ throw new Error(`key ${key} not found in exports`);
284
+ return acc[key];
285
+ }, obj);
286
+ const withMinify = (output, minify = build?.output?.minify) => minify === false ? [output] : minify === "only-minify" ? [{
287
+ ...output,
288
+ // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
289
+ // TODO resolve dts output file name
290
+ file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
291
+ plugins: [
292
+ ...output.plugins ?? [],
293
+ terser()
294
+ ]
295
+ }] : [
296
+ output,
297
+ {
298
+ ...output,
299
+ file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
300
+ plugins: [
301
+ ...output.plugins ?? [],
302
+ terser()
303
+ ]
304
+ }
305
+ ];
306
+ const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
307
+ const getExtendTSConfig = (tsconfigPath) => {
308
+ tsconfigPath = resolve(tsconfigPath);
309
+ const tsconfigPathDirname = dirname(tsconfigPath);
310
+ const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
311
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
312
+ const extendsPaths = resolvePaths(
313
+ exts ? Array.isArray(exts) ? exts : [exts] : []
314
+ );
315
+ if (extendsPaths.length === 0)
316
+ return tsconfig;
317
+ return extendsPaths.map(getExtendTSConfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
318
+ ...acc,
319
+ ...curr,
320
+ compilerOptions: {
321
+ ...acc.compilerOptions,
322
+ ...compilerOptions
323
+ }
324
+ }), tsconfig);
325
+ };
326
+ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
327
+ tsconfigPath = resolve(tsconfigPath);
328
+ filePath = resolve(filePath);
329
+ const tsconfigPathDirname = dirname(tsconfigPath);
330
+ const tsconfig = getExtendTSConfig(tsconfigPath);
331
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
332
+ const [
333
+ references,
334
+ files,
335
+ include,
336
+ exclude
337
+ ] = [
338
+ tsconfig.references?.map(({ path }) => path),
339
+ tsconfig.files,
340
+ tsconfig.include,
341
+ tsconfig.exclude
342
+ ].map(resolvePaths);
343
+ if (exclude.length > 0 && exclude.some((i) => isMatch(filePath, i)))
344
+ return;
345
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
346
+ return;
347
+ let isInclude = false;
348
+ isInclude || (isInclude = files.length > 0 && files.includes(filePath));
349
+ isInclude || (isInclude = include.length > 0 && include.some((i) => isMatch(filePath, i)));
350
+ if (isInclude) {
351
+ return tsconfig.compilerOptions ?? {};
352
+ } else {
353
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0)
354
+ return;
355
+ }
356
+ references.reverse();
357
+ for (const ref of references) {
358
+ const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
359
+ if (compilerOptions)
360
+ return compilerOptions;
361
+ }
362
+ return tsconfig.compilerOptions;
363
+ };
364
+ const generateConfigs = ({
365
+ path,
366
+ name,
367
+ input,
368
+ output,
369
+ external,
370
+ pkgIsModule,
371
+ conditionals
372
+ }, options = {}) => {
373
+ const isModule = conditionals.includes("import");
374
+ const isCommonJS = conditionals.includes("require");
375
+ const isBrowser = conditionals.includes("browser");
376
+ const dtsTSConfigPaths = [
377
+ resolveWorkspacePath("tsconfig.json"),
378
+ resolveWorkspacePath("tsconfig.dts.json")
379
+ ];
380
+ let dtsTSConfigPath;
381
+ dtsTSConfigPaths.forEach((p) => {
382
+ if (fs.existsSync(p) && fs.statSync(p).isFile()) {
383
+ dtsTSConfigPath = p;
384
+ }
385
+ });
386
+ let compilerOptions = {};
387
+ if (dtsTSConfigPath) {
388
+ const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, resolve(input));
389
+ const { options: options2, errors } = ts.convertCompilerOptionsFromJson(
390
+ jsonCompilerOptions,
391
+ dirname(dtsTSConfigPath)
392
+ );
393
+ if (errors.length > 0) {
394
+ throw new Error(errors.map((e) => e.messageText).join("\n"));
395
+ }
396
+ compilerOptions = options2;
397
+ }
398
+ const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
399
+ const throughEventProps = {
400
+ type: "progress",
401
+ data: { name, path, exportConditions, input }
402
+ };
403
+ const outdir = options?.output?.dir;
404
+ return [
405
+ {
406
+ input,
407
+ external,
408
+ output: [
409
+ ...withMinify({
410
+ file: output,
411
+ name,
412
+ sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap,
413
+ format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
414
+ strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict
415
+ })
416
+ ],
417
+ plugins: [
418
+ nodeResolve({ exportConditions }),
419
+ import('rollup-plugin-postcss').then(
420
+ ({ default: postcss }) => postcss({
421
+ extract: resolve(output.replace(/\.[cm]?js$/, ".css")),
422
+ minimize: true
423
+ })
424
+ ).catch(() => void 0),
425
+ esbuild(),
426
+ progress({
427
+ onEvent: (event, message) => sendMessage(
428
+ {
429
+ ...throughEventProps,
430
+ data: { ...throughEventProps.data, event, message, tags: ["js"] }
431
+ }
432
+ )
433
+ })
434
+ ]
435
+ },
436
+ {
437
+ input,
438
+ external,
439
+ output: [
440
+ {
441
+ dir: resolve((typeof outdir === "object" ? outdir.dts : outdir) ?? "dist"),
442
+ sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap,
443
+ entryFileNames: () => output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, ".d$1ts"),
444
+ strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
445
+ }
446
+ ],
447
+ plugins: [
448
+ nodeResolve({ exportConditions }),
449
+ skip({ patterns: [STYLE_REGEXP] }),
450
+ dts({
451
+ respectExternal: true,
452
+ compilerOptions
453
+ }),
454
+ progress({
455
+ onEvent: (event, message) => sendMessage(
456
+ {
457
+ ...throughEventProps,
458
+ data: { ...throughEventProps.data, event, message, tags: ["dts"] }
459
+ }
460
+ )
461
+ })
462
+ ]
463
+ }
464
+ ];
465
+ };
466
+ function template(packageJSON) {
467
+ const { name, type, exports: entrypoints } = packageJSON;
468
+ const pkgIsModule = type === "module";
469
+ if (!name)
470
+ throw new Error("package.json name is required");
471
+ if (!entrypoints)
472
+ throw new Error("package.json exports is required");
473
+ const entries = JIEK_ENTRIES?.split(",").map((e) => e.trim()).map((e) => ({
474
+ "index": "."
475
+ })[e] ?? e);
476
+ const packageName = pascalCase(name);
477
+ const external = externalResolver(packageJSON);
478
+ const [filteredResolvedEntrypoints, exports] = getExports({
479
+ entrypoints,
480
+ pkgIsModule,
481
+ entries,
482
+ config
483
+ });
484
+ const leafMap = /* @__PURE__ */ new Map();
485
+ getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
486
+ if (typeof value === "string") {
487
+ const keysArr = leafMap.get(value) ?? [];
488
+ leafMap.set(value, keysArr);
489
+ keysArr.push(keys);
490
+ }
491
+ return false;
492
+ });
493
+ const configs = [];
494
+ leafMap.forEach(
495
+ (keysArr, input) => keysArr.forEach((keys) => {
496
+ const [path, ...conditionals] = keys;
497
+ const name2 = packageName + (path === "." ? "" : pascalCase(path));
498
+ const keyExports = reveal(exports, keys);
499
+ const commonOptions = {
500
+ path,
501
+ name: name2,
502
+ input,
503
+ external,
504
+ pkgIsModule
505
+ };
506
+ switch (typeof keyExports) {
507
+ case "string": {
508
+ configs.push(...generateConfigs({
509
+ ...commonOptions,
510
+ output: keyExports,
511
+ conditionals
512
+ }, build));
513
+ break;
514
+ }
515
+ case "object": {
516
+ getAllLeafs(keyExports, ({ keys: nextKeys, value }) => {
517
+ const allConditionals = [.../* @__PURE__ */ new Set([...conditionals, ...nextKeys])];
518
+ if (typeof value === "string") {
519
+ configs.push(...generateConfigs({
520
+ ...commonOptions,
521
+ output: value,
522
+ conditionals: allConditionals
523
+ }, build));
524
+ }
525
+ return false;
526
+ });
527
+ break;
528
+ }
529
+ }
530
+ })
531
+ );
532
+ sendMessage(
533
+ {
534
+ type: "init",
535
+ data: {
536
+ leafMap,
537
+ targetsLength: configs.length
538
+ }
539
+ }
540
+ );
541
+ return configs.map((c) => ({
542
+ ...COMMON_OPTIONS,
543
+ ...c,
544
+ plugins: [
545
+ ...COMMON_PLUGINS,
546
+ c.plugins
547
+ ]
548
+ }));
549
+ }
550
+
551
+ export { template };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../src/utils/getRoot.ts","../../src/utils/filterSupport.ts","../../src/utils/getWD.ts","../../src/utils/tsRegister.ts","../../src/utils/loadConfig.ts","../../src/rollup/plugins/progress.ts","../../src/rollup/plugins/skip.ts","../../src/rollup/utils/externalResolver.ts","../../src/rollup/index.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { program } from 'commander'\n\nlet root: string\nexport function getRoot() {\n if (root) return root\n\n const rootOption = program.getOptionValue('root')\n root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : undefined\n return root\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { getRoot } from './getRoot'\nimport { getWD } from './getWD'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const root = getRoot()\n const { wd, notWorkspace } = getWD()\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd,\n root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd,\n root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","import { getWorkspaceDir, isWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\n\nimport { type } from './filterSupport'\nimport { getRoot } from './getRoot'\n\nlet wd: string\nlet notWorkspace = false\n\nexport function getWD() {\n if (wd) return { wd, notWorkspace }\n\n const root = getRoot()\n if (root !== undefined) {\n const isWorkspace = isWorkspaceDir(root, type)\n notWorkspace = !isWorkspace\n wd = root\n return { wd, notWorkspace }\n }\n try {\n wd = getWorkspaceDir(type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n return { wd, notWorkspace }\n}\n","function packageIsExist(name: string) {\n try {\n require.resolve(name)\n return true\n } catch (e) {\n return false\n }\n}\n\nexport let tsRegisterName: string | undefined\nconst registers = [\n process.env.JIEK_TS_REGISTER,\n 'esbuild-register',\n '@swc-node/register',\n 'ts-node/register'\n].filter(Boolean) as string[]\nfor (const register of registers) {\n if (packageIsExist(register)) {\n tsRegisterName = register\n break\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\nimport type { Config } from 'jiek'\nimport { load } from 'js-yaml'\n\nimport { getWD } from './getWD'\nimport { tsRegisterName } from './tsRegister'\n\nlet configName = 'jiek.config'\n\nfunction getConfigPath(root: string) {\n const isSupportTsLoader = !!tsRegisterName\n function configWithExtIsExist(ext: string) {\n const filenames = [\n path.resolve(process.cwd(), `${configName}.${ext}`),\n path.resolve(process.cwd(), `.${configName}.${ext}`),\n path.resolve(root, `${configName}.${ext}`),\n path.resolve(root, `.${configName}.${ext}`)\n ]\n for (const filename of filenames) {\n if (\n fs.existsSync(filename)\n && fs.lstatSync(filename)\n .isFile()\n ) {\n return filename\n }\n }\n return\n }\n configName = configWithExtIsExist('js') ?? configName\n configName = configWithExtIsExist('json') ?? configName\n configName = configWithExtIsExist('yaml') ?? configName\n if (isSupportTsLoader) {\n configName = configWithExtIsExist('ts') ?? configName\n }\n return path.resolve(root, configName)\n}\n\nexport function loadConfig(): Config {\n const { wd: root, notWorkspace } = getWD()\n if (notWorkspace) {\n throw new Error('not in workspace')\n }\n\n let configPath = program.getOptionValue('configPath')\n\n if (!configPath) {\n configPath = getConfigPath(root)\n } else {\n if (!fs.existsSync(configPath)) {\n throw new Error(`config file not found: ${configPath}`)\n }\n if (!path.isAbsolute(configPath)) {\n configPath = path.resolve(root, configPath)\n }\n }\n const ext = path.extname(configPath)\n\n let module: any\n switch (ext) {\n case '.js':\n module = require(configPath)\n break\n case '.json':\n return require(configPath)\n case '.yaml':\n return load(fs.readFileSync(configPath, 'utf-8')) as Config\n case '.ts':\n if (tsRegisterName) {\n require(tsRegisterName)\n module = require(configPath)\n break\n }\n throw new Error(\n 'ts config file is not supported without ts register, '\n + 'please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register'\n )\n case '.config':\n module = {}\n break\n default:\n throw new Error(`unsupported config file type: ${ext}`)\n }\n if (!module) throw new Error('config file is empty')\n\n return module.default ?? module\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n onEvent?: (event: string, message?: string) => void\n}\n\nexport default ((options = {}) => {\n const { onEvent } = options\n return {\n name: 'progress',\n buildStart: () => onEvent?.('start', 'Start building...'),\n buildEnd: () => onEvent?.('end', 'Build completed!'),\n resolveId: {\n order: 'post',\n handler: source => onEvent?.('resolve', `Resolving ${source}...`)\n },\n load: {\n order: 'post',\n handler: id => onEvent?.('load', `Loading ${id}...`)\n },\n transform: {\n order: 'post',\n handler: (_, id) => onEvent?.('transform', `Transforming ${id}...`)\n }\n }\n}) as PluginImpl<Options>\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import fs from 'node:fs'\n\nexport default function(json: Record<string, unknown>): (string | RegExp)[]\nexport default function(path?: string): (string | RegExp)[]\nexport default function(jsonOrPath: string | Record<string, unknown> = process.cwd()): (string | RegExp)[] {\n const pkg = typeof jsonOrPath === 'string'\n ? fs.existsSync(`${jsonOrPath}/package.json`)\n ? JSON.parse(fs.readFileSync(`${jsonOrPath}/package.json`, 'utf-8'))\n : {}\n : jsonOrPath\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]> Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n","import '../rollup/base'\n\nimport fs from 'node:fs'\nimport { dirname, resolve } from 'node:path'\n\nimport type { Entrypoints2ExportsOptions, RecursiveRecord } from '@jiek/pkger/entrypoints'\nimport {\n DEFAULT_SKIP_VALUES,\n entrypoints2Exports,\n filterLeafs,\n getAllLeafs,\n resolveEntrypoints\n} from '@jiek/pkger/entrypoints'\nimport { dts } from '@jiek/rollup-plugin-dts'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport { nodeResolve } from '@rollup/plugin-node-resolve'\nimport terser from '@rollup/plugin-terser'\nimport { sendMessage } from 'execa'\nimport { parse } from 'jsonc-parser'\nimport { isMatch } from 'micromatch'\nimport type { OutputOptions, OutputPlugin, RollupOptions } from 'rollup'\nimport esbuild from 'rollup-plugin-esbuild'\nimport ts from 'typescript'\n\nimport { loadConfig } from '../utils/loadConfig'\nimport type { RollupProgressEvent, TemplateOptions } from './base'\nimport progress from './plugins/progress'\nimport skip from './plugins/skip'\nimport externalResolver from './utils/externalResolver'\n\ninterface PackageJSON {\n name?: string\n type?: string\n exports?: Record<string, unknown> | string | string[]\n}\n\nconst {\n JIEK_ROOT,\n JIEK_ENTRIES\n} = process.env\nconst WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir()\nconst COMMON_OPTIONS = {} satisfies RollupOptions\nconst COMMON_PLUGINS = [\n json()\n]\n\nconst { build } = loadConfig()\nconst jsOutdir = resolve(\n (\n typeof build?.output?.dir === 'object'\n // the outdir only effect js output in this function\n ? build.output.dir.js\n : build?.output?.dir\n ) ?? 'dist'\n)\n\nconst STYLE_REGEXP = /\\.(css|s[ac]ss|less|styl)$/\n\n// eslint-disable-next-line unused-imports/no-unused-vars\nconst debug = (...args: unknown[]) => sendMessage({ type: 'debug', data: args } satisfies RollupProgressEvent)\n\nconst resolveWorkspacePath = (p: string) => resolve(WORKSPACE_ROOT, p)\n\nconst intersection = <T>(a: Set<T>, b: Set<T>) => new Set([...a].filter(i => b.has(i)))\n\nconst pascalCase = (str: string) =>\n str\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n .replace(/(?:^|-)(\\w)/g, (_, $1) => $1.toUpperCase())\n\nconst reveal = (obj: string | Record<string, unknown>, keys: string[]) =>\n keys.reduce((acc, key) => {\n if (typeof acc === 'string') throw new Error('key not found in exports')\n if (!(key in acc)) throw new Error(`key ${key} not found in exports`)\n return acc[key] as string | Record<string, unknown>\n }, obj)\n\nconst withMinify = (\n output: OutputOptions & {\n plugins?: OutputPlugin[]\n },\n minify = build?.output?.minify\n) =>\n minify === false\n ? [output]\n : minify === 'only-minify'\n ? [{\n ...output,\n // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'\n // TODO resolve dts output file name\n file: output.file?.replace(/(\\.[cm]?js)$/, '.min$1'),\n plugins: [\n ...(output.plugins ?? []),\n terser()\n ]\n }]\n : [\n output,\n {\n ...output,\n file: output.file?.replace(/(\\.[cm]?js)$/, '.min$1'),\n plugins: [\n ...(output.plugins ?? []),\n terser()\n ]\n }\n ]\n\ntype TSConfig = {\n extends?: string | string[]\n compilerOptions?: Record<string, unknown>\n references?: { path: string }[]\n files?: string[]\n include?: string[]\n exclude?: string[]\n}\n\nconst getTSConfig = (p: string): TSConfig =>\n !fs.existsSync(p) || !fs.statSync(p).isFile()\n ? {}\n : parse(fs.readFileSync(p, 'utf-8'), [], { allowTrailingComma: true, allowEmptyContent: true })\n\nconst getExtendTSConfig = (tsconfigPath: string): TSConfig => {\n tsconfigPath = resolve(tsconfigPath)\n const tsconfigPathDirname = dirname(tsconfigPath)\n const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath)\n const resolvePaths = (paths: string[] | undefined) => paths?.map(p => resolve(tsconfigPathDirname, p)) ?? []\n\n const extendsPaths = resolvePaths(\n exts ? Array.isArray(exts) ? exts : [exts] : []\n )\n if (extendsPaths.length === 0) return tsconfig\n return extendsPaths\n .map(getExtendTSConfig)\n // https://www.typescriptlang.org/tsconfig/#files:~:text=Currently%2C%20the%20only%20top%2Dlevel%20property%20that%20is%20excluded%20from%20inheritance%20is%20references.\n // Currently, the only top-level property that is excluded from inheritance is references.\n .reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({\n ...acc,\n ...curr,\n compilerOptions: {\n ...acc.compilerOptions,\n ...compilerOptions\n }\n }), tsconfig)\n}\n\nconst getCompilerOptionsByFilePath = (tsconfigPath: string, filePath: string): Record<string, unknown> | undefined => {\n tsconfigPath = resolve(tsconfigPath)\n filePath = resolve(filePath)\n const tsconfigPathDirname = dirname(tsconfigPath)\n // https://www.typescriptlang.org/tsconfig/#files:~:text=It%E2%80%99s%20worth%20noting%20that%20files%2C%20include%2C%20and%20exclude%20from%20the%20inheriting%20config%20file%20overwrite%20those%20from%20the%20base%20config%20file%2C%20and%20that%20circularity%20between%20configuration%20files%20is%20not%20allowed.\n // It’s worth noting that files, include, and exclude from the inheriting config file overwrite\n // those from the base config file, and that circularity between configuration files is not allowed.\n const tsconfig = getExtendTSConfig(tsconfigPath)\n\n const resolvePaths = (paths: string[] | undefined) => paths?.map(p => resolve(tsconfigPathDirname, p)) ?? []\n\n const [\n references,\n files,\n include,\n exclude\n ] = [\n tsconfig.references?.map(({ path }) => path),\n tsconfig.files,\n tsconfig.include,\n tsconfig.exclude\n ].map(resolvePaths)\n if (exclude.length > 0 && exclude.some(i => isMatch(filePath, i))) return\n\n // when files or include is not empty, the tsconfig should be ignored\n if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return\n let isInclude = false\n isInclude ||= files.length > 0 && files.includes(filePath)\n isInclude ||= include.length > 0 && include.some(i => isMatch(filePath, i))\n if (isInclude) {\n return tsconfig.compilerOptions ?? {}\n } else {\n // when files or include is not empty, but the file is not matched, the tsconfig should be ignored\n if (\n (tsconfig.files && tsconfig.files.length > 0)\n || (tsconfig.include && tsconfig.include.length > 0)\n ) return\n }\n\n references.reverse()\n for (const ref of references) {\n const compilerOptions = getCompilerOptionsByFilePath(ref, filePath)\n if (compilerOptions) return compilerOptions\n }\n return tsconfig.compilerOptions\n}\n\nconst generateConfigs = ({\n path,\n name,\n input,\n output,\n external,\n pkgIsModule,\n conditionals\n}: {\n path: string\n name: string\n input: string\n output: string\n external: (string | RegExp)[]\n pkgIsModule: boolean\n conditionals: string[]\n}, options: TemplateOptions = {}): RollupOptions[] => {\n const isModule = conditionals.includes('import')\n const isCommonJS = conditionals.includes('require')\n const isBrowser = conditionals.includes('browser')\n const dtsTSConfigPaths = [\n resolveWorkspacePath('tsconfig.json'),\n resolveWorkspacePath('tsconfig.dts.json')\n ]\n let dtsTSConfigPath: string | undefined\n dtsTSConfigPaths.forEach(p => {\n if (fs.existsSync(p) && fs.statSync(p).isFile()) {\n dtsTSConfigPath = p\n }\n })\n let compilerOptions: ts.CompilerOptions = {}\n if (dtsTSConfigPath) {\n const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, resolve(input))\n const { options, errors } = ts.convertCompilerOptionsFromJson(\n jsonCompilerOptions,\n dirname(dtsTSConfigPath)\n )\n if (errors.length > 0) {\n throw new Error(errors.map(e => e.messageText).join('\\n'))\n }\n compilerOptions = options\n }\n const exportConditions = [...conditionals, ...(compilerOptions.customConditions ?? [])]\n const throughEventProps: RollupProgressEvent & { type: 'progress' } = {\n type: 'progress',\n data: { name, path, exportConditions, input }\n }\n const outdir = options?.output?.dir\n return [\n {\n input,\n external,\n output: [\n ...withMinify({\n file: output,\n name,\n sourcemap: typeof options?.output?.sourcemap === 'object'\n ? options.output.sourcemap.js\n : options?.output?.sourcemap ?? true,\n format: isModule ? 'esm' : (\n isCommonJS ? 'cjs' : (\n isBrowser ? 'umd' : (\n pkgIsModule ? 'esm' : 'cjs'\n )\n )\n ),\n strict: typeof options?.output?.strict === 'object'\n ? options.output.strict.js\n : options?.output?.strict\n })\n ],\n plugins: [\n nodeResolve({ exportConditions }),\n import('rollup-plugin-postcss')\n .then(({ default: postcss }) =>\n postcss({\n extract: resolve(output.replace(/\\.[cm]?js$/, '.css')),\n minimize: true\n })\n )\n .catch(() => void 0),\n esbuild(),\n progress({\n onEvent: (event, message) =>\n sendMessage(\n {\n ...throughEventProps,\n data: { ...throughEventProps.data, event, message, tags: ['js'] }\n } satisfies RollupProgressEvent\n )\n })\n ]\n },\n {\n input,\n external,\n output: [\n {\n dir: resolve((typeof outdir === 'object' ? outdir.dts : outdir) ?? 'dist'),\n sourcemap: typeof options?.output?.sourcemap === 'object'\n ? options.output.sourcemap.dts\n : options?.output?.sourcemap ?? true,\n entryFileNames: () =>\n output\n .replace(`${jsOutdir}/`, '')\n .replace(/(\\.[cm]?)js$/, '.d$1ts'),\n strict: typeof options?.output?.strict === 'object'\n ? options.output.strict.dts\n : options?.output?.strict\n }\n ],\n plugins: [\n nodeResolve({ exportConditions }),\n skip({ patterns: [STYLE_REGEXP] }),\n dts({\n respectExternal: true,\n compilerOptions\n }),\n progress({\n onEvent: (event, message) =>\n sendMessage(\n {\n ...throughEventProps,\n data: { ...throughEventProps.data, event, message, tags: ['dts'] }\n } satisfies RollupProgressEvent\n )\n })\n ]\n }\n ]\n}\n\nexport function template(packageJSON: PackageJSON): RollupOptions[] {\n const { name, type, exports: entrypoints } = packageJSON\n const pkgIsModule = type === 'module'\n if (!name) throw new Error('package.json name is required')\n if (!entrypoints) throw new Error('package.json exports is required')\n\n const entries = JIEK_ENTRIES\n ?.split(',')\n .map(e => e.trim())\n .map(e => ({\n 'index': '.'\n }[e] ?? e))\n\n const {\n crossModuleConvertor = true\n } = build ?? {}\n\n const packageName = pascalCase(name)\n\n const external = externalResolver(packageJSON as Record<string, unknown>)\n\n const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints)\n if (entries) {\n Object\n .entries(resolvedEntrypoints)\n .forEach(([key]) => {\n if (!entries.some(e => isMatch(key, e, { matchBase: true }))) {\n delete resolvedEntrypoints[key]\n }\n })\n }\n const filteredResolvedEntrypoints = filterLeafs(\n resolvedEntrypoints as RecursiveRecord<string>,\n {\n skipValue: [\n // ignore values that filename starts with `.jk-noentry`\n /(^|\\/)\\.jk-noentry/,\n ...DEFAULT_SKIP_VALUES\n ]\n }\n )\n const crossModuleWithConditional: Entrypoints2ExportsOptions['withConditional'] = crossModuleConvertor\n ? {\n import: opts =>\n !pkgIsModule && intersection(\n new Set(opts.conditionals),\n new Set(['import', 'module'])\n ).size === 0\n ? opts.dist.replace(/\\.js$/, '.mjs')\n : false,\n require: opts => {\n return pkgIsModule && intersection(\n new Set(opts.conditionals),\n new Set(['require', 'node'])\n ).size === 0\n ? opts.dist.replace(/\\.js$/, '.cjs')\n : false\n }\n }\n : {}\n const exports = entrypoints2Exports(filteredResolvedEntrypoints, {\n outdir: jsOutdir,\n withConditional: {\n ...crossModuleWithConditional\n }\n })\n\n const leafMap = new Map<string, string[][]>()\n getAllLeafs(filteredResolvedEntrypoints as RecursiveRecord<string>, ({ keys, value }) => {\n if (typeof value === 'string') {\n const keysArr = leafMap.get(value) ?? []\n leafMap.set(value, keysArr)\n keysArr.push(keys)\n }\n return false\n })\n\n const configs: RollupOptions[] = []\n leafMap.forEach((keysArr, input) =>\n keysArr.forEach((keys) => {\n const [path, ...conditionals] = keys\n\n const name = packageName + (path === '.' ? '' : pascalCase(path))\n const keyExports = reveal(exports, keys)\n const commonOptions = {\n path,\n name,\n input,\n external,\n pkgIsModule\n }\n\n switch (typeof keyExports) {\n case 'string': {\n configs.push(...generateConfigs({\n ...commonOptions,\n output: keyExports,\n conditionals\n }, build))\n break\n }\n case 'object': {\n getAllLeafs(keyExports as RecursiveRecord<string>, ({ keys: nextKeys, value }) => {\n const allConditionals = [...new Set([...conditionals, ...nextKeys])]\n if (typeof value === 'string') {\n configs.push(...generateConfigs({\n ...commonOptions,\n output: value,\n conditionals: allConditionals\n }, build))\n }\n return false\n })\n break\n }\n }\n })\n )\n sendMessage(\n {\n type: 'init',\n data: {\n leafMap,\n targetsLength: configs.length\n }\n } satisfies RollupProgressEvent\n )\n return configs.map(c => ({\n ...COMMON_OPTIONS,\n ...c,\n plugins: [\n ...COMMON_PLUGINS,\n c.plugins\n ]\n }))\n}\n"],"names":["options","name"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAI,IAAA,CAAA;AACG,SAAS,OAAU,GAAA;AACxB,EAAI,IAAA,IAAA;AAAM,IAAO,OAAA,IAAA,CAAA;AAEjB,EAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAChD,EAAA,IAAA,GAAO,UACH,GAAA,IAAA,CAAK,UAAW,CAAA,UAAU,CACxB,GAAA,UAAA,GACA,IAAK,CAAA,OAAA,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