jiek 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,8 +22,7 @@ var Koa__default = /*#__PURE__*/_interopDefault(Koa);
22
22
 
23
23
  let root;
24
24
  function getRoot() {
25
- if (root)
26
- return root;
25
+ if (root) return root;
27
26
  const rootOption = process.env.JIEK_ROOT;
28
27
  root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
29
28
  return root;
@@ -32,8 +31,7 @@ function getRoot() {
32
31
  let wd;
33
32
  let notWorkspace$1 = false;
34
33
  function getWD() {
35
- if (wd)
36
- return { wd, notWorkspace: notWorkspace$1 };
34
+ if (wd) return { wd, notWorkspace: notWorkspace$1 };
37
35
  const root = getRoot();
38
36
  if (root !== void 0) {
39
37
  const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type$1);
@@ -120,7 +118,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
120
118
 
121
119
  var name = "jiek";
122
120
  var type = "module";
123
- var version = "2.2.1";
121
+ var version = "2.2.2";
124
122
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
125
123
  var author = "YiJie <yijie4188@gmail.com>";
126
124
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
@@ -300,14 +298,12 @@ function Main() {
300
298
  }, [path, filterModules]);
301
299
  useEffect(() => {
302
300
  const offGraphClick = listen("graph:click", ({ detail }) => {
303
- if (!detail)
304
- return;
301
+ if (!detail) return;
305
302
  let root = detail.node;
306
303
  while (root.parent) {
307
304
  root = root.parent;
308
305
  }
309
- if (root.filename === path)
310
- return;
306
+ if (root.filename === path) return;
311
307
  push(root.filename);
312
308
  });
313
309
  return () => {
@@ -376,8 +372,7 @@ const CLIENT_CUSTOM_RENDER_SCRIPT = [
376
372
  ].join("\n");
377
373
 
378
374
  function parseBoolean(v) {
379
- if (v === void 0)
380
- return true;
375
+ if (v === void 0) return true;
381
376
  return Boolean(v);
382
377
  }
383
378
 
@@ -427,8 +422,7 @@ const useAnalyzer = async (options, server) => {
427
422
  bundleAnalyzerModule = await import('vite-bundle-analyzer');
428
423
  }
429
424
  const refreshAnalyzer = async (cwd, applyModules) => {
430
- if (!(analyzer && server && bundleAnalyzerModule))
431
- return;
425
+ if (!(analyzer && server && bundleAnalyzerModule)) return;
432
426
  if (analyzer.mode === "json") {
433
427
  const anaDir = path__default.default.resolve(cwd, analyzer.dir);
434
428
  if (!fs.existsSync(anaDir)) {
@@ -605,8 +599,7 @@ function loadConfig(dirOrOptions) {
605
599
  default:
606
600
  throw new Error(`unsupported config file type: ${ext}`);
607
601
  }
608
- if (!module)
609
- throw new Error("config file is empty");
602
+ if (!module) throw new Error("config file is empty");
610
603
  return module.default ?? module;
611
604
  }
612
605
 
@@ -818,8 +811,7 @@ command.action(async (commandFiltersOrEntries, options) => {
818
811
  "init",
819
812
  "progress",
820
813
  "watchChange"
821
- ].includes(e.type))
822
- return;
814
+ ].includes(e.type)) return;
823
815
  switch (e.type) {
824
816
  case "init": {
825
817
  const { leafMap, targetsLength } = e.data;
@@ -840,8 +832,7 @@ command.action(async (commandFiltersOrEntries, options) => {
840
832
  });
841
833
  leafs.forEach(({ input, path: path2 }) => {
842
834
  const key = `${input}:${path2}`;
843
- if (bars[key])
844
- return;
835
+ if (bars[key]) return;
845
836
  bars[key] = multiBars.create(50, 0, {
846
837
  pkgName: manifest.name,
847
838
  input: input.padEnd(inputMaxLen + 5),
@@ -862,8 +853,7 @@ command.action(async (commandFiltersOrEntries, options) => {
862
853
  message
863
854
  } = e.data;
864
855
  const bar = bars[`${input}:${path2}`];
865
- if (!bar)
866
- return;
856
+ if (!bar) return;
867
857
  const time = times[`${input}:${path2}`];
868
858
  bar.update(
869
859
  {
@@ -886,8 +876,7 @@ command.action(async (commandFiltersOrEntries, options) => {
886
876
  } = e.data;
887
877
  const key = `${input}:${path2}`;
888
878
  const bar = bars[key];
889
- if (!bar)
890
- return;
879
+ if (!bar) return;
891
880
  let time = times[key] ?? 1;
892
881
  if (!locks[key]) {
893
882
  time += 1;
@@ -40,6 +40,17 @@ interface TemplateOptions {
40
40
  } & rollup_plugin_esbuild.Options) | ({
41
41
  type: 'swc';
42
42
  } & rollup_plugin_swc3.PluginOptions);
43
+ features?: {
44
+ /**
45
+ * When use esbuild type builder, it will inject `supported.import-attributes` option.
46
+ * When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
47
+ *
48
+ * And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
49
+ *
50
+ * @default true
51
+ */
52
+ keepImportAttributes?: boolean | 'assert';
53
+ };
43
54
  output?: {
44
55
  /**
45
56
  * @default true
@@ -40,6 +40,17 @@ interface TemplateOptions {
40
40
  } & rollup_plugin_esbuild.Options) | ({
41
41
  type: 'swc';
42
42
  } & rollup_plugin_swc3.PluginOptions);
43
+ features?: {
44
+ /**
45
+ * When use esbuild type builder, it will inject `supported.import-attributes` option.
46
+ * When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
47
+ *
48
+ * And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
49
+ *
50
+ * @default true
51
+ */
52
+ keepImportAttributes?: boolean | 'assert';
53
+ };
43
54
  output?: {
44
55
  /**
45
56
  * @default true
@@ -12,8 +12,7 @@ import Koa from 'koa';
12
12
 
13
13
  let root;
14
14
  function getRoot() {
15
- if (root)
16
- return root;
15
+ if (root) return root;
17
16
  const rootOption = process.env.JIEK_ROOT;
18
17
  root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
19
18
  return root;
@@ -22,8 +21,7 @@ function getRoot() {
22
21
  let wd;
23
22
  let notWorkspace$1 = false;
24
23
  function getWD() {
25
- if (wd)
26
- return { wd, notWorkspace: notWorkspace$1 };
24
+ if (wd) return { wd, notWorkspace: notWorkspace$1 };
27
25
  const root = getRoot();
28
26
  if (root !== void 0) {
29
27
  const isWorkspace = isWorkspaceDir(root, type$1);
@@ -110,7 +108,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
110
108
 
111
109
  var name = "jiek";
112
110
  var type = "module";
113
- var version = "2.2.1";
111
+ var version = "2.2.2";
114
112
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
115
113
  var author = "YiJie <yijie4188@gmail.com>";
116
114
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
@@ -290,14 +288,12 @@ function Main() {
290
288
  }, [path, filterModules]);
291
289
  useEffect(() => {
292
290
  const offGraphClick = listen("graph:click", ({ detail }) => {
293
- if (!detail)
294
- return;
291
+ if (!detail) return;
295
292
  let root = detail.node;
296
293
  while (root.parent) {
297
294
  root = root.parent;
298
295
  }
299
- if (root.filename === path)
300
- return;
296
+ if (root.filename === path) return;
301
297
  push(root.filename);
302
298
  });
303
299
  return () => {
@@ -366,8 +362,7 @@ const CLIENT_CUSTOM_RENDER_SCRIPT = [
366
362
  ].join("\n");
367
363
 
368
364
  function parseBoolean(v) {
369
- if (v === void 0)
370
- return true;
365
+ if (v === void 0) return true;
371
366
  return Boolean(v);
372
367
  }
373
368
 
@@ -417,8 +412,7 @@ const useAnalyzer = async (options, server) => {
417
412
  bundleAnalyzerModule = await import('vite-bundle-analyzer');
418
413
  }
419
414
  const refreshAnalyzer = async (cwd, applyModules) => {
420
- if (!(analyzer && server && bundleAnalyzerModule))
421
- return;
415
+ if (!(analyzer && server && bundleAnalyzerModule)) return;
422
416
  if (analyzer.mode === "json") {
423
417
  const anaDir = path.resolve(cwd, analyzer.dir);
424
418
  if (!existsSync(anaDir)) {
@@ -595,8 +589,7 @@ function loadConfig(dirOrOptions) {
595
589
  default:
596
590
  throw new Error(`unsupported config file type: ${ext}`);
597
591
  }
598
- if (!module)
599
- throw new Error("config file is empty");
592
+ if (!module) throw new Error("config file is empty");
600
593
  return module.default ?? module;
601
594
  }
602
595
 
@@ -808,8 +801,7 @@ command.action(async (commandFiltersOrEntries, options) => {
808
801
  "init",
809
802
  "progress",
810
803
  "watchChange"
811
- ].includes(e.type))
812
- return;
804
+ ].includes(e.type)) return;
813
805
  switch (e.type) {
814
806
  case "init": {
815
807
  const { leafMap, targetsLength } = e.data;
@@ -830,8 +822,7 @@ command.action(async (commandFiltersOrEntries, options) => {
830
822
  });
831
823
  leafs.forEach(({ input, path: path2 }) => {
832
824
  const key = `${input}:${path2}`;
833
- if (bars[key])
834
- return;
825
+ if (bars[key]) return;
835
826
  bars[key] = multiBars.create(50, 0, {
836
827
  pkgName: manifest.name,
837
828
  input: input.padEnd(inputMaxLen + 5),
@@ -852,8 +843,7 @@ command.action(async (commandFiltersOrEntries, options) => {
852
843
  message
853
844
  } = e.data;
854
845
  const bar = bars[`${input}:${path2}`];
855
- if (!bar)
856
- return;
846
+ if (!bar) return;
857
847
  const time = times[`${input}:${path2}`];
858
848
  bar.update(
859
849
  {
@@ -876,8 +866,7 @@ command.action(async (commandFiltersOrEntries, options) => {
876
866
  } = e.data;
877
867
  const key = `${input}:${path2}`;
878
868
  const bar = bars[key];
879
- if (!bar)
880
- return;
869
+ if (!bar) return;
881
870
  let time = times[key] ?? 1;
882
871
  if (!locks[key]) {
883
872
  time += 1;
package/dist/cli.cjs CHANGED
@@ -47,8 +47,7 @@ var require$$0__default$1 = /*#__PURE__*/_interopDefault(require$$0$1);
47
47
 
48
48
  let root;
49
49
  function getRoot() {
50
- if (root)
51
- return root;
50
+ if (root) return root;
52
51
  const rootOption = process.env.JIEK_ROOT;
53
52
  root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
54
53
  return root;
@@ -57,8 +56,7 @@ function getRoot() {
57
56
  let wd;
58
57
  let notWorkspace = false;
59
58
  function getWD() {
60
- if (wd)
61
- return { wd, notWorkspace };
59
+ if (wd) return { wd, notWorkspace };
62
60
  const root = getRoot();
63
61
  if (root !== void 0) {
64
62
  const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type);
@@ -4438,8 +4436,7 @@ function loadConfig(dirOrOptions) {
4438
4436
  default:
4439
4437
  throw new Error(`unsupported config file type: ${ext}`);
4440
4438
  }
4441
- if (!module)
4442
- throw new Error("config file is empty");
4439
+ if (!module) throw new Error("config file is empty");
4443
4440
  return module.default ?? module;
4444
4441
  }
4445
4442
 
@@ -4551,10 +4548,8 @@ async function prepublish({ bumper: bumper$1 } = {}) {
4551
4548
  )
4552
4549
  );
4553
4550
  for (const [key, value] of Object.entries(manifest)) {
4554
- if (key === "version")
4555
- continue;
4556
- if (JSON.stringify(value) === JSON.stringify(oldJSON[key]))
4557
- continue;
4551
+ if (key === "version") continue;
4552
+ if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue;
4558
4553
  if (key !== "exports") {
4559
4554
  newJSONString = jsoncParser.applyEdits(
4560
4555
  newJSONString,
@@ -4593,8 +4588,7 @@ async function prepublish({ bumper: bumper$1 } = {}) {
4593
4588
  }
4594
4589
  }
4595
4590
  for (const [k, v] of Object.entries(indexPublishConfig)) {
4596
- if (v === void 0)
4597
- continue;
4591
+ if (v === void 0) continue;
4598
4592
  newJSONString = jsoncParser.applyEdits(
4599
4593
  newJSONString,
4600
4594
  jsoncParser.modify(
package/dist/cli.js CHANGED
@@ -16,8 +16,7 @@ import 'jiek/cli-only-build';
16
16
 
17
17
  let root;
18
18
  function getRoot() {
19
- if (root)
20
- return root;
19
+ if (root) return root;
21
20
  const rootOption = process.env.JIEK_ROOT;
22
21
  root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
23
22
  return root;
@@ -26,8 +25,7 @@ function getRoot() {
26
25
  let wd;
27
26
  let notWorkspace = false;
28
27
  function getWD() {
29
- if (wd)
30
- return { wd, notWorkspace };
28
+ if (wd) return { wd, notWorkspace };
31
29
  const root = getRoot();
32
30
  if (root !== void 0) {
33
31
  const isWorkspace = isWorkspaceDir(root, type);
@@ -4407,8 +4405,7 @@ function loadConfig(dirOrOptions) {
4407
4405
  default:
4408
4406
  throw new Error(`unsupported config file type: ${ext}`);
4409
4407
  }
4410
- if (!module)
4411
- throw new Error("config file is empty");
4408
+ if (!module) throw new Error("config file is empty");
4412
4409
  return module.default ?? module;
4413
4410
  }
4414
4411
 
@@ -4520,10 +4517,8 @@ async function prepublish({ bumper } = {}) {
4520
4517
  )
4521
4518
  );
4522
4519
  for (const [key, value] of Object.entries(manifest)) {
4523
- if (key === "version")
4524
- continue;
4525
- if (JSON.stringify(value) === JSON.stringify(oldJSON[key]))
4526
- continue;
4520
+ if (key === "version") continue;
4521
+ if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue;
4527
4522
  if (key !== "exports") {
4528
4523
  newJSONString = applyEdits(
4529
4524
  newJSONString,
@@ -4562,8 +4557,7 @@ async function prepublish({ bumper } = {}) {
4562
4557
  }
4563
4558
  }
4564
4559
  for (const [k, v] of Object.entries(indexPublishConfig)) {
4565
- if (v === void 0)
4566
- continue;
4560
+ if (v === void 0) continue;
4567
4561
  newJSONString = applyEdits(
4568
4562
  newJSONString,
4569
4563
  modify(
package/dist/index.d.cts CHANGED
@@ -40,6 +40,17 @@ interface TemplateOptions {
40
40
  } & rollup_plugin_esbuild.Options) | ({
41
41
  type: 'swc';
42
42
  } & rollup_plugin_swc3.PluginOptions);
43
+ features?: {
44
+ /**
45
+ * When use esbuild type builder, it will inject `supported.import-attributes` option.
46
+ * When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
47
+ *
48
+ * And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
49
+ *
50
+ * @default true
51
+ */
52
+ keepImportAttributes?: boolean | 'assert';
53
+ };
43
54
  output?: {
44
55
  /**
45
56
  * @default true
package/dist/index.d.ts CHANGED
@@ -40,6 +40,17 @@ interface TemplateOptions {
40
40
  } & rollup_plugin_esbuild.Options) | ({
41
41
  type: 'swc';
42
42
  } & rollup_plugin_swc3.PluginOptions);
43
+ features?: {
44
+ /**
45
+ * When use esbuild type builder, it will inject `supported.import-attributes` option.
46
+ * When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
47
+ *
48
+ * And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
49
+ *
50
+ * @default true
51
+ */
52
+ keepImportAttributes?: boolean | 'assert';
53
+ };
43
54
  output?: {
44
55
  /**
45
56
  * @default true
@@ -4171,8 +4171,7 @@ function bundleAnalyzer(modulesResolved) {
4171
4171
  return {
4172
4172
  name: "jiek:bundle-analyzer",
4173
4173
  async closeBundle(...args) {
4174
- if (typeof ana.closeBundle !== "function")
4175
- return;
4174
+ if (typeof ana.closeBundle !== "function") return;
4176
4175
  return ana.closeBundle?.call(this, ...args);
4177
4176
  }
4178
4177
  };
@@ -4280,8 +4279,7 @@ function getExports({
4280
4279
 
4281
4280
  let root;
4282
4281
  function getRoot() {
4283
- if (root)
4284
- return root;
4282
+ if (root) return root;
4285
4283
  const rootOption = process.env.JIEK_ROOT;
4286
4284
  root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
4287
4285
  return root;
@@ -4298,8 +4296,7 @@ try {
4298
4296
  let wd;
4299
4297
  let notWorkspace = false;
4300
4298
  function getWD() {
4301
- if (wd)
4302
- return { wd, notWorkspace };
4299
+ if (wd) return { wd, notWorkspace };
4303
4300
  const root = getRoot();
4304
4301
  if (root !== void 0) {
4305
4302
  const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type);
@@ -4421,16 +4418,14 @@ function loadConfig(dirOrOptions) {
4421
4418
  default:
4422
4419
  throw new Error(`unsupported config file type: ${ext}`);
4423
4420
  }
4424
- if (!module)
4425
- throw new Error("config file is empty");
4421
+ if (!module) throw new Error("config file is empty");
4426
4422
  return module.default ?? module;
4427
4423
  }
4428
4424
 
4429
4425
  const recusiveListFiles = (dir) => fs__default.default.readdirSync(dir).reduce((acc, file) => {
4430
4426
  const filePath = path.resolve(dir, file);
4431
4427
  if (fs__default.default.statSync(filePath).isDirectory()) {
4432
- if (filePath.endsWith("/node_modules"))
4433
- return acc;
4428
+ if (filePath.endsWith("/node_modules")) return acc;
4434
4429
  return [...acc, ...recusiveListFiles(filePath)];
4435
4430
  }
4436
4431
  return [...acc, filePath];
@@ -4445,8 +4440,7 @@ const getExtendTSConfig = (tsconfigPath) => {
4445
4440
  const extendsPaths = resolvePaths(
4446
4441
  exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
4447
4442
  );
4448
- if (extendsPaths.length === 0)
4449
- return tsconfig;
4443
+ if (extendsPaths.length === 0) return tsconfig;
4450
4444
  return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
4451
4445
  ...acc,
4452
4446
  ...curr,
@@ -4473,24 +4467,20 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4473
4467
  tsconfig.include,
4474
4468
  tsconfig.exclude
4475
4469
  ].map(resolvePaths);
4476
- if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i)))
4477
- return;
4478
- if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
4479
- return;
4470
+ if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
4471
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
4480
4472
  let isInclude = false;
4481
- isInclude || (isInclude = files.length > 0 && files.includes(filePath));
4482
- isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
4473
+ isInclude ||= files.length > 0 && files.includes(filePath);
4474
+ isInclude ||= include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i));
4483
4475
  if (isInclude) {
4484
4476
  return tsconfig.compilerOptions ?? {};
4485
4477
  } else {
4486
- if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0)
4487
- return;
4478
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
4488
4479
  }
4489
4480
  references.reverse();
4490
4481
  for (const ref of references) {
4491
4482
  const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
4492
- if (compilerOptions)
4493
- return compilerOptions;
4483
+ if (compilerOptions) return compilerOptions;
4494
4484
  }
4495
4485
  return tsconfig.compilerOptions;
4496
4486
  };
@@ -4669,10 +4659,8 @@ const resolveOutputControls = (context, output) => ({
4669
4659
  const resolveWorkspacePath = (p) => path.resolve(WORKSPACE_ROOT, p);
4670
4660
  const pascalCase = (str) => str.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()).replace(/(?:^|-)(\w)/g, (_, $1) => $1.toUpperCase());
4671
4661
  const reveal = (obj, keys) => keys.reduce((acc, key) => {
4672
- if (typeof acc === "string")
4673
- throw new Error("key not found in exports");
4674
- if (!(key in acc))
4675
- throw new Error(`key ${key} not found in exports`);
4662
+ if (typeof acc === "string") throw new Error("key not found in exports");
4663
+ if (!(key in acc)) throw new Error(`key ${key} not found in exports`);
4676
4664
  return acc[key];
4677
4665
  }, obj);
4678
4666
  const resolveMinifyOptions = (minifyOptions) => typeof minifyOptions === "string" ? { type: minifyOptions } : minifyOptions ?? { type: "esbuild" };
@@ -4819,11 +4807,19 @@ const generateConfigs = (context, options = {}) => {
4819
4807
  ];
4820
4808
  if (jsOutput && !WITHOUT_JS) {
4821
4809
  const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap;
4810
+ const features = Object.assign({
4811
+ keepImportAttributes: true
4812
+ }, build.features);
4822
4813
  const builder = resolvedBuilderOptions.type === "esbuild" ? import('rollup-plugin-esbuild').then(
4823
4814
  ({ default: esbuild }) => esbuild({
4824
4815
  sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
4825
4816
  tsconfig: buildTSConfigPath,
4826
- ...noTypeResolvedBuilderOptions
4817
+ target: "node22",
4818
+ ...noTypeResolvedBuilderOptions,
4819
+ supported: {
4820
+ "import-attributes": features.keepImportAttributes !== false,
4821
+ ...resolvedBuilderOptions.supported
4822
+ }
4827
4823
  })
4828
4824
  ) : import('rollup-plugin-swc3').then(
4829
4825
  ({ default: swc }) => swc({
@@ -4832,7 +4828,14 @@ const generateConfigs = (context, options = {}) => {
4832
4828
  inline: "inline"
4833
4829
  }[sourcemap] ?? void 0,
4834
4830
  tsconfig: buildTSConfigPath,
4835
- ...noTypeResolvedBuilderOptions
4831
+ ...noTypeResolvedBuilderOptions,
4832
+ jsc: {
4833
+ ...resolvedBuilderOptions.jsc,
4834
+ experimental: {
4835
+ ...resolvedBuilderOptions.jsc?.experimental,
4836
+ keepImportAttributes: features.keepImportAttributes !== false
4837
+ }
4838
+ }
4836
4839
  })
4837
4840
  );
4838
4841
  const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
@@ -4851,6 +4854,8 @@ const generateConfigs = (context, options = {}) => {
4851
4854
  sourcemap,
4852
4855
  format,
4853
4856
  strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
4857
+ externalImportAttributes: features.keepImportAttributes !== false,
4858
+ importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
4854
4859
  plugins: [
4855
4860
  isFormatEsm(format === "esm")
4856
4861
  ]
@@ -4926,10 +4931,8 @@ const generateConfigs = (context, options = {}) => {
4926
4931
  function template(packageJSON) {
4927
4932
  const { name, type, exports: entrypoints$1 } = packageJSON;
4928
4933
  const pkgIsModule = type === "module";
4929
- if (!name)
4930
- throw new Error("package.json name is required");
4931
- if (!entrypoints$1)
4932
- throw new Error("package.json exports is required");
4934
+ if (!name) throw new Error("package.json name is required");
4935
+ if (!entrypoints$1) throw new Error("package.json exports is required");
4933
4936
  const packageName = pascalCase(name);
4934
4937
  const external = externalResolver(packageJSON);
4935
4938
  const [filteredResolvedEntrypoints, exports] = getExports({
@@ -4155,8 +4155,7 @@ function bundleAnalyzer(modulesResolved) {
4155
4155
  return {
4156
4156
  name: "jiek:bundle-analyzer",
4157
4157
  async closeBundle(...args) {
4158
- if (typeof ana.closeBundle !== "function")
4159
- return;
4158
+ if (typeof ana.closeBundle !== "function") return;
4160
4159
  return ana.closeBundle?.call(this, ...args);
4161
4160
  }
4162
4161
  };
@@ -4264,8 +4263,7 @@ function getExports({
4264
4263
 
4265
4264
  let root;
4266
4265
  function getRoot() {
4267
- if (root)
4268
- return root;
4266
+ if (root) return root;
4269
4267
  const rootOption = process.env.JIEK_ROOT;
4270
4268
  root = rootOption ? path.isAbsolute(rootOption) ? rootOption : path.resolve(process.cwd(), rootOption) : void 0;
4271
4269
  return root;
@@ -4282,8 +4280,7 @@ try {
4282
4280
  let wd;
4283
4281
  let notWorkspace = false;
4284
4282
  function getWD() {
4285
- if (wd)
4286
- return { wd, notWorkspace };
4283
+ if (wd) return { wd, notWorkspace };
4287
4284
  const root = getRoot();
4288
4285
  if (root !== void 0) {
4289
4286
  const isWorkspace = isWorkspaceDir(root, type);
@@ -4405,16 +4402,14 @@ function loadConfig(dirOrOptions) {
4405
4402
  default:
4406
4403
  throw new Error(`unsupported config file type: ${ext}`);
4407
4404
  }
4408
- if (!module)
4409
- throw new Error("config file is empty");
4405
+ if (!module) throw new Error("config file is empty");
4410
4406
  return module.default ?? module;
4411
4407
  }
4412
4408
 
4413
4409
  const recusiveListFiles = (dir) => fs.readdirSync(dir).reduce((acc, file) => {
4414
4410
  const filePath = resolve(dir, file);
4415
4411
  if (fs.statSync(filePath).isDirectory()) {
4416
- if (filePath.endsWith("/node_modules"))
4417
- return acc;
4412
+ if (filePath.endsWith("/node_modules")) return acc;
4418
4413
  return [...acc, ...recusiveListFiles(filePath)];
4419
4414
  }
4420
4415
  return [...acc, filePath];
@@ -4429,8 +4424,7 @@ const getExtendTSConfig = (tsconfigPath) => {
4429
4424
  const extendsPaths = resolvePaths(
4430
4425
  exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
4431
4426
  );
4432
- if (extendsPaths.length === 0)
4433
- return tsconfig;
4427
+ if (extendsPaths.length === 0) return tsconfig;
4434
4428
  return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
4435
4429
  ...acc,
4436
4430
  ...curr,
@@ -4457,24 +4451,20 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4457
4451
  tsconfig.include,
4458
4452
  tsconfig.exclude
4459
4453
  ].map(resolvePaths);
4460
- if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i)))
4461
- return;
4462
- if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0)
4463
- return;
4454
+ if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
4455
+ if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
4464
4456
  let isInclude = false;
4465
- isInclude || (isInclude = files.length > 0 && files.includes(filePath));
4466
- isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
4457
+ isInclude ||= files.length > 0 && files.includes(filePath);
4458
+ isInclude ||= include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i));
4467
4459
  if (isInclude) {
4468
4460
  return tsconfig.compilerOptions ?? {};
4469
4461
  } else {
4470
- if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0)
4471
- return;
4462
+ if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
4472
4463
  }
4473
4464
  references.reverse();
4474
4465
  for (const ref of references) {
4475
4466
  const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
4476
- if (compilerOptions)
4477
- return compilerOptions;
4467
+ if (compilerOptions) return compilerOptions;
4478
4468
  }
4479
4469
  return tsconfig.compilerOptions;
4480
4470
  };
@@ -4653,10 +4643,8 @@ const resolveOutputControls = (context, output) => ({
4653
4643
  const resolveWorkspacePath = (p) => resolve(WORKSPACE_ROOT, p);
4654
4644
  const pascalCase = (str) => str.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()).replace(/(?:^|-)(\w)/g, (_, $1) => $1.toUpperCase());
4655
4645
  const reveal = (obj, keys) => keys.reduce((acc, key) => {
4656
- if (typeof acc === "string")
4657
- throw new Error("key not found in exports");
4658
- if (!(key in acc))
4659
- throw new Error(`key ${key} not found in exports`);
4646
+ if (typeof acc === "string") throw new Error("key not found in exports");
4647
+ if (!(key in acc)) throw new Error(`key ${key} not found in exports`);
4660
4648
  return acc[key];
4661
4649
  }, obj);
4662
4650
  const resolveMinifyOptions = (minifyOptions) => typeof minifyOptions === "string" ? { type: minifyOptions } : minifyOptions ?? { type: "esbuild" };
@@ -4803,11 +4791,19 @@ const generateConfigs = (context, options = {}) => {
4803
4791
  ];
4804
4792
  if (jsOutput && !WITHOUT_JS) {
4805
4793
  const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.js : options?.output?.sourcemap;
4794
+ const features = Object.assign({
4795
+ keepImportAttributes: true
4796
+ }, build.features);
4806
4797
  const builder = resolvedBuilderOptions.type === "esbuild" ? import('rollup-plugin-esbuild').then(
4807
4798
  ({ default: esbuild }) => esbuild({
4808
4799
  sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
4809
4800
  tsconfig: buildTSConfigPath,
4810
- ...noTypeResolvedBuilderOptions
4801
+ target: "node22",
4802
+ ...noTypeResolvedBuilderOptions,
4803
+ supported: {
4804
+ "import-attributes": features.keepImportAttributes !== false,
4805
+ ...resolvedBuilderOptions.supported
4806
+ }
4811
4807
  })
4812
4808
  ) : import('rollup-plugin-swc3').then(
4813
4809
  ({ default: swc }) => swc({
@@ -4816,7 +4812,14 @@ const generateConfigs = (context, options = {}) => {
4816
4812
  inline: "inline"
4817
4813
  }[sourcemap] ?? void 0,
4818
4814
  tsconfig: buildTSConfigPath,
4819
- ...noTypeResolvedBuilderOptions
4815
+ ...noTypeResolvedBuilderOptions,
4816
+ jsc: {
4817
+ ...resolvedBuilderOptions.jsc,
4818
+ experimental: {
4819
+ ...resolvedBuilderOptions.jsc?.experimental,
4820
+ keepImportAttributes: features.keepImportAttributes !== false
4821
+ }
4822
+ }
4820
4823
  })
4821
4824
  );
4822
4825
  const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
@@ -4835,6 +4838,8 @@ const generateConfigs = (context, options = {}) => {
4835
4838
  sourcemap,
4836
4839
  format,
4837
4840
  strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
4841
+ externalImportAttributes: features.keepImportAttributes !== false,
4842
+ importAttributesKey: features.keepImportAttributes === false || features.keepImportAttributes === void 0 ? void 0 : features.keepImportAttributes === true ? "with" : features.keepImportAttributes,
4838
4843
  plugins: [
4839
4844
  isFormatEsm(format === "esm")
4840
4845
  ]
@@ -4910,10 +4915,8 @@ const generateConfigs = (context, options = {}) => {
4910
4915
  function template(packageJSON) {
4911
4916
  const { name, type, exports: entrypoints } = packageJSON;
4912
4917
  const pkgIsModule = type === "module";
4913
- if (!name)
4914
- throw new Error("package.json name is required");
4915
- if (!entrypoints)
4916
- throw new Error("package.json exports is required");
4918
+ if (!name) throw new Error("package.json name is required");
4919
+ if (!entrypoints) throw new Error("package.json exports is required");
4917
4920
  const packageName = pascalCase(name);
4918
4921
  const external = externalResolver(packageJSON);
4919
4922
  const [filteredResolvedEntrypoints, exports] = getExports({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.2.2",
4
+ "version": "2.2.3",
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",
@@ -49,6 +49,17 @@ export interface TemplateOptions {
49
49
  | ({
50
50
  type: 'swc'
51
51
  } & import('rollup-plugin-swc3').PluginOptions)
52
+ features?: {
53
+ /**
54
+ * When use esbuild type builder, it will inject `supported.import-attributes` option.
55
+ * When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
56
+ *
57
+ * And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
58
+ *
59
+ * @default true
60
+ */
61
+ keepImportAttributes?: boolean | 'assert'
62
+ }
52
63
  output?: {
53
64
  /**
54
65
  * @default true
@@ -381,12 +381,20 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
381
381
  const sourcemap = typeof options?.output?.sourcemap === 'object'
382
382
  ? options.output.sourcemap.js
383
383
  : options?.output?.sourcemap
384
+ const features = Object.assign({
385
+ keepImportAttributes: true
386
+ }, build.features)
384
387
  const builder = resolvedBuilderOptions.type === 'esbuild'
385
388
  ? import('rollup-plugin-esbuild').then(({ default: esbuild }) =>
386
389
  esbuild({
387
390
  sourceMap: sourcemap === 'hidden' ? false : !!sourcemap,
388
391
  tsconfig: buildTSConfigPath,
389
- ...noTypeResolvedBuilderOptions
392
+ target: 'node22',
393
+ ...noTypeResolvedBuilderOptions,
394
+ supported: {
395
+ 'import-attributes': features.keepImportAttributes !== false,
396
+ ...resolvedBuilderOptions.supported
397
+ }
390
398
  })
391
399
  )
392
400
  : import('rollup-plugin-swc3').then(({ default: swc }) =>
@@ -400,7 +408,14 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
400
408
  inline: 'inline'
401
409
  } as const)[sourcemap] ?? undefined,
402
410
  tsconfig: buildTSConfigPath,
403
- ...noTypeResolvedBuilderOptions
411
+ ...noTypeResolvedBuilderOptions,
412
+ jsc: {
413
+ ...resolvedBuilderOptions.jsc,
414
+ experimental: {
415
+ ...resolvedBuilderOptions.jsc?.experimental,
416
+ keepImportAttributes: features.keepImportAttributes !== false
417
+ }
418
+ }
404
419
  })
405
420
  )
406
421
  const [ana, anaOutputPlugin] = bundleAnalyzer(modules => void publishInEntry('modulesAnalyze', { modules }))
@@ -427,6 +442,15 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
427
442
  strict: typeof options?.output?.strict === 'object'
428
443
  ? options.output.strict.js
429
444
  : options?.output?.strict,
445
+ externalImportAttributes: features.keepImportAttributes !== false,
446
+ importAttributesKey: (
447
+ features.keepImportAttributes === false
448
+ || features.keepImportAttributes === undefined
449
+ )
450
+ ? undefined
451
+ : features.keepImportAttributes === true
452
+ ? 'with'
453
+ : features.keepImportAttributes,
430
454
  plugins: [
431
455
  isFormatEsm(format === 'esm')
432
456
  ]