jiek 0.4.7-alpha.3 → 0.4.7-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,33 +1,33 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs');
4
- var path = require('node:path');
5
- var entrypoints = require('@jiek/pkger/entrypoints');
6
- var rollupPluginDts = require('@jiek/rollup-plugin-dts');
7
- var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
8
- var json = require('@rollup/plugin-json');
9
- var pluginNodeResolve = require('@rollup/plugin-node-resolve');
10
- var terser = require('@rollup/plugin-terser');
11
- var execa = require('execa');
12
- var jsoncParser = require('jsonc-parser');
13
- var micromatch = require('micromatch');
14
- var esbuild = require('rollup-plugin-esbuild');
15
- var ts = require('typescript');
16
- var commander = require('commander');
17
- var jsYaml = require('js-yaml');
18
- require('@pnpm/filter-workspace-packages');
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';
19
17
 
20
18
  const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
21
19
  function getExports({
22
- entrypoints: entrypoints$1,
20
+ entrypoints,
23
21
  pkgIsModule,
24
22
  entries,
25
23
  config,
26
24
  dir,
27
- noFilter
25
+ noFilter,
26
+ withSource,
27
+ withSuffix
28
28
  }) {
29
- const dirResolve = (...paths) => path.resolve(dir ?? process.cwd(), ...paths);
30
- const dirRelative = (path$1) => path.relative(dir ?? process.cwd(), path$1);
29
+ const dirResolve = (...paths) => resolve(dir ?? process.cwd(), ...paths);
30
+ const dirRelative = (path) => relative(dir ?? process.cwd(), path);
31
31
  const { build = {} } = config ?? {};
32
32
  const {
33
33
  crossModuleConvertor = true
@@ -35,21 +35,21 @@ function getExports({
35
35
  const jsOutdir = `./${dirRelative(dirResolve(
36
36
  (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
37
37
  ))}`;
38
- const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
38
+ const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
39
39
  if (entries) {
40
40
  Object.entries(resolvedEntrypoints).forEach(([key]) => {
41
- if (!entries.some((e) => micromatch.isMatch(key, e, { matchBase: true }))) {
41
+ if (!entries.some((e) => isMatch(key, e, { matchBase: true }))) {
42
42
  delete resolvedEntrypoints[key];
43
43
  }
44
44
  });
45
45
  }
46
- const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : entrypoints.filterLeafs(
46
+ const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : filterLeafs(
47
47
  resolvedEntrypoints,
48
48
  {
49
49
  skipValue: [
50
50
  // ignore values that filename starts with `.jk-noentry`
51
51
  /(^|\/)\.jk-noentry/,
52
- ...entrypoints.DEFAULT_SKIP_VALUES
52
+ ...DEFAULT_SKIP_VALUES
53
53
  ]
54
54
  }
55
55
  );
@@ -65,8 +65,10 @@ function getExports({
65
65
  } : {};
66
66
  return [
67
67
  filteredResolvedEntrypoints,
68
- entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
68
+ entrypoints2Exports(filteredResolvedEntrypoints, {
69
69
  outdir: jsOutdir,
70
+ withSource,
71
+ withSuffix,
70
72
  withConditional: {
71
73
  ...crossModuleWithConditional
72
74
  }
@@ -78,7 +80,7 @@ let root;
78
80
  function getRoot() {
79
81
  if (root)
80
82
  return root;
81
- const rootOption = commander.program.getOptionValue("root");
83
+ const rootOption = program.getOptionValue("root");
82
84
  root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
83
85
  return root;
84
86
  }
@@ -90,7 +92,7 @@ try {
90
92
  } catch {
91
93
  }
92
94
  if (type !== "") {
93
- commander.program.option("-f, --filter <filter>", "filter packages");
95
+ program.option("-f, --filter <filter>", "filter packages");
94
96
  }
95
97
 
96
98
  let wd;
@@ -100,13 +102,13 @@ function getWD() {
100
102
  return { wd, notWorkspace };
101
103
  const root = getRoot();
102
104
  if (root !== void 0) {
103
- const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type);
105
+ const isWorkspace = isWorkspaceDir(root, type);
104
106
  notWorkspace = !isWorkspace;
105
107
  wd = root;
106
108
  return { wd, notWorkspace };
107
109
  }
108
110
  try {
109
- wd = getWorkspaceDir.getWorkspaceDir(type);
111
+ wd = getWorkspaceDir(type);
110
112
  } catch (e) {
111
113
  if ("message" in e && e.message === "workspace root not found") {
112
114
  wd = root;
@@ -173,7 +175,7 @@ function getConfigPath(root, dir) {
173
175
  }
174
176
  function loadConfig(dir) {
175
177
  const { wd: root } = getWD();
176
- let configPath = commander.program.getOptionValue("configPath");
178
+ let configPath = program.getOptionValue("configPath");
177
179
  if (!configPath) {
178
180
  configPath = getConfigPath(root, dir);
179
181
  } else {
@@ -193,7 +195,7 @@ function loadConfig(dir) {
193
195
  case ".json":
194
196
  return require(configPath);
195
197
  case ".yaml":
196
- return jsYaml.load(fs.readFileSync(configPath, "utf-8"));
198
+ return load(fs.readFileSync(configPath, "utf-8"));
197
199
  case ".ts":
198
200
  if (tsRegisterName) {
199
201
  require(tsRegisterName);
@@ -262,21 +264,21 @@ const {
262
264
  JIEK_ROOT,
263
265
  JIEK_ENTRIES
264
266
  } = process.env;
265
- const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
267
+ const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir();
266
268
  const COMMON_OPTIONS = {};
267
269
  const COMMON_PLUGINS = [
268
270
  json()
269
271
  ];
270
272
  const config = loadConfig() ?? {};
271
273
  const { build = {} } = config;
272
- const jsOutdir = `./${path.relative(
274
+ const jsOutdir = `./${relative(
273
275
  process.cwd(),
274
- path.resolve(
276
+ resolve(
275
277
  (typeof build?.output?.dir === "object" ? build.output.dir.js : build?.output?.dir) ?? "dist"
276
278
  )
277
279
  )}`;
278
280
  const STYLE_REGEXP = /\.(css|s[ac]ss|less|styl)$/;
279
- const resolveWorkspacePath = (p) => path.resolve(WORKSPACE_ROOT, p);
281
+ const resolveWorkspacePath = (p) => resolve(WORKSPACE_ROOT, p);
280
282
  const pascalCase = (str) => str.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()).replace(/(?:^|-)(\w)/g, (_, $1) => $1.toUpperCase());
281
283
  const reveal = (obj, keys) => keys.reduce((acc, key) => {
282
284
  if (typeof acc === "string")
@@ -305,12 +307,12 @@ const withMinify = (output, minify = build?.output?.minify) => minify === false
305
307
  ]
306
308
  }
307
309
  ];
308
- const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : jsoncParser.parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
310
+ const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
309
311
  const getExtendTSConfig = (tsconfigPath) => {
310
- tsconfigPath = path.resolve(tsconfigPath);
311
- const tsconfigPathDirname = path.dirname(tsconfigPath);
312
+ tsconfigPath = resolve(tsconfigPath);
313
+ const tsconfigPathDirname = dirname(tsconfigPath);
312
314
  const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
313
- const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
315
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
314
316
  const extendsPaths = resolvePaths(
315
317
  exts ? Array.isArray(exts) ? exts : [exts] : []
316
318
  );
@@ -326,11 +328,11 @@ const getExtendTSConfig = (tsconfigPath) => {
326
328
  }), tsconfig);
327
329
  };
328
330
  const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
329
- tsconfigPath = path.resolve(tsconfigPath);
330
- filePath = path.resolve(filePath);
331
- const tsconfigPathDirname = path.dirname(tsconfigPath);
331
+ tsconfigPath = resolve(tsconfigPath);
332
+ filePath = resolve(filePath);
333
+ const tsconfigPathDirname = dirname(tsconfigPath);
332
334
  const tsconfig = getExtendTSConfig(tsconfigPath);
333
- const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
335
+ const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
334
336
  const [
335
337
  references,
336
338
  files,
@@ -342,13 +344,13 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
342
344
  tsconfig.include,
343
345
  tsconfig.exclude
344
346
  ].map(resolvePaths);
345
- if (exclude.length > 0 && exclude.some((i) => micromatch.isMatch(filePath, i)))
347
+ if (exclude.length > 0 && exclude.some((i) => isMatch(filePath, i)))
346
348
  return;
347
349
  if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
348
350
  return;
349
351
  let isInclude = false;
350
352
  isInclude || (isInclude = files.length > 0 && files.includes(filePath));
351
- isInclude || (isInclude = include.length > 0 && include.some((i) => micromatch.isMatch(filePath, i)));
353
+ isInclude || (isInclude = include.length > 0 && include.some((i) => isMatch(filePath, i)));
352
354
  if (isInclude) {
353
355
  return tsconfig.compilerOptions ?? {};
354
356
  } else {
@@ -364,7 +366,7 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
364
366
  return tsconfig.compilerOptions;
365
367
  };
366
368
  const generateConfigs = ({
367
- path: path$1,
369
+ path,
368
370
  name,
369
371
  input,
370
372
  output,
@@ -387,10 +389,10 @@ const generateConfigs = ({
387
389
  });
388
390
  let compilerOptions = {};
389
391
  if (dtsTSConfigPath) {
390
- const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, path.resolve(input));
392
+ const jsonCompilerOptions = getCompilerOptionsByFilePath(dtsTSConfigPath, resolve(input));
391
393
  const { options: options2, errors } = ts.convertCompilerOptionsFromJson(
392
394
  jsonCompilerOptions,
393
- path.dirname(dtsTSConfigPath)
395
+ dirname(dtsTSConfigPath)
394
396
  );
395
397
  if (errors.length > 0) {
396
398
  throw new Error(errors.map((e) => e.messageText).join("\n"));
@@ -400,7 +402,7 @@ const generateConfigs = ({
400
402
  const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
401
403
  const throughEventProps = {
402
404
  type: "progress",
403
- data: { name, path: path$1, exportConditions, input }
405
+ data: { name, path, exportConditions, input }
404
406
  };
405
407
  const outdir = options?.output?.dir;
406
408
  return [
@@ -417,16 +419,16 @@ const generateConfigs = ({
417
419
  })
418
420
  ],
419
421
  plugins: [
420
- pluginNodeResolve.nodeResolve({ exportConditions }),
422
+ nodeResolve({ exportConditions }),
421
423
  import('rollup-plugin-postcss').then(
422
424
  ({ default: postcss }) => postcss({
423
- extract: path.resolve(output.replace(/\.[cm]?js$/, ".css")),
425
+ extract: resolve(output.replace(/\.[cm]?js$/, ".css")),
424
426
  minimize: true
425
427
  })
426
428
  ).catch(() => void 0),
427
429
  esbuild(),
428
430
  progress({
429
- onEvent: (event, message) => execa.sendMessage(
431
+ onEvent: (event, message) => sendMessage(
430
432
  {
431
433
  ...throughEventProps,
432
434
  data: { ...throughEventProps.data, event, message, tags: ["js"] }
@@ -440,21 +442,21 @@ const generateConfigs = ({
440
442
  external,
441
443
  output: [
442
444
  {
443
- dir: path.resolve((typeof outdir === "object" ? outdir.dts : outdir) ?? "dist"),
445
+ dir: resolve((typeof outdir === "object" ? outdir.dts : outdir) ?? "dist"),
444
446
  sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap,
445
447
  entryFileNames: () => output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, ".d$1ts"),
446
448
  strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
447
449
  }
448
450
  ],
449
451
  plugins: [
450
- pluginNodeResolve.nodeResolve({ exportConditions }),
452
+ nodeResolve({ exportConditions }),
451
453
  skip({ patterns: [STYLE_REGEXP] }),
452
- rollupPluginDts.dts({
454
+ dts({
453
455
  respectExternal: true,
454
456
  compilerOptions
455
457
  }),
456
458
  progress({
457
- onEvent: (event, message) => execa.sendMessage(
459
+ onEvent: (event, message) => sendMessage(
458
460
  {
459
461
  ...throughEventProps,
460
462
  data: { ...throughEventProps.data, event, message, tags: ["dts"] }
@@ -466,11 +468,11 @@ const generateConfigs = ({
466
468
  ];
467
469
  };
468
470
  function template(packageJSON) {
469
- const { name, type, exports: entrypoints$1 } = packageJSON;
471
+ const { name, type, exports: entrypoints } = packageJSON;
470
472
  const pkgIsModule = type === "module";
471
473
  if (!name)
472
474
  throw new Error("package.json name is required");
473
- if (!entrypoints$1)
475
+ if (!entrypoints)
474
476
  throw new Error("package.json exports is required");
475
477
  const entries = JIEK_ENTRIES?.split(",").map((e) => e.trim()).map((e) => ({
476
478
  "index": "."
@@ -478,13 +480,13 @@ function template(packageJSON) {
478
480
  const packageName = pascalCase(name);
479
481
  const external = externalResolver(packageJSON);
480
482
  const [filteredResolvedEntrypoints, exports] = getExports({
481
- entrypoints: entrypoints$1,
483
+ entrypoints,
482
484
  pkgIsModule,
483
485
  entries,
484
486
  config
485
487
  });
486
488
  const leafMap = /* @__PURE__ */ new Map();
487
- entrypoints.getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
489
+ getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
488
490
  if (typeof value === "string") {
489
491
  const keysArr = leafMap.get(value) ?? [];
490
492
  leafMap.set(value, keysArr);
@@ -515,7 +517,7 @@ function template(packageJSON) {
515
517
  break;
516
518
  }
517
519
  case "object": {
518
- entrypoints.getAllLeafs(keyExports, ({ keys: nextKeys, value }) => {
520
+ getAllLeafs(keyExports, ({ keys: nextKeys, value }) => {
519
521
  const allConditionals = [.../* @__PURE__ */ new Set([...conditionals, ...nextKeys])];
520
522
  if (typeof value === "string") {
521
523
  configs.push(...generateConfigs({
@@ -531,7 +533,7 @@ function template(packageJSON) {
531
533
  }
532
534
  })
533
535
  );
534
- execa.sendMessage(
536
+ sendMessage(
535
537
  {
536
538
  type: "init",
537
539
  data: {
@@ -550,4 +552,4 @@ function template(packageJSON) {
550
552
  }));
551
553
  }
552
554
 
553
- exports.template = template;
555
+ export { template };
@@ -0,0 +1 @@
1
+ "use strict";var e=require("node:fs"),t=require("node:path"),r=require("@jiek/pkger/entrypoints"),s=require("@jiek/rollup-plugin-dts"),o=require("@jiek/utils/getWorkspaceDir"),n=require("@rollup/plugin-json"),i=require("@rollup/plugin-node-resolve"),c=require("@rollup/plugin-terser"),p=require("execa"),u=require("jsonc-parser"),a=require("micromatch"),l=require("rollup-plugin-esbuild"),d=require("typescript"),f=require("commander"),m=require("js-yaml");require("@pnpm/filter-workspace-packages");const g=(e,t)=>new Set([...e].filter((e=>t.has(e))));let h;function y(){if(h)return h;const e=f.program.getOptionValue("root");return h=e?t.isAbsolute(e)?e:t.resolve(process.cwd(),e):void 0,h}let w,v="";try{require.resolve("@pnpm/filter-workspace-packages"),v="pnpm"}catch{}""!==v&&f.program.option("-f, --filter <filter>","filter packages");let j,k=!1;function $(e){try{return require.resolve(e),!0}catch(e){return!1}}const E=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of E)if($(e)){j=e;break}let S="jiek.config";var x=(e={})=>{const{onEvent:t}=e;return{name:"progress",buildStart:()=>t?.("start","Start building..."),buildEnd:()=>t?.("end","Build completed!"),resolveId:{order:"post",handler:e=>t?.("resolve",`Resolving ${e}...`)},load:{order:"post",handler:e=>t?.("load",`Loading ${e}...`)},transform:{order:"post",handler:(e,r)=>t?.("transform",`Transforming ${r}...`)}}},b=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const{JIEK_ROOT:q,JIEK_ENTRIES:O}=process.env,I=q??o.getWorkspaceDir(),M={},C=[n()],F=function(r){const{wd:s}=function(){if(w)return{wd:w,notWorkspace:k};const e=y();if(void 0!==e){const t=o.isWorkspaceDir(e,v);return k=!t,w=e,{wd:w,notWorkspace:k}}try{w=o.getWorkspaceDir(v)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;w=e,k=!0}return{wd:w,notWorkspace:k}}();let n=f.program.getOptionValue("configPath");if(n){if(!e.existsSync(n))throw new Error(`config file not found: ${n}`);t.isAbsolute(n)||(n=t.resolve(s,n))}else n=function(r,s){const o=!!j;function n(o){const n=[t.resolve(process.cwd(),`${S}.${o}`),t.resolve(process.cwd(),`.${S}.${o}`),t.resolve(r,`${S}.${o}`),t.resolve(r,`.${S}.${o}`)];s&&n.unshift(t.resolve(s,`${S}.${o}`),t.resolve(s,`.${S}.${o}`));for(const t of n)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return S=n("js")??S,S=n("json")??S,S=n("yaml")??S,o&&(S=n("ts")??S),t.resolve(r,S)}(s,r);const i=t.extname(n);let c;switch(i){case".js":c=require(n);break;case".json":return require(n);case".yaml":return m.load(e.readFileSync(n,"utf-8"));case".ts":if(j){require(j),c=require(n);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":c={};break;default:throw new Error(`unsupported config file type: ${i}`)}if(!c)throw new Error("config file is empty");return c.default??c}()??{},{build:R={}}=F,T=`./${t.relative(process.cwd(),t.resolve(("object"==typeof R?.output?.dir?R.output.dir.js:R?.output?.dir)??"dist"))}`,A=/\.(css|s[ac]ss|less|styl)$/,_=e=>t.resolve(I,e),D=e=>e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())).replace(/(?:^|-)(\w)/g,((e,t)=>t.toUpperCase())),L=(e,t=R?.output?.minify)=>!1===t?[e]:"only-minify"===t?[{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],c()]}]:[e,{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],c()]}],W=r=>{r=t.resolve(r);const s=t.dirname(r),{extends:o,...n}=(i=r,e.existsSync(i)&&e.statSync(i).isFile()?u.parse(e.readFileSync(i,"utf-8"),[],{allowTrailingComma:!0,allowEmptyContent:!0}):{});var i;const c=(p=o?Array.isArray(o)?o:[o]:[],p?.map((e=>t.resolve(s,e)))??[]);var p;return 0===c.length?n:c.map(W).reduce(((e,{compilerOptions:t={},references:r,...s})=>({...e,...s,compilerOptions:{...e.compilerOptions,...t}})),n)},J=(e,r)=>{e=t.resolve(e),r=t.resolve(r);const s=t.dirname(e),o=W(e),[n,i,c,p]=[o.references?.map((({path:e})=>e)),o.files,o.include,o.exclude].map((e=>e?.map((e=>t.resolve(s,e)))??[]));if(p.length>0&&p.some((e=>a.isMatch(r,e))))return;if(0===o.files?.length&&0===o.include?.length)return;let u=!1;if(u||(u=i.length>0&&i.includes(r)),u||(u=c.length>0&&c.some((e=>a.isMatch(r,e)))),u)return o.compilerOptions??{};if(!(o.files&&o.files.length>0||o.include&&o.include.length>0)){n.reverse();for(const e of n){const t=J(e,r);if(t)return t}return o.compilerOptions}},K=({path:r,name:o,input:n,output:c,external:u,pkgIsModule:a,conditionals:f},m={})=>{const g=f.includes("import"),h=f.includes("require"),y=f.includes("browser");let w;[_("tsconfig.json"),_("tsconfig.dts.json")].forEach((t=>{e.existsSync(t)&&e.statSync(t).isFile()&&(w=t)}));let v={};if(w){const e=J(w,t.resolve(n)),{options:r,errors:s}=d.convertCompilerOptionsFromJson(e,t.dirname(w));if(s.length>0)throw new Error(s.map((e=>e.messageText)).join("\n"));v=r}const j=[...f,...v.customConditions??[]],k={type:"progress",data:{name:o,path:r,exportConditions:j,input:n}},$=m?.output?.dir;return[{input:n,external:u,output:[...L({file:c,name:o,sourcemap:"object"==typeof m?.output?.sourcemap?m.output.sourcemap.js:m?.output?.sourcemap,format:g?"esm":h?"cjs":y?"umd":a?"esm":"cjs",strict:"object"==typeof m?.output?.strict?m.output.strict.js:m?.output?.strict})],plugins:[i.nodeResolve({exportConditions:j}),import("rollup-plugin-postcss").then((({default:e})=>e({extract:t.resolve(c.replace(/\.[cm]?js$/,".css")),minimize:!0}))).catch((()=>{})),l(),x({onEvent:(e,t)=>p.sendMessage({...k,data:{...k.data,event:e,message:t,tags:["js"]}})})]},{input:n,external:u,output:[{dir:t.resolve(("object"==typeof $?$.dts:$)??"dist"),sourcemap:"object"==typeof m?.output?.sourcemap?m.output.sourcemap.dts:m?.output?.sourcemap,entryFileNames:()=>c.replace(`${T}/`,"").replace(/(\.[cm]?)js$/,".d$1ts"),strict:"object"==typeof m?.output?.strict?m.output.strict.dts:m?.output?.strict}],plugins:[i.nodeResolve({exportConditions:j}),b({patterns:[A]}),s.dts({respectExternal:!0,compilerOptions:v}),x({onEvent:(e,t)=>p.sendMessage({...k,data:{...k.data,event:e,message:t,tags:["dts"]}})})]}]};exports.template=function(s){const{name:o,type:n,exports:i}=s,c="module"===n;if(!o)throw new Error("package.json name is required");if(!i)throw new Error("package.json exports is required");const u=O?.split(",").map((e=>e.trim())).map((e=>({index:"."}[e]??e))),l=D(o),d=function(t=process.cwd()){const r="string"==typeof t?e.existsSync(`${t}/package.json`)?JSON.parse(e.readFileSync(`${t}/package.json`,"utf-8")):{}:t,{dependencies:s={},peerDependencies:o={},optionalDependencies:n={}}=r;return Object.keys(s).concat(Object.keys(o)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(s),[f,m]=function({entrypoints:e,pkgIsModule:s,entries:o,config:n,dir:i,noFilter:c,withSource:p,withSuffix:u}){const{build:l={}}=n??{},{crossModuleConvertor:d=!0}=l,f=`./${m=((...e)=>t.resolve(i??process.cwd(),...e))(("object"==typeof l?.output?.dir?l.output.dir.js:l?.output?.dir)??"dist"),t.relative(i??process.cwd(),m)}`;var m;const[,h]=r.resolveEntrypoints(e);o&&Object.entries(h).forEach((([e])=>{o.some((t=>a.isMatch(e,t,{matchBase:!0})))||delete h[e]}));const y=c?h:r.filterLeafs(h,{skipValue:[/(^|\/)\.jk-noentry/,...r.DEFAULT_SKIP_VALUES]}),w=d?{import:e=>!s&&0===g(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!s||0!==g(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{};return[y,r.entrypoints2Exports(y,{outdir:f,withSource:p,withSuffix:u,withConditional:{...w}})]}({entrypoints:i,pkgIsModule:c,entries:u,config:F}),h=new Map;r.getAllLeafs(f,(({keys:e,value:t})=>{if("string"==typeof t){const r=h.get(t)??[];h.set(t,r),r.push(e)}return!1}));const y=[];return h.forEach(((e,t)=>e.forEach((e=>{const[s,...o]=e,n=l+("."===s?"":D(s)),i=((e,t)=>t.reduce(((e,t)=>{if("string"==typeof e)throw new Error("key not found in exports");if(!(t in e))throw new Error(`key ${t} not found in exports`);return e[t]}),e))(m,e),p={path:s,name:n,input:t,external:d,pkgIsModule:c};switch(typeof i){case"string":y.push(...K({...p,output:i,conditionals:o},R));break;case"object":r.getAllLeafs(i,(({keys:e,value:t})=>{const r=[...new Set([...o,...e])];return"string"==typeof t&&y.push(...K({...p,output:t,conditionals:r},R)),!1}))}})))),p.sendMessage({type:"init",data:{leafMap:h,targetsLength:y.length}}),y.map((e=>({...M,...e,plugins:[...C,e.plugins]})))};
@@ -1 +1 @@
1
- "use strict";var e=require("node:fs"),t=require("node:path"),r=require("@jiek/pkger/entrypoints"),s=require("@jiek/rollup-plugin-dts"),o=require("@jiek/utils/getWorkspaceDir"),n=require("@rollup/plugin-json"),i=require("@rollup/plugin-node-resolve"),c=require("@rollup/plugin-terser"),p=require("execa"),u=require("jsonc-parser"),a=require("micromatch"),l=require("rollup-plugin-esbuild"),d=require("typescript"),f=require("commander"),m=require("js-yaml");require("@pnpm/filter-workspace-packages");const g=(e,t)=>new Set([...e].filter((e=>t.has(e))));let y;function h(){if(y)return y;const e=f.program.getOptionValue("root");return y=e?t.isAbsolute(e)?e:t.resolve(process.cwd(),e):void 0,y}let v,w="";try{require.resolve("@pnpm/filter-workspace-packages"),w="pnpm"}catch{}""!==w&&f.program.option("-f, --filter <filter>","filter packages");let j,k=!1;function $(e){try{return require.resolve(e),!0}catch(e){return!1}}const E=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of E)if($(e)){j=e;break}let b="jiek.config";var q=(e={})=>{const{onEvent:t}=e;return{name:"progress",buildStart:()=>t?.("start","Start building..."),buildEnd:()=>t?.("end","Build completed!"),resolveId:{order:"post",handler:e=>t?.("resolve",`Resolving ${e}...`)},load:{order:"post",handler:e=>t?.("load",`Loading ${e}...`)},transform:{order:"post",handler:(e,r)=>t?.("transform",`Transforming ${r}...`)}}},x=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const{JIEK_ROOT:S,JIEK_ENTRIES:O}=process.env,I=S??o.getWorkspaceDir(),M={},C=[n()],F=function(r){const{wd:s}=function(){if(v)return{wd:v,notWorkspace:k};const e=h();if(void 0!==e){const t=o.isWorkspaceDir(e,w);return k=!t,v=e,{wd:v,notWorkspace:k}}try{v=o.getWorkspaceDir(w)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;v=e,k=!0}return{wd:v,notWorkspace:k}}();let n=f.program.getOptionValue("configPath");if(n){if(!e.existsSync(n))throw new Error(`config file not found: ${n}`);t.isAbsolute(n)||(n=t.resolve(s,n))}else n=function(r,s){const o=!!j;function n(o){const n=[t.resolve(process.cwd(),`${b}.${o}`),t.resolve(process.cwd(),`.${b}.${o}`),t.resolve(r,`${b}.${o}`),t.resolve(r,`.${b}.${o}`)];s&&n.unshift(t.resolve(s,`${b}.${o}`),t.resolve(s,`.${b}.${o}`));for(const t of n)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return b=n("js")??b,b=n("json")??b,b=n("yaml")??b,o&&(b=n("ts")??b),t.resolve(r,b)}(s,r);const i=t.extname(n);let c;switch(i){case".js":c=require(n);break;case".json":return require(n);case".yaml":return m.load(e.readFileSync(n,"utf-8"));case".ts":if(j){require(j),c=require(n);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":c={};break;default:throw new Error(`unsupported config file type: ${i}`)}if(!c)throw new Error("config file is empty");return c.default??c}()??{},{build:R={}}=F,T=`./${t.relative(process.cwd(),t.resolve(("object"==typeof R?.output?.dir?R.output.dir.js:R?.output?.dir)??"dist"))}`,A=/\.(css|s[ac]ss|less|styl)$/,_=e=>t.resolve(I,e),D=e=>e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())).replace(/(?:^|-)(\w)/g,((e,t)=>t.toUpperCase())),L=(e,t=R?.output?.minify)=>!1===t?[e]:"only-minify"===t?[{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],c()]}]:[e,{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],c()]}],W=r=>{r=t.resolve(r);const s=t.dirname(r),{extends:o,...n}=(i=r,e.existsSync(i)&&e.statSync(i).isFile()?u.parse(e.readFileSync(i,"utf-8"),[],{allowTrailingComma:!0,allowEmptyContent:!0}):{});var i;const c=(p=o?Array.isArray(o)?o:[o]:[],p?.map((e=>t.resolve(s,e)))??[]);var p;return 0===c.length?n:c.map(W).reduce(((e,{compilerOptions:t={},references:r,...s})=>({...e,...s,compilerOptions:{...e.compilerOptions,...t}})),n)},J=(e,r)=>{e=t.resolve(e),r=t.resolve(r);const s=t.dirname(e),o=W(e),[n,i,c,p]=[o.references?.map((({path:e})=>e)),o.files,o.include,o.exclude].map((e=>e?.map((e=>t.resolve(s,e)))??[]));if(p.length>0&&p.some((e=>a.isMatch(r,e))))return;if(0===o.files?.length&&0===o.include?.length)return;let u=!1;if(u||(u=i.length>0&&i.includes(r)),u||(u=c.length>0&&c.some((e=>a.isMatch(r,e)))),u)return o.compilerOptions??{};if(!(o.files&&o.files.length>0||o.include&&o.include.length>0)){n.reverse();for(const e of n){const t=J(e,r);if(t)return t}return o.compilerOptions}},K=({path:r,name:o,input:n,output:c,external:u,pkgIsModule:a,conditionals:f},m={})=>{const g=f.includes("import"),y=f.includes("require"),h=f.includes("browser");let v;[_("tsconfig.json"),_("tsconfig.dts.json")].forEach((t=>{e.existsSync(t)&&e.statSync(t).isFile()&&(v=t)}));let w={};if(v){const e=J(v,t.resolve(n)),{options:r,errors:s}=d.convertCompilerOptionsFromJson(e,t.dirname(v));if(s.length>0)throw new Error(s.map((e=>e.messageText)).join("\n"));w=r}const j=[...f,...w.customConditions??[]],k={type:"progress",data:{name:o,path:r,exportConditions:j,input:n}},$=m?.output?.dir;return[{input:n,external:u,output:[...L({file:c,name:o,sourcemap:"object"==typeof m?.output?.sourcemap?m.output.sourcemap.js:m?.output?.sourcemap,format:g?"esm":y?"cjs":h?"umd":a?"esm":"cjs",strict:"object"==typeof m?.output?.strict?m.output.strict.js:m?.output?.strict})],plugins:[i.nodeResolve({exportConditions:j}),import("rollup-plugin-postcss").then((({default:e})=>e({extract:t.resolve(c.replace(/\.[cm]?js$/,".css")),minimize:!0}))).catch((()=>{})),l(),q({onEvent:(e,t)=>p.sendMessage({...k,data:{...k.data,event:e,message:t,tags:["js"]}})})]},{input:n,external:u,output:[{dir:t.resolve(("object"==typeof $?$.dts:$)??"dist"),sourcemap:"object"==typeof m?.output?.sourcemap?m.output.sourcemap.dts:m?.output?.sourcemap,entryFileNames:()=>c.replace(`${T}/`,"").replace(/(\.[cm]?)js$/,".d$1ts"),strict:"object"==typeof m?.output?.strict?m.output.strict.dts:m?.output?.strict}],plugins:[i.nodeResolve({exportConditions:j}),x({patterns:[A]}),s.dts({respectExternal:!0,compilerOptions:w}),q({onEvent:(e,t)=>p.sendMessage({...k,data:{...k.data,event:e,message:t,tags:["dts"]}})})]}]};exports.template=function(s){const{name:o,type:n,exports:i}=s,c="module"===n;if(!o)throw new Error("package.json name is required");if(!i)throw new Error("package.json exports is required");const u=O?.split(",").map((e=>e.trim())).map((e=>({index:"."}[e]??e))),l=D(o),d=function(t=process.cwd()){const r="string"==typeof t?e.existsSync(`${t}/package.json`)?JSON.parse(e.readFileSync(`${t}/package.json`,"utf-8")):{}:t,{dependencies:s={},peerDependencies:o={},optionalDependencies:n={}}=r;return Object.keys(s).concat(Object.keys(o)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(s),[f,m]=function({entrypoints:e,pkgIsModule:s,entries:o,config:n,dir:i,noFilter:c}){const{build:p={}}=n??{},{crossModuleConvertor:u=!0}=p,l=`./${d=((...e)=>t.resolve(i??process.cwd(),...e))(("object"==typeof p?.output?.dir?p.output.dir.js:p?.output?.dir)??"dist"),t.relative(i??process.cwd(),d)}`;var d;const[,f]=r.resolveEntrypoints(e);o&&Object.entries(f).forEach((([e])=>{o.some((t=>a.isMatch(e,t,{matchBase:!0})))||delete f[e]}));const m=c?f:r.filterLeafs(f,{skipValue:[/(^|\/)\.jk-noentry/,...r.DEFAULT_SKIP_VALUES]}),y=u?{import:e=>!s&&0===g(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!s||0!==g(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{};return[m,r.entrypoints2Exports(m,{outdir:l,withConditional:{...y}})]}({entrypoints:i,pkgIsModule:c,entries:u,config:F}),y=new Map;r.getAllLeafs(f,(({keys:e,value:t})=>{if("string"==typeof t){const r=y.get(t)??[];y.set(t,r),r.push(e)}return!1}));const h=[];return y.forEach(((e,t)=>e.forEach((e=>{const[s,...o]=e,n=l+("."===s?"":D(s)),i=((e,t)=>t.reduce(((e,t)=>{if("string"==typeof e)throw new Error("key not found in exports");if(!(t in e))throw new Error(`key ${t} not found in exports`);return e[t]}),e))(m,e),p={path:s,name:n,input:t,external:d,pkgIsModule:c};switch(typeof i){case"string":h.push(...K({...p,output:i,conditionals:o},R));break;case"object":r.getAllLeafs(i,(({keys:e,value:t})=>{const r=[...new Set([...o,...e])];return"string"==typeof t&&h.push(...K({...p,output:t,conditionals:r},R)),!1}))}})))),p.sendMessage({type:"init",data:{leafMap:y,targetsLength:h.length}}),h.map((e=>({...M,...e,plugins:[...C,e.plugins]})))};
1
+ import e from"node:fs";import t,{resolve as r,relative as o,dirname as s}from"node:path";import{resolveEntrypoints as n,filterLeafs as i,DEFAULT_SKIP_VALUES as p,entrypoints2Exports as c,getAllLeafs as u}from"@jiek/pkger/entrypoints";import{dts as l}from"@jiek/rollup-plugin-dts";import{isWorkspaceDir as a,getWorkspaceDir as f}from"@jiek/utils/getWorkspaceDir";import d from"@rollup/plugin-json";import{nodeResolve as m}from"@rollup/plugin-node-resolve";import g from"@rollup/plugin-terser";import{sendMessage as w}from"execa";import{parse as y}from"jsonc-parser";import{isMatch as h}from"micromatch";import j from"rollup-plugin-esbuild";import k from"typescript";import{program as $}from"commander";import{load as v}from"js-yaml";import"@pnpm/filter-workspace-packages";const E=(e,t)=>new Set([...e].filter((e=>t.has(e))));let S;function b(){if(S)return S;const e=$.getOptionValue("root");return S=e?t.isAbsolute(e)?e:t.resolve(process.cwd(),e):void 0,S}let x,O="";try{require.resolve("@pnpm/filter-workspace-packages"),O="pnpm"}catch{}""!==O&&$.option("-f, --filter <filter>","filter packages");let I,q=!1;function C(e){try{return require.resolve(e),!0}catch(e){return!1}}const F=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of F)if(C(e)){I=e;break}let T="jiek.config";var R=(e={})=>{const{onEvent:t}=e;return{name:"progress",buildStart:()=>t?.("start","Start building..."),buildEnd:()=>t?.("end","Build completed!"),resolveId:{order:"post",handler:e=>t?.("resolve",`Resolving ${e}...`)},load:{order:"post",handler:e=>t?.("load",`Loading ${e}...`)},transform:{order:"post",handler:(e,r)=>t?.("transform",`Transforming ${r}...`)}}},M=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const{JIEK_ROOT:J,JIEK_ENTRIES:_}=process.env,A=J??f(),K={},W=[d()],z=function(r){const{wd:o}=function(){if(x)return{wd:x,notWorkspace:q};const e=b();if(void 0!==e){const t=a(e,O);return q=!t,x=e,{wd:x,notWorkspace:q}}try{x=f(O)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;x=e,q=!0}return{wd:x,notWorkspace:q}}();let s=$.getOptionValue("configPath");if(s){if(!e.existsSync(s))throw new Error(`config file not found: ${s}`);t.isAbsolute(s)||(s=t.resolve(o,s))}else s=function(r,o){const s=!!I;function n(s){const n=[t.resolve(process.cwd(),`${T}.${s}`),t.resolve(process.cwd(),`.${T}.${s}`),t.resolve(r,`${T}.${s}`),t.resolve(r,`.${T}.${s}`)];o&&n.unshift(t.resolve(o,`${T}.${s}`),t.resolve(o,`.${T}.${s}`));for(const t of n)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return T=n("js")??T,T=n("json")??T,T=n("yaml")??T,s&&(T=n("ts")??T),t.resolve(r,T)}(o,r);const n=t.extname(s);let i;switch(n){case".js":i=require(s);break;case".json":return require(s);case".yaml":return v(e.readFileSync(s,"utf-8"));case".ts":if(I){require(I),i=require(s);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":i={};break;default:throw new Error(`unsupported config file type: ${n}`)}if(!i)throw new Error("config file is empty");return i.default??i}()??{},{build:B={}}=z,D=`./${o(process.cwd(),r(("object"==typeof B?.output?.dir?B.output.dir.js:B?.output?.dir)??"dist"))}`,N=/\.(css|s[ac]ss|less|styl)$/,V=e=>r(A,e),G=e=>e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())).replace(/(?:^|-)(\w)/g,((e,t)=>t.toUpperCase())),L=(e,t=B?.output?.minify)=>!1===t?[e]:"only-minify"===t?[{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],g()]}]:[e,{...e,file:e.file?.replace(/(\.[cm]?js)$/,".min$1"),plugins:[...e.plugins??[],g()]}],U=t=>{t=r(t);const o=s(t),{extends:n,...i}=(p=t,e.existsSync(p)&&e.statSync(p).isFile()?y(e.readFileSync(p,"utf-8"),[],{allowTrailingComma:!0,allowEmptyContent:!0}):{});var p;const c=(u=n?Array.isArray(n)?n:[n]:[],u?.map((e=>r(o,e)))??[]);var u;return 0===c.length?i:c.map(U).reduce(((e,{compilerOptions:t={},references:r,...o})=>({...e,...o,compilerOptions:{...e.compilerOptions,...t}})),i)},P=(e,t)=>{e=r(e),t=r(t);const o=s(e),n=U(e),[i,p,c,u]=[n.references?.map((({path:e})=>e)),n.files,n.include,n.exclude].map((e=>e?.map((e=>r(o,e)))??[]));if(u.length>0&&u.some((e=>h(t,e))))return;if(0===n.files?.length&&0===n.include?.length)return;let l=!1;if(l||(l=p.length>0&&p.includes(t)),l||(l=c.length>0&&c.some((e=>h(t,e)))),l)return n.compilerOptions??{};if(!(n.files&&n.files.length>0||n.include&&n.include.length>0)){i.reverse();for(const e of i){const r=P(e,t);if(r)return r}return n.compilerOptions}},H=({path:t,name:o,input:n,output:i,external:p,pkgIsModule:c,conditionals:u},a={})=>{const f=u.includes("import"),d=u.includes("require"),g=u.includes("browser");let y;[V("tsconfig.json"),V("tsconfig.dts.json")].forEach((t=>{e.existsSync(t)&&e.statSync(t).isFile()&&(y=t)}));let h={};if(y){const e=P(y,r(n)),{options:t,errors:o}=k.convertCompilerOptionsFromJson(e,s(y));if(o.length>0)throw new Error(o.map((e=>e.messageText)).join("\n"));h=t}const $=[...u,...h.customConditions??[]],v={type:"progress",data:{name:o,path:t,exportConditions:$,input:n}},E=a?.output?.dir;return[{input:n,external:p,output:[...L({file:i,name:o,sourcemap:"object"==typeof a?.output?.sourcemap?a.output.sourcemap.js:a?.output?.sourcemap,format:f?"esm":d?"cjs":g?"umd":c?"esm":"cjs",strict:"object"==typeof a?.output?.strict?a.output.strict.js:a?.output?.strict})],plugins:[m({exportConditions:$}),import("rollup-plugin-postcss").then((({default:e})=>e({extract:r(i.replace(/\.[cm]?js$/,".css")),minimize:!0}))).catch((()=>{})),j(),R({onEvent:(e,t)=>w({...v,data:{...v.data,event:e,message:t,tags:["js"]}})})]},{input:n,external:p,output:[{dir:r(("object"==typeof E?E.dts:E)??"dist"),sourcemap:"object"==typeof a?.output?.sourcemap?a.output.sourcemap.dts:a?.output?.sourcemap,entryFileNames:()=>i.replace(`${D}/`,"").replace(/(\.[cm]?)js$/,".d$1ts"),strict:"object"==typeof a?.output?.strict?a.output.strict.dts:a?.output?.strict}],plugins:[m({exportConditions:$}),M({patterns:[N]}),l({respectExternal:!0,compilerOptions:h}),R({onEvent:(e,t)=>w({...v,data:{...v.data,event:e,message:t,tags:["dts"]}})})]}]};function Q(t){const{name:s,type:l,exports:a}=t,f="module"===l;if(!s)throw new Error("package.json name is required");if(!a)throw new Error("package.json exports is required");const d=_?.split(",").map((e=>e.trim())).map((e=>({index:"."}[e]??e))),m=G(s),g=function(t=process.cwd()){const r="string"==typeof t?e.existsSync(`${t}/package.json`)?JSON.parse(e.readFileSync(`${t}/package.json`,"utf-8")):{}:t,{dependencies:o={},peerDependencies:s={},optionalDependencies:n={}}=r;return Object.keys(o).concat(Object.keys(s)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(t),[y,j]=function({entrypoints:e,pkgIsModule:t,entries:s,config:u,dir:l,noFilter:a,withSource:f,withSuffix:d}){const{build:m={}}=u??{},{crossModuleConvertor:g=!0}=m,w=`./${(e=>o(l??process.cwd(),e))(((...e)=>r(l??process.cwd(),...e))(("object"==typeof m?.output?.dir?m.output.dir.js:m?.output?.dir)??"dist"))}`,[,y]=n(e);s&&Object.entries(y).forEach((([e])=>{s.some((t=>h(e,t,{matchBase:!0})))||delete y[e]}));const j=a?y:i(y,{skipValue:[/(^|\/)\.jk-noentry/,...p]});return[j,c(j,{outdir:w,withSource:f,withSuffix:d,withConditional:{...g?{import:e=>!t&&0===E(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!t||0!==E(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{}}})]}({entrypoints:a,pkgIsModule:f,entries:d,config:z}),k=new Map;u(y,(({keys:e,value:t})=>{if("string"==typeof t){const r=k.get(t)??[];k.set(t,r),r.push(e)}return!1}));const $=[];return k.forEach(((e,t)=>e.forEach((e=>{const[r,...o]=e,s=m+("."===r?"":G(r)),n=((e,t)=>t.reduce(((e,t)=>{if("string"==typeof e)throw new Error("key not found in exports");if(!(t in e))throw new Error(`key ${t} not found in exports`);return e[t]}),e))(j,e),i={path:r,name:s,input:t,external:g,pkgIsModule:f};switch(typeof n){case"string":$.push(...H({...i,output:n,conditionals:o},B));break;case"object":u(n,(({keys:e,value:t})=>{const r=[...new Set([...o,...e])];return"string"==typeof t&&$.push(...H({...i,output:t,conditionals:r},B)),!1}))}})))),w({type:"init",data:{leafMap:k,targetsLength:$.length}}),$.map((e=>({...K,...e,plugins:[...W,e.plugins]})))}export{Q as template};
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
- "version": "0.4.7-alpha.3",
3
+ "type": "module",
4
+ "version": "0.4.7-alpha.4",
4
5
  "description": "YiJie's personal kits.",
5
6
  "bin": {
6
7
  "jiek": "bin/jiek.js",
@@ -26,27 +27,27 @@
26
27
  "./package.json": "./package.json",
27
28
  ".": {
28
29
  "source": "./src/index.ts",
29
- "import": "./dist/index.mjs",
30
+ "require": "./dist/index.cjs",
30
31
  "default": "./dist/index.js"
31
32
  },
32
33
  "./cli": {
33
34
  "source": "./src/cli.ts",
34
- "import": "./dist/cli.mjs",
35
+ "require": "./dist/cli.cjs",
35
36
  "default": "./dist/cli.js"
36
37
  },
37
38
  "./rollup": {
38
39
  "source": "./src/rollup/index.ts",
39
- "import": "./dist/rollup/index.mjs",
40
+ "require": "./dist/rollup/index.cjs",
40
41
  "default": "./dist/rollup/index.js"
41
42
  },
42
43
  "./cli.js": {
43
44
  "source": "./src/cli.ts",
44
- "import": "./dist/cli.mjs",
45
+ "require": "./dist/cli.cjs",
45
46
  "default": "./dist/cli.js"
46
47
  },
47
48
  "./rollup.js": {
48
49
  "source": "./src/rollup/index.ts",
49
- "import": "./dist/rollup/index.mjs",
50
+ "require": "./dist/rollup/index.cjs",
50
51
  "default": "./dist/rollup/index.js"
51
52
  }
52
53
  },
@@ -71,8 +72,8 @@
71
72
  "rollup-plugin-copy": "^3.5.0",
72
73
  "rollup-plugin-esbuild": "^6.1.0",
73
74
  "typescript": "^5.0.0",
74
- "@jiek/pkger": "^0.1.11",
75
- "@jiek/utils": "^0.2.0"
75
+ "@jiek/utils": "^0.2.0",
76
+ "@jiek/pkger": "^0.2.0"
76
77
  },
77
78
  "optionalDependencies": {
78
79
  "@pnpm/filter-workspace-packages": "^7.2.13",
@@ -93,6 +94,6 @@
93
94
  "postcss": "^8.4.47",
94
95
  "rollup-plugin-postcss": "^4.0.2"
95
96
  },
96
- "main": "./dist/index.js",
97
- "module": "./dist/index.mjs"
97
+ "main": "./dist/index.cjs",
98
+ "module": "./dist/index.js"
98
99
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.mts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}