jiek 2.2.1 → 2.2.2

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.
@@ -5,9 +5,9 @@ import { program } from 'commander';
5
5
  import { load } from 'js-yaml';
6
6
  import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
7
7
  import process$1 from 'node:process';
8
- import { confirm } from '@inquirer/prompts';
9
8
  import { MultiBar, Presets } from 'cli-progress';
10
9
  import { execaCommand } from 'execa';
10
+ import { confirm } from '@inquirer/prompts';
11
11
  import Koa from 'koa';
12
12
 
13
13
  let root;
@@ -110,7 +110,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
110
110
 
111
111
  var name = "jiek";
112
112
  var type = "module";
113
- var version = "2.2.0";
113
+ var version = "2.2.1";
114
114
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
115
115
  var author = "YiJie <yijie4188@gmail.com>";
116
116
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
@@ -141,7 +141,11 @@ var exports = {
141
141
  "./rollup": "./src/rollup/index.ts"
142
142
  };
143
143
  var imports = {
144
- "#~/*": "./src/*"
144
+ "#~/*": [
145
+ "./src/*",
146
+ "./src/*/index.ts",
147
+ "./src/*/index.tsx"
148
+ ]
145
149
  };
146
150
  var bin = {
147
151
  jiek: "bin/jiek.js",
@@ -172,7 +176,7 @@ var peerDependencies = {
172
176
  "rollup-plugin-postcss": "^4.0.2",
173
177
  "rollup-plugin-swc3": "^0.12.1",
174
178
  typescript: "^4.0.0||^5.0.0",
175
- "vite-bundle-analyzer": "^0.15.2"
179
+ "vite-bundle-analyzer": "0.16.0-beta.1"
176
180
  };
177
181
  var dependencies = {
178
182
  "@inquirer/prompts": "^7.1.0",
@@ -203,6 +207,7 @@ var devDependencies = {
203
207
  "@types/js-yaml": "^4.0.9",
204
208
  "@types/koa": "^2.15.0",
205
209
  "@types/micromatch": "^4.0.6",
210
+ "@types/react": "^18.3.14",
206
211
  "esbuild-register": "^3.5.0",
207
212
  micromatch: "^4.0.5",
208
213
  "node-sass": "^9.0.0",
@@ -210,7 +215,7 @@ var devDependencies = {
210
215
  "rollup-plugin-esbuild": "^6.1.0",
211
216
  "rollup-plugin-postcss": "^4.0.2",
212
217
  "rollup-plugin-swc3": "^0.12.1",
213
- "vite-bundle-analyzer": "^0.15.2"
218
+ "vite-bundle-analyzer": "0.16.0-beta.1"
214
219
  };
215
220
  var pkg = {
216
221
  name: name,
@@ -256,6 +261,212 @@ if (type$1 !== "" && IS_WORKSPACE) {
256
261
  program.option("-f, --filter <filter>", filterDescription);
257
262
  }
258
263
 
264
+ function Main() {
265
+ const { useState, useMemo, useEffect, useCallback } = React;
266
+ const [path, setPath] = useState(() => location.pathname.replace(/^\/ana\/?/, ""));
267
+ const [pkgName, entry] = useMemo(() => {
268
+ const pkgName2 = /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(path)?.[1];
269
+ return [
270
+ pkgName2,
271
+ pkgName2 != null ? path.replace(`${pkgName2}/`, "") : void 0
272
+ ];
273
+ }, [path]);
274
+ const push = useCallback((newPath) => {
275
+ setPath(newPath);
276
+ document.title = `${document.title.replace(/ - \/.*/, "")} - /${newPath}`;
277
+ history.pushState(null, "", `/ana/${newPath}`);
278
+ }, []);
279
+ const filterModules = useCallback((startWith) => {
280
+ const modules = analyzeModule.filter((m) => m.filename.startsWith(startWith));
281
+ dispatchEvent(new CustomEvent("send:filter", { detail: { analyzeModule: modules } }));
282
+ }, []);
283
+ useEffect(() => {
284
+ if (path !== "") {
285
+ document.title = `${document.title.replace(/ - \/.*/, "")} - /${path}`;
286
+ } else {
287
+ document.title = document.title.replace(/ - \/.*/, "");
288
+ }
289
+ filterModules(path);
290
+ }, [path, filterModules]);
291
+ useEffect(() => {
292
+ const offGraphClick = listen("graph:click", ({ detail }) => {
293
+ if (!detail)
294
+ return;
295
+ let root = detail.node;
296
+ while (root.parent) {
297
+ root = root.parent;
298
+ }
299
+ if (root.filename === path)
300
+ return;
301
+ push(root.filename);
302
+ });
303
+ return () => {
304
+ offGraphClick();
305
+ };
306
+ }, [push]);
307
+ function listen(type, listener) {
308
+ window.addEventListener(type, listener);
309
+ return () => {
310
+ window.removeEventListener(type, listener);
311
+ };
312
+ }
313
+ return /* @__PURE__ */ React.createElement(
314
+ "div",
315
+ {
316
+ style: {
317
+ padding: "12px 55px"
318
+ }
319
+ },
320
+ "/",
321
+ /* @__PURE__ */ React.createElement(
322
+ "select",
323
+ {
324
+ style: {
325
+ appearance: "none",
326
+ border: "none",
327
+ background: "none"
328
+ },
329
+ value: pkgName,
330
+ onChange: (e) => push(e.target.value)
331
+ },
332
+ /* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
333
+ analyzeModule.map((m) => /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(m.filename)?.[1]).filter((v, i, a) => a.indexOf(v) === i).map((v) => /* @__PURE__ */ React.createElement("option", { key: v, value: v }, v))
334
+ ),
335
+ pkgName != null && /* @__PURE__ */ React.createElement(React.Fragment, null, "/", /* @__PURE__ */ React.createElement(
336
+ "select",
337
+ {
338
+ style: {
339
+ appearance: "none",
340
+ border: "none",
341
+ background: "none"
342
+ },
343
+ value: entry,
344
+ onChange: (e) => push(`${pkgName}/${e.target.value}`)
345
+ },
346
+ /* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
347
+ analyzeModule.filter((m) => m.filename.startsWith(`${pkgName}/`)).map((m) => m.filename.replace(`${pkgName}/`, "")).filter((v, i, a) => a.indexOf(v) === i).map((v) => /* @__PURE__ */ React.createElement("option", { key: v, value: v }, v))
348
+ ))
349
+ );
350
+ }
351
+
352
+ function render() {
353
+ CUSTOM_SIDE_BAR = true;
354
+ window.addEventListener("client:ready", () => setTimeout(() => {
355
+ window.dispatchEvent(
356
+ new CustomEvent("send:ui", {
357
+ detail: { type: "Main", Component: __REPLACE_INJECT__ }
358
+ })
359
+ );
360
+ }, 0));
361
+ }
362
+ const CLIENT_CUSTOM_RENDER_SCRIPT = [
363
+ Main.toString(),
364
+ render.toString().replace("__REPLACE_INJECT__", Main.name),
365
+ `(${render.name})()`
366
+ ].join("\n");
367
+
368
+ function parseBoolean(v) {
369
+ if (v === void 0)
370
+ return true;
371
+ return Boolean(v);
372
+ }
373
+
374
+ async function checkDependency(dependency) {
375
+ try {
376
+ require.resolve(dependency);
377
+ } catch {
378
+ console.error(`The package '${dependency}' is not installed, please install it first.`);
379
+ const { notWorkspace } = getWD();
380
+ const command = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
381
+ if (await confirm({ message: "Do you want to install it now?" })) {
382
+ await execaCommand(command);
383
+ } else {
384
+ console.warn(`You can run the command '${command}' to install it manually.`);
385
+ process$1.exit(1);
386
+ }
387
+ }
388
+ }
389
+
390
+ const registerAnalyzerCommandOptions = (command) => command.option("--ana", "Enable the bundle analyzer.", parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option(
391
+ "--ana.mode <MODE>",
392
+ 'The mode of the bundle analyzer, support "static", "json" and "server".',
393
+ "server"
394
+ ).option("--ana.open", "Open the bundle analyzer in the browser.", parseBoolean).option(
395
+ "--ana.size <SIZE>",
396
+ 'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
397
+ "parsed"
398
+ );
399
+ const useAnalyzer = async (options, server) => {
400
+ const modules = [];
401
+ let bundleAnalyzerModule;
402
+ const analyzer = options.ana ? {
403
+ dir: options["ana.dir"],
404
+ mode: options["ana.mode"],
405
+ open: options["ana.open"],
406
+ size: options["ana.size"]
407
+ } : void 0;
408
+ if (options.ana && ![
409
+ "stat",
410
+ "parsed",
411
+ "gzip"
412
+ ].includes(analyzer?.size ?? "")) {
413
+ throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
414
+ }
415
+ if (analyzer) {
416
+ await checkDependency("vite-bundle-analyzer");
417
+ bundleAnalyzerModule = await import('vite-bundle-analyzer');
418
+ }
419
+ const refreshAnalyzer = async (cwd, applyModules) => {
420
+ if (!(analyzer && server && bundleAnalyzerModule))
421
+ return;
422
+ if (analyzer.mode === "json") {
423
+ const anaDir = path.resolve(cwd, analyzer.dir);
424
+ if (!existsSync(anaDir)) {
425
+ mkdirSync(anaDir, { recursive: true });
426
+ }
427
+ const gitIgnorePath = path.resolve(anaDir, ".gitignore");
428
+ if (!existsSync(gitIgnorePath)) {
429
+ writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
430
+ }
431
+ const npmIgnorePath = path.resolve(anaDir, ".npmignore");
432
+ if (!existsSync(npmIgnorePath)) {
433
+ writeFileSync(npmIgnorePath, "*\n");
434
+ }
435
+ if (!statSync(anaDir).isDirectory()) {
436
+ throw new Error(`The directory '${anaDir}' is not a directory.`);
437
+ }
438
+ }
439
+ const { renderView, injectHTMLTag } = bundleAnalyzerModule;
440
+ applyModules.forEach((m) => {
441
+ const index = modules.findIndex(({ filename }) => filename === m.filename);
442
+ if (index === -1) {
443
+ modules.push(m);
444
+ } else {
445
+ modules[index] = m;
446
+ }
447
+ });
448
+ let html = await renderView(modules, {
449
+ title: `Jiek Analyzer`,
450
+ mode: analyzer.size
451
+ });
452
+ html = injectHTMLTag({
453
+ html,
454
+ injectTo: "body",
455
+ descriptors: [
456
+ { kind: "script", text: CLIENT_CUSTOM_RENDER_SCRIPT }
457
+ ]
458
+ });
459
+ void server.renderTo("/ana", html);
460
+ };
461
+ return {
462
+ modules,
463
+ refreshAnalyzer,
464
+ ANALYZER_ENV: {
465
+ JIEK_ANALYZER: analyzer ? JSON.stringify(analyzer) : void 0
466
+ }
467
+ };
468
+ };
469
+
259
470
  const BUILDER_TYPES = ["esbuild", "swc"];
260
471
  const BUILDER_TYPE_PACKAGE_NAME_MAP = {
261
472
  esbuild: "rollup-plugin-esbuild",
@@ -267,7 +478,11 @@ const createServer = (port, host) => {
267
478
  app.listen(port, host);
268
479
  const streams = /* @__PURE__ */ new Map();
269
480
  app.use(async (ctx) => {
270
- const stream = streams.get(ctx.path);
481
+ let stream = streams.get(ctx.path);
482
+ if (stream == null) {
483
+ const maybeKey = streams.keys().find((p) => ctx.path.startsWith(p));
484
+ stream = maybeKey != null ? streams.get(maybeKey) : void 0;
485
+ }
271
486
  if (stream != null) {
272
487
  ctx.body = stream;
273
488
  }
@@ -282,10 +497,10 @@ const createServer = (port, host) => {
282
497
  };
283
498
  };
284
499
 
285
- const require$2 = createRequire(import.meta.url);
500
+ const require$3 = createRequire(import.meta.url);
286
501
  function packageIsExist(name) {
287
502
  try {
288
- require$2.resolve(name);
503
+ require$3.resolve(name);
289
504
  return true;
290
505
  } catch (e) {
291
506
  return false;
@@ -305,7 +520,7 @@ for (const register of registers) {
305
520
  }
306
521
  }
307
522
 
308
- const require$1 = createRequire(import.meta.url);
523
+ const require$2 = createRequire(import.meta.url);
309
524
  let configName = "jiek.config";
310
525
  function getConfigPath(root, dir) {
311
526
  const isSupportTsLoader = !!tsRegisterName;
@@ -359,16 +574,16 @@ function loadConfig(dirOrOptions) {
359
574
  let module;
360
575
  switch (ext) {
361
576
  case ".js":
362
- module = require$1(configPath);
577
+ module = require$2(configPath);
363
578
  break;
364
579
  case ".json":
365
- return require$1(configPath);
580
+ return require$2(configPath);
366
581
  case ".yaml":
367
582
  return load(fs.readFileSync(configPath, "utf-8"));
368
583
  case ".ts":
369
584
  if (tsRegisterName) {
370
- require$1(tsRegisterName);
371
- module = require$1(configPath);
585
+ require$2(tsRegisterName);
586
+ module = require$2(configPath);
372
587
  break;
373
588
  }
374
589
  throw new Error(
@@ -388,32 +603,17 @@ function loadConfig(dirOrOptions) {
388
603
  const FILE_TEMPLATE = (manifest) => `
389
604
  module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
390
605
  `.trimStart();
391
- const require = createRequire(import.meta.url);
606
+ const require$1 = createRequire(import.meta.url);
392
607
  const isDefault = process$1.env.JIEK_IS_ONLY_BUILD === "true";
393
608
  const description = `
394
609
  Build the package according to the 'exports' field from the package.json.
395
610
  If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
396
611
  ${isDefault ? "This command is the default command." : ""}
397
612
  `.trim();
398
- async function checkDependency(dependency) {
399
- try {
400
- require.resolve(dependency);
401
- } catch {
402
- console.error(`The package '${dependency}' is not installed, please install it first.`);
403
- const { notWorkspace } = getWD();
404
- const command2 = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
405
- if (await confirm({ message: "Do you want to install it now?" })) {
406
- await execaCommand(command2);
407
- } else {
408
- console.warn(`You can run the command '${command2}' to install it manually.`);
409
- process$1.exit(1);
410
- }
411
- }
412
- }
413
613
  let DEFAULT_BUILDER_TYPE;
414
614
  Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
415
615
  try {
416
- require.resolve(packageName);
616
+ require$1.resolve(packageName);
417
617
  DEFAULT_BUILDER_TYPE = type;
418
618
  } catch {
419
619
  }
@@ -421,11 +621,6 @@ Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
421
621
  if (!DEFAULT_BUILDER_TYPE) {
422
622
  DEFAULT_BUILDER_TYPE = "esbuild";
423
623
  }
424
- function parseBoolean(v) {
425
- if (v === void 0)
426
- return true;
427
- return Boolean(v);
428
- }
429
624
  const buildFilterDescription = `
430
625
  ${filterDescription}
431
626
  If you pass the --filter option, it will merge into the filters of the command.
@@ -464,11 +659,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
464
659
  );
465
660
  command = command.option("--tsconfig <TSCONFIG>", "The path of the tsconfig file which is used to generate js and dts files.", String).option("--dtsconfig <DTSCONFIG>", "The path of the tsconfig file which is used to generate dts files.", String);
466
661
  command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
467
- command = command.option("--ana", "Enable the bundle analyzer.", parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option("--ana.mode <MODE>", 'The mode of the bundle analyzer, support "static", "json" and "server".', "server").option("--ana.open", "Open the bundle analyzer in the browser.", parseBoolean).option(
468
- "--ana.size <SIZE>",
469
- 'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
470
- "parsed"
471
- );
662
+ command = registerAnalyzerCommandOptions(command);
472
663
  command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
473
664
  command.action(async (commandFiltersOrEntries, options) => {
474
665
  let {
@@ -516,43 +707,14 @@ command.action(async (commandFiltersOrEntries, options) => {
516
707
  },
517
708
  []
518
709
  );
519
- const modules = [];
520
- const cjsModules = [];
521
- const esmModules = [];
522
- let render;
523
- const analyzer = options.ana ? {
524
- dir: options["ana.dir"],
525
- mode: options["ana.mode"],
526
- open: options["ana.open"],
527
- size: options["ana.size"]
528
- } : void 0;
529
- if (options.ana && ![
530
- "stat",
531
- "parsed",
532
- "gzip"
533
- ].includes(analyzer?.size ?? "")) {
534
- throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
535
- }
536
- const server = analyzer && createServer(options.port, "localhost");
537
- if (analyzer) {
538
- await checkDependency("vite-bundle-analyzer");
539
- const { renderView } = await import('vite-bundle-analyzer');
540
- render = renderView;
541
- }
542
- const anaPaths = /* @__PURE__ */ new Set();
543
- const refreshAnalyzer = async (subPath = "", renderModules = modules) => {
544
- if (!(analyzer && server && render))
545
- return;
546
- const p = `/ana${subPath}`;
547
- anaPaths.add(p);
548
- void server.renderTo(
549
- p,
550
- await render(renderModules, {
551
- title: `Jiek Analyzer - ${subPath}`,
552
- mode: analyzer.size
553
- })
554
- );
555
- };
710
+ const shouldCreateServer = [
711
+ options.ana === true && options["ana.mode"] === "server"
712
+ ].some(Boolean);
713
+ const server = shouldCreateServer ? createServer(options.port, "localhost") : void 0;
714
+ const {
715
+ ANALYZER_ENV,
716
+ refreshAnalyzer
717
+ } = await useAnalyzer(options, server);
556
718
  const { build } = loadConfig();
557
719
  silent = silent ?? build?.silent ?? false;
558
720
  if (withoutMin && onlyMin) {
@@ -569,7 +731,7 @@ command.action(async (commandFiltersOrEntries, options) => {
569
731
  entries = void 0;
570
732
  }
571
733
  const env = {
572
- JIEK_ANALYZER: analyzer && JSON.stringify(analyzer),
734
+ ...ANALYZER_ENV,
573
735
  JIEK_BUILDER: type,
574
736
  JIEK_OUT_DIR: outdir,
575
737
  JIEK_CLEAN: String(!noClean),
@@ -608,30 +770,13 @@ command.action(async (commandFiltersOrEntries, options) => {
608
770
  } catch {
609
771
  }
610
772
  }
611
- const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
773
+ const rollupBinaryPath = require$1.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
612
774
  let i = 0;
613
775
  await Promise.all(
614
- Object.entries(value).map(async ([dir, manifest]) => {
776
+ Object.entries(value).map(async ([pkgCWD, manifest]) => {
615
777
  if (manifest.name == null) {
616
778
  throw new Error("package.json must have a name field");
617
779
  }
618
- if (analyzer) {
619
- const anaDir = path.resolve(dir, analyzer.dir);
620
- if (!existsSync(anaDir)) {
621
- mkdirSync(anaDir, { recursive: true });
622
- }
623
- const gitIgnorePath = path.resolve(anaDir, ".gitignore");
624
- if (!existsSync(gitIgnorePath)) {
625
- writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
626
- }
627
- const npmIgnorePath = path.resolve(anaDir, ".npmignore");
628
- if (!existsSync(npmIgnorePath)) {
629
- writeFileSync(npmIgnorePath, "*\n");
630
- }
631
- if (!statSync(anaDir).isDirectory()) {
632
- throw new Error(`The directory '${anaDir}' is not a directory.`);
633
- }
634
- }
635
780
  const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
636
781
  const configFile = resolveByJiekTemp(
637
782
  `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
@@ -647,7 +792,7 @@ command.action(async (commandFiltersOrEntries, options) => {
647
792
  command2.push(...passThroughOptions);
648
793
  const child = execaCommand(command2.join(" "), {
649
794
  ipc: true,
650
- cwd: dir,
795
+ cwd: pkgCWD,
651
796
  env: {
652
797
  ...env,
653
798
  JIEK_NAME: manifest.name,
@@ -753,41 +898,18 @@ command.action(async (commandFiltersOrEntries, options) => {
753
898
  const {
754
899
  data: {
755
900
  type: type2,
756
- path: path2,
757
901
  modules: pkgModules
758
902
  }
759
903
  } = e;
760
- pkgModules.forEach((m) => {
761
- const newM = {
904
+ void refreshAnalyzer(
905
+ pkgCWD,
906
+ pkgModules.map((m) => ({
762
907
  ...m,
908
+ type: type2,
763
909
  filename: `${manifest.name}/${m.filename}`,
764
910
  label: `${manifest.name}/${m.label}`
765
- };
766
- const pushOrReplace = (arr) => {
767
- const index = arr.findIndex(({ filename }) => filename === newM.filename);
768
- if (index === -1) {
769
- arr.push(newM);
770
- } else {
771
- arr[index] = newM;
772
- }
773
- };
774
- pushOrReplace(modules);
775
- if (type2 === "esm") {
776
- pushOrReplace(esmModules);
777
- }
778
- if (type2 === "cjs") {
779
- pushOrReplace(cjsModules);
780
- }
781
- });
782
- void refreshAnalyzer();
783
- void refreshAnalyzer(
784
- `/${type2}`,
785
- {
786
- cjs: cjsModules,
787
- esm: esmModules
788
- }[type2]
911
+ }))
789
912
  );
790
- void refreshAnalyzer(`/${type2}/${manifest.name}/${path2.slice(2)}`, pkgModules);
791
913
  break;
792
914
  }
793
915
  case "debug": {
@@ -824,17 +946,7 @@ ${errorStr}`)));
824
946
  }
825
947
  } finally {
826
948
  multiBars.stop();
827
- let message = "The build is complete";
828
- if (analyzer) {
829
- message += ` and the analyzer is running at http://localhost:${options.port}/ana in ${analyzer.mode} mode.
830
- `;
831
- message += analyzer.open ? " The browser will open automatically.\n" : "";
832
- if (anaPaths.size > 0) {
833
- message += `The analyzer has ${anaPaths.size} pages:
834
- ${Array.from(anaPaths).map((p) => `http://localhost:${options.port}${p}`).join("\n")}`;
835
- }
836
- }
837
- !silent && console.log(message);
949
+ !silent && console.log("Build complete");
838
950
  }
839
951
  });
840
952
 
@@ -4443,7 +4443,7 @@ const getExtendTSConfig = (tsconfigPath) => {
4443
4443
  const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
4444
4444
  const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
4445
4445
  const extendsPaths = resolvePaths(
4446
- exts ? Array.isArray(exts) ? exts : [exts] : []
4446
+ exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
4447
4447
  );
4448
4448
  if (extendsPaths.length === 0)
4449
4449
  return tsconfig;
@@ -4692,7 +4692,7 @@ const withMinify = (output, onlyOncePlugins = []) => {
4692
4692
  const minifyPlugin = resolvedMinifyOptions.type === "esbuild" ? import('rollup-plugin-esbuild').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : resolvedMinifyOptions.type === "swc" ? import('rollup-plugin-swc3').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : import('@rollup/plugin-terser').then(({ default: minify2 }) => minify2(noTypeResolvedMinifyOptions));
4693
4693
  return minify === "only-minify" ? [{
4694
4694
  ...output,
4695
- // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
4695
+ // TODO replace suffix when publish to npm and the `build.output.minify` is 'only-minify'
4696
4696
  // TODO resolve dts output file name
4697
4697
  entryFileNames: (chunkInfo) => typeof output.entryFileNames === "function" ? output.entryFileNames(chunkInfo) : (() => {
4698
4698
  throw new Error("entryFileNames must be a function");
@@ -4799,7 +4799,23 @@ const generateConfigs = (context, options = {}) => {
4799
4799
  const { js: jsOutput, dts: dtsOutput } = resolveOutputControls(context, build.output);
4800
4800
  const rollupOptions = [];
4801
4801
  const commonPlugins = [
4802
- pluginNodeResolve.nodeResolve({ exportConditions })
4802
+ pluginNodeResolve.nodeResolve({
4803
+ exportConditions,
4804
+ extensions: [
4805
+ ".js",
4806
+ ".cjs",
4807
+ ".mjs",
4808
+ ".jsx",
4809
+ ".cjsx",
4810
+ ".mjsx",
4811
+ ".ts",
4812
+ ".cts",
4813
+ ".mts",
4814
+ ".tsx",
4815
+ ".ctsx",
4816
+ ".mtsx"
4817
+ ]
4818
+ })
4803
4819
  ];
4804
4820
  if (jsOutput && !WITHOUT_JS) {
4805
4821
  const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap;
@@ -4427,7 +4427,7 @@ const getExtendTSConfig = (tsconfigPath) => {
4427
4427
  const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
4428
4428
  const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
4429
4429
  const extendsPaths = resolvePaths(
4430
- exts ? Array.isArray(exts) ? exts : [exts] : []
4430
+ exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
4431
4431
  );
4432
4432
  if (extendsPaths.length === 0)
4433
4433
  return tsconfig;
@@ -4676,7 +4676,7 @@ const withMinify = (output, onlyOncePlugins = []) => {
4676
4676
  const minifyPlugin = resolvedMinifyOptions.type === "esbuild" ? import('rollup-plugin-esbuild').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : resolvedMinifyOptions.type === "swc" ? import('rollup-plugin-swc3').then(({ minify: minify2 }) => minify2(noTypeResolvedMinifyOptions)) : import('@rollup/plugin-terser').then(({ default: minify2 }) => minify2(noTypeResolvedMinifyOptions));
4677
4677
  return minify === "only-minify" ? [{
4678
4678
  ...output,
4679
- // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
4679
+ // TODO replace suffix when publish to npm and the `build.output.minify` is 'only-minify'
4680
4680
  // TODO resolve dts output file name
4681
4681
  entryFileNames: (chunkInfo) => typeof output.entryFileNames === "function" ? output.entryFileNames(chunkInfo) : (() => {
4682
4682
  throw new Error("entryFileNames must be a function");
@@ -4783,7 +4783,23 @@ const generateConfigs = (context, options = {}) => {
4783
4783
  const { js: jsOutput, dts: dtsOutput } = resolveOutputControls(context, build.output);
4784
4784
  const rollupOptions = [];
4785
4785
  const commonPlugins = [
4786
- nodeResolve({ exportConditions })
4786
+ nodeResolve({
4787
+ exportConditions,
4788
+ extensions: [
4789
+ ".js",
4790
+ ".cjs",
4791
+ ".mjs",
4792
+ ".jsx",
4793
+ ".cjsx",
4794
+ ".mjsx",
4795
+ ".ts",
4796
+ ".cts",
4797
+ ".mts",
4798
+ ".tsx",
4799
+ ".ctsx",
4800
+ ".mtsx"
4801
+ ]
4802
+ })
4787
4803
  ];
4788
4804
  if (jsOutput && !WITHOUT_JS) {
4789
4805
  const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.2.1",
4
+ "version": "2.2.2",
5
5
  "description": "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.",
6
6
  "author": "YiJie <yijie4188@gmail.com>",
7
7
  "homepage": "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme",
@@ -48,7 +48,11 @@
48
48
  }
49
49
  },
50
50
  "imports": {
51
- "#~/*": "./src/*"
51
+ "#~/*": [
52
+ "./src/*",
53
+ "./src/*/index.ts",
54
+ "./src/*/index.tsx"
55
+ ]
52
56
  },
53
57
  "bin": {
54
58
  "jiek": "bin/jiek.js",
@@ -65,7 +69,7 @@
65
69
  "rollup-plugin-postcss": "^4.0.2",
66
70
  "rollup-plugin-swc3": "^0.12.1",
67
71
  "typescript": "^4.0.0||^5.0.0",
68
- "vite-bundle-analyzer": "^0.15.2"
72
+ "vite-bundle-analyzer": "0.16.0-beta.1"
69
73
  },
70
74
  "dependencies": {
71
75
  "@inquirer/prompts": "^7.1.0",
@@ -83,8 +87,8 @@
83
87
  "jsonc-parser": "^3.2.1",
84
88
  "koa": "^2.15.3",
85
89
  "rollup": "^4.0.0",
86
- "@jiek/utils": "^0.2.3",
87
- "@jiek/pkger": "^0.2.1"
90
+ "@jiek/pkger": "^0.2.1",
91
+ "@jiek/utils": "^0.2.3"
88
92
  },
89
93
  "peerDependenciesMeta": {
90
94
  "@pnpm/filter-workspace-packages": {