jiek 2.1.12 → 2.1.13

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.
@@ -9,10 +9,10 @@ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
9
9
  var commonjs = require('@rollup/plugin-commonjs');
10
10
  var json = require('@rollup/plugin-json');
11
11
  var pluginNodeResolve = require('@rollup/plugin-node-resolve');
12
- var execa = require('execa');
13
12
  var require$$0 = require('util');
14
13
  var require$$0$1 = require('path');
15
14
  var ts = require('typescript');
15
+ var execa = require('execa');
16
16
  var node_module = require('node:module');
17
17
  var commander = require('commander');
18
18
  var jsYaml = require('js-yaml');
@@ -4140,6 +4140,53 @@ function requireMicromatch () {
4140
4140
 
4141
4141
  var micromatchExports = requireMicromatch();
4142
4142
 
4143
+ const publish = async (type, data) => {
4144
+ return execa.sendMessage({ type, data });
4145
+ };
4146
+
4147
+ const {
4148
+ JIEK_ANALYZER
4149
+ } = process__default.default.env;
4150
+ const ANALYZER = JIEK_ANALYZER != null && JSON.parse(JIEK_ANALYZER);
4151
+ function bundleAnalyzer(modulesResolved) {
4152
+ if (!ANALYZER) {
4153
+ return [];
4154
+ }
4155
+ const defaultSizes = {
4156
+ parsed: "parsed",
4157
+ stat: "stat",
4158
+ gzip: "gzip"
4159
+ }[ANALYZER.size ?? "stat"] ?? "parsed";
4160
+ let ana;
4161
+ async function initAna() {
4162
+ const { adapter, analyzer } = await import('vite-bundle-analyzer');
4163
+ ana = ana ?? adapter(analyzer({
4164
+ defaultSizes,
4165
+ analyzerMode: modulesResolved
4166
+ }));
4167
+ }
4168
+ return [
4169
+ (async () => {
4170
+ await initAna();
4171
+ return {
4172
+ name: "jiek:bundle-analyzer",
4173
+ async closeBundle(...args) {
4174
+ if (typeof ana.closeBundle !== "function")
4175
+ return;
4176
+ return ana.closeBundle?.call(this, ...args);
4177
+ }
4178
+ };
4179
+ })(),
4180
+ (async () => {
4181
+ await initAna();
4182
+ return {
4183
+ ...ana,
4184
+ name: "jiek:bundle-analyzer-output"
4185
+ };
4186
+ })()
4187
+ ];
4188
+ }
4189
+
4143
4190
  const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4144
4191
  const {
4145
4192
  JIEK_OUT_DIR
@@ -4538,7 +4585,6 @@ function externalResolver(jsonOrPath = process.cwd()) {
4538
4585
  }
4539
4586
 
4540
4587
  const {
4541
- JIEK_ANALYZER,
4542
4588
  JIEK_ROOT,
4543
4589
  JIEK_NAME,
4544
4590
  JIEK_BUILDER,
@@ -4561,7 +4607,6 @@ const resolveArrayString = (str) => {
4561
4607
  ];
4562
4608
  return arr?.length ? arr : void 0;
4563
4609
  };
4564
- const ANALYZER = JIEK_ANALYZER && JSON.parse(JIEK_ANALYZER);
4565
4610
  const entries = resolveArrayString(JIEK_ENTRIES)?.map((e) => ({ "index": "." })[e] ?? e);
4566
4611
  const commandExternal = resolveArrayString(JIEK_EXTERNAL)?.map((e) => new RegExp(`^${e}$`));
4567
4612
  const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
@@ -4636,15 +4681,9 @@ const resolvedMinifyOptions = resolveMinifyOptions(build.output?.minifyOptions ?
4636
4681
  const { type: _resolvedMinifyOptionsType, ...noTypeResolvedMinifyOptions } = resolvedMinifyOptions;
4637
4682
  const resolvedBuilderOptions = resolveBuilderOptions(build.builder ?? BUILDER_OPTIONS);
4638
4683
  const { type: _resolvedBuilderOptionsType, ...noTypeResolvedBuilderOptions } = resolvedBuilderOptions;
4639
- const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE) => {
4684
+ const withMinify = (output, onlyOncePlugins = []) => {
4685
+ const minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE;
4640
4686
  output.plugins = output.plugins ?? [];
4641
- const onlyOncePlugins = [
4642
- // adapter(analyzer({
4643
- // analyzerMode: 'server',
4644
- // analyzerPort: 8888,
4645
- // reportTitle: 'Bundle Analysis'
4646
- // }))
4647
- ];
4648
4687
  if (minify === false) {
4649
4688
  output.plugins.push(...onlyOncePlugins);
4650
4689
  return [output];
@@ -4691,6 +4730,7 @@ const generateConfigs = (context, options = {}) => {
4691
4730
  const isModule = conditionals.includes("import");
4692
4731
  const isCommonJS = conditionals.includes("require");
4693
4732
  const isBrowser = conditionals.includes("browser");
4733
+ const format = isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs";
4694
4734
  const dtsTSConfigPaths = [
4695
4735
  resolveWorkspacePath("tsconfig.json"),
4696
4736
  resolveWorkspacePath("tsconfig.dts.json")
@@ -4728,10 +4768,19 @@ const generateConfigs = (context, options = {}) => {
4728
4768
  delete compilerOptions.composite;
4729
4769
  }
4730
4770
  const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
4731
- const throughEventProps = {
4732
- type: "progress",
4733
- data: { name, path: path$1, exportConditions, input }
4734
- };
4771
+ const publishInEntry = (type, data) => (
4772
+ // eslint-disable-next-line ts/no-unsafe-argument
4773
+ void publish(type, {
4774
+ ...{
4775
+ type: format,
4776
+ name,
4777
+ path: path$1,
4778
+ exportConditions,
4779
+ input
4780
+ },
4781
+ ...data
4782
+ })
4783
+ );
4735
4784
  const { js: jsPlugins, dts: dtsPlugins } = resolveBuildPlugins(context, build.plugins);
4736
4785
  if (input.includes("**")) {
4737
4786
  throw new Error(
@@ -4769,55 +4818,10 @@ const generateConfigs = (context, options = {}) => {
4769
4818
  ...noTypeResolvedBuilderOptions
4770
4819
  })
4771
4820
  );
4772
- const ana = ANALYZER ? import('vite-bundle-analyzer').then(({ adapter, analyzer }) => {
4773
- const defaultSizes = {
4774
- parsed: "parsed",
4775
- stat: "stat",
4776
- gzip: "gzip"
4777
- }[ANALYZER.size ?? "stat"] ?? "parsed";
4778
- const title = `${path.join(context.name, context.path)} ${context.conditionals.join(",")}`;
4779
- const filename = title.replace("/", "_").replace(" ", "_");
4780
- switch (ANALYZER.mode ?? "server") {
4781
- case "server":
4782
- return adapter(analyzer({
4783
- defaultSizes,
4784
- analyzerMode: "server",
4785
- analyzerPort: ANALYZER.port ?? "auto",
4786
- openAnalyzer: ANALYZER.open ?? false,
4787
- reportTitle: `Bundle Analysis ${title}`
4788
- }));
4789
- case "json":
4790
- return adapter(analyzer({
4791
- defaultSizes,
4792
- analyzerMode: "json",
4793
- fileName: ANALYZER.dir ? path.join(ANALYZER.dir, filename) : filename
4794
- }));
4795
- case "static":
4796
- return adapter(analyzer({
4797
- defaultSizes,
4798
- analyzerMode: "static",
4799
- analyzerPort: ANALYZER.port ?? "auto",
4800
- openAnalyzer: ANALYZER.open ?? false,
4801
- reportTitle: `Bundle Analysis ${title}`,
4802
- fileName: ANALYZER.dir ? path.join(ANALYZER.dir, filename) : filename
4803
- }));
4804
- case void 0: {
4805
- throw new Error("Not implemented yet: undefined case");
4806
- }
4807
- default:
4808
- void execa.sendMessage(
4809
- {
4810
- ...throughEventProps,
4811
- data: {
4812
- ...throughEventProps.data,
4813
- event: "error",
4814
- message: "ANALYZER.mode not supported",
4815
- tags: ["js"]
4816
- }
4817
- }
4818
- );
4819
- }
4820
- }) : void 0;
4821
+ const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
4822
+ const onlyOncePlugins = [
4823
+ anaOutputPlugin
4824
+ ];
4821
4825
  rollupOptions.push({
4822
4826
  input: inputObj,
4823
4827
  external,
@@ -4828,12 +4832,12 @@ const generateConfigs = (context, options = {}) => {
4828
4832
  interop: "auto",
4829
4833
  entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix) : output.replace(`${jsOutdir}/`, ""),
4830
4834
  sourcemap,
4831
- format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
4835
+ format,
4832
4836
  strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
4833
4837
  plugins: [
4834
- isFormatEsm(isModule)
4838
+ isFormatEsm(format === "esm")
4835
4839
  ]
4836
- })
4840
+ }, onlyOncePlugins)
4837
4841
  ],
4838
4842
  plugins: [
4839
4843
  ...commonPlugins,
@@ -4848,12 +4852,7 @@ const generateConfigs = (context, options = {}) => {
4848
4852
  builder,
4849
4853
  ana,
4850
4854
  progress({
4851
- onEvent: (event, message) => void execa.sendMessage(
4852
- {
4853
- ...throughEventProps,
4854
- data: { ...throughEventProps.data, event, message, tags: ["js"] }
4855
- }
4856
- )
4855
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
4857
4856
  }),
4858
4857
  jsPlugins
4859
4858
  ]
@@ -4890,12 +4889,7 @@ const generateConfigs = (context, options = {}) => {
4890
4889
  tsconfig: dtsTSConfigPath
4891
4890
  }),
4892
4891
  progress({
4893
- onEvent: (event, message) => void execa.sendMessage(
4894
- {
4895
- ...throughEventProps,
4896
- data: { ...throughEventProps.data, event, message, tags: ["dts"] }
4897
- }
4898
- )
4892
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["dts"] })
4899
4893
  }),
4900
4894
  dtsPlugins
4901
4895
  ]
@@ -4905,12 +4899,7 @@ const generateConfigs = (context, options = {}) => {
4905
4899
  rollupOptions[0].plugins = [
4906
4900
  {
4907
4901
  name: "jiek-plugin-watcher",
4908
- watchChange: (id) => void execa.sendMessage(
4909
- {
4910
- type: "watchChange",
4911
- data: { id, name: JIEK_NAME, path: path$1, input }
4912
- }
4913
- )
4902
+ watchChange: (id) => void publishInEntry("watchChange", { id })
4914
4903
  },
4915
4904
  ...rollupOptions[0].plugins
4916
4905
  ];
@@ -4982,15 +4971,7 @@ function template(packageJSON) {
4982
4971
  }
4983
4972
  })
4984
4973
  );
4985
- void execa.sendMessage(
4986
- {
4987
- type: "init",
4988
- data: {
4989
- leafMap,
4990
- targetsLength: configs.length
4991
- }
4992
- }
4993
- );
4974
+ void publish("init", { leafMap, targetsLength: configs.length });
4994
4975
  return configs.map((c) => ({
4995
4976
  ...COMMON_OPTIONS,
4996
4977
  ...c,
@@ -1,5 +1,5 @@
1
1
  import fs from 'node:fs';
2
- import path, { isAbsolute, relative, resolve, dirname, extname, join } from 'node:path';
2
+ import path, { isAbsolute, relative, resolve, dirname, extname } from 'node:path';
3
3
  import process$1 from 'node:process';
4
4
  import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports, getAllLeafs } from '@jiek/pkger/entrypoints';
5
5
  import { dts } from '@jiek/rollup-plugin-dts';
@@ -7,10 +7,10 @@ import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
7
7
  import commonjs from '@rollup/plugin-commonjs';
8
8
  import json from '@rollup/plugin-json';
9
9
  import { nodeResolve } from '@rollup/plugin-node-resolve';
10
- import { sendMessage } from 'execa';
11
10
  import require$$0 from 'util';
12
11
  import require$$0$1 from 'path';
13
12
  import ts from 'typescript';
13
+ import { sendMessage } from 'execa';
14
14
  import { createRequire as createRequire$1, builtinModules } from 'node:module';
15
15
  import { program } from 'commander';
16
16
  import { load } from 'js-yaml';
@@ -4124,6 +4124,53 @@ function requireMicromatch () {
4124
4124
 
4125
4125
  var micromatchExports = requireMicromatch();
4126
4126
 
4127
+ const publish = async (type, data) => {
4128
+ return sendMessage({ type, data });
4129
+ };
4130
+
4131
+ const {
4132
+ JIEK_ANALYZER
4133
+ } = process$1.env;
4134
+ const ANALYZER = JIEK_ANALYZER != null && JSON.parse(JIEK_ANALYZER);
4135
+ function bundleAnalyzer(modulesResolved) {
4136
+ if (!ANALYZER) {
4137
+ return [];
4138
+ }
4139
+ const defaultSizes = {
4140
+ parsed: "parsed",
4141
+ stat: "stat",
4142
+ gzip: "gzip"
4143
+ }[ANALYZER.size ?? "stat"] ?? "parsed";
4144
+ let ana;
4145
+ async function initAna() {
4146
+ const { adapter, analyzer } = await import('vite-bundle-analyzer');
4147
+ ana = ana ?? adapter(analyzer({
4148
+ defaultSizes,
4149
+ analyzerMode: modulesResolved
4150
+ }));
4151
+ }
4152
+ return [
4153
+ (async () => {
4154
+ await initAna();
4155
+ return {
4156
+ name: "jiek:bundle-analyzer",
4157
+ async closeBundle(...args) {
4158
+ if (typeof ana.closeBundle !== "function")
4159
+ return;
4160
+ return ana.closeBundle?.call(this, ...args);
4161
+ }
4162
+ };
4163
+ })(),
4164
+ (async () => {
4165
+ await initAna();
4166
+ return {
4167
+ ...ana,
4168
+ name: "jiek:bundle-analyzer-output"
4169
+ };
4170
+ })()
4171
+ ];
4172
+ }
4173
+
4127
4174
  const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4128
4175
  const {
4129
4176
  JIEK_OUT_DIR
@@ -4522,7 +4569,6 @@ function externalResolver(jsonOrPath = process.cwd()) {
4522
4569
  }
4523
4570
 
4524
4571
  const {
4525
- JIEK_ANALYZER,
4526
4572
  JIEK_ROOT,
4527
4573
  JIEK_NAME,
4528
4574
  JIEK_BUILDER,
@@ -4545,7 +4591,6 @@ const resolveArrayString = (str) => {
4545
4591
  ];
4546
4592
  return arr?.length ? arr : void 0;
4547
4593
  };
4548
- const ANALYZER = JIEK_ANALYZER && JSON.parse(JIEK_ANALYZER);
4549
4594
  const entries = resolveArrayString(JIEK_ENTRIES)?.map((e) => ({ "index": "." })[e] ?? e);
4550
4595
  const commandExternal = resolveArrayString(JIEK_EXTERNAL)?.map((e) => new RegExp(`^${e}$`));
4551
4596
  const WORKSPACE_ROOT = JIEK_ROOT ?? getWorkspaceDir();
@@ -4620,15 +4665,9 @@ const resolvedMinifyOptions = resolveMinifyOptions(build.output?.minifyOptions ?
4620
4665
  const { type: _resolvedMinifyOptionsType, ...noTypeResolvedMinifyOptions } = resolvedMinifyOptions;
4621
4666
  const resolvedBuilderOptions = resolveBuilderOptions(build.builder ?? BUILDER_OPTIONS);
4622
4667
  const { type: _resolvedBuilderOptionsType, ...noTypeResolvedBuilderOptions } = resolvedBuilderOptions;
4623
- const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE) => {
4668
+ const withMinify = (output, onlyOncePlugins = []) => {
4669
+ const minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE;
4624
4670
  output.plugins = output.plugins ?? [];
4625
- const onlyOncePlugins = [
4626
- // adapter(analyzer({
4627
- // analyzerMode: 'server',
4628
- // analyzerPort: 8888,
4629
- // reportTitle: 'Bundle Analysis'
4630
- // }))
4631
- ];
4632
4671
  if (minify === false) {
4633
4672
  output.plugins.push(...onlyOncePlugins);
4634
4673
  return [output];
@@ -4675,6 +4714,7 @@ const generateConfigs = (context, options = {}) => {
4675
4714
  const isModule = conditionals.includes("import");
4676
4715
  const isCommonJS = conditionals.includes("require");
4677
4716
  const isBrowser = conditionals.includes("browser");
4717
+ const format = isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs";
4678
4718
  const dtsTSConfigPaths = [
4679
4719
  resolveWorkspacePath("tsconfig.json"),
4680
4720
  resolveWorkspacePath("tsconfig.dts.json")
@@ -4712,10 +4752,19 @@ const generateConfigs = (context, options = {}) => {
4712
4752
  delete compilerOptions.composite;
4713
4753
  }
4714
4754
  const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
4715
- const throughEventProps = {
4716
- type: "progress",
4717
- data: { name, path, exportConditions, input }
4718
- };
4755
+ const publishInEntry = (type, data) => (
4756
+ // eslint-disable-next-line ts/no-unsafe-argument
4757
+ void publish(type, {
4758
+ ...{
4759
+ type: format,
4760
+ name,
4761
+ path,
4762
+ exportConditions,
4763
+ input
4764
+ },
4765
+ ...data
4766
+ })
4767
+ );
4719
4768
  const { js: jsPlugins, dts: dtsPlugins } = resolveBuildPlugins(context, build.plugins);
4720
4769
  if (input.includes("**")) {
4721
4770
  throw new Error(
@@ -4753,55 +4802,10 @@ const generateConfigs = (context, options = {}) => {
4753
4802
  ...noTypeResolvedBuilderOptions
4754
4803
  })
4755
4804
  );
4756
- const ana = ANALYZER ? import('vite-bundle-analyzer').then(({ adapter, analyzer }) => {
4757
- const defaultSizes = {
4758
- parsed: "parsed",
4759
- stat: "stat",
4760
- gzip: "gzip"
4761
- }[ANALYZER.size ?? "stat"] ?? "parsed";
4762
- const title = `${join(context.name, context.path)} ${context.conditionals.join(",")}`;
4763
- const filename = title.replace("/", "_").replace(" ", "_");
4764
- switch (ANALYZER.mode ?? "server") {
4765
- case "server":
4766
- return adapter(analyzer({
4767
- defaultSizes,
4768
- analyzerMode: "server",
4769
- analyzerPort: ANALYZER.port ?? "auto",
4770
- openAnalyzer: ANALYZER.open ?? false,
4771
- reportTitle: `Bundle Analysis ${title}`
4772
- }));
4773
- case "json":
4774
- return adapter(analyzer({
4775
- defaultSizes,
4776
- analyzerMode: "json",
4777
- fileName: ANALYZER.dir ? join(ANALYZER.dir, filename) : filename
4778
- }));
4779
- case "static":
4780
- return adapter(analyzer({
4781
- defaultSizes,
4782
- analyzerMode: "static",
4783
- analyzerPort: ANALYZER.port ?? "auto",
4784
- openAnalyzer: ANALYZER.open ?? false,
4785
- reportTitle: `Bundle Analysis ${title}`,
4786
- fileName: ANALYZER.dir ? join(ANALYZER.dir, filename) : filename
4787
- }));
4788
- case void 0: {
4789
- throw new Error("Not implemented yet: undefined case");
4790
- }
4791
- default:
4792
- void sendMessage(
4793
- {
4794
- ...throughEventProps,
4795
- data: {
4796
- ...throughEventProps.data,
4797
- event: "error",
4798
- message: "ANALYZER.mode not supported",
4799
- tags: ["js"]
4800
- }
4801
- }
4802
- );
4803
- }
4804
- }) : void 0;
4805
+ const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
4806
+ const onlyOncePlugins = [
4807
+ anaOutputPlugin
4808
+ ];
4805
4809
  rollupOptions.push({
4806
4810
  input: inputObj,
4807
4811
  external,
@@ -4812,12 +4816,12 @@ const generateConfigs = (context, options = {}) => {
4812
4816
  interop: "auto",
4813
4817
  entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process$1.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix) : output.replace(`${jsOutdir}/`, ""),
4814
4818
  sourcemap,
4815
- format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
4819
+ format,
4816
4820
  strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
4817
4821
  plugins: [
4818
- isFormatEsm(isModule)
4822
+ isFormatEsm(format === "esm")
4819
4823
  ]
4820
- })
4824
+ }, onlyOncePlugins)
4821
4825
  ],
4822
4826
  plugins: [
4823
4827
  ...commonPlugins,
@@ -4832,12 +4836,7 @@ const generateConfigs = (context, options = {}) => {
4832
4836
  builder,
4833
4837
  ana,
4834
4838
  progress({
4835
- onEvent: (event, message) => void sendMessage(
4836
- {
4837
- ...throughEventProps,
4838
- data: { ...throughEventProps.data, event, message, tags: ["js"] }
4839
- }
4840
- )
4839
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
4841
4840
  }),
4842
4841
  jsPlugins
4843
4842
  ]
@@ -4874,12 +4873,7 @@ const generateConfigs = (context, options = {}) => {
4874
4873
  tsconfig: dtsTSConfigPath
4875
4874
  }),
4876
4875
  progress({
4877
- onEvent: (event, message) => void sendMessage(
4878
- {
4879
- ...throughEventProps,
4880
- data: { ...throughEventProps.data, event, message, tags: ["dts"] }
4881
- }
4882
- )
4876
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["dts"] })
4883
4877
  }),
4884
4878
  dtsPlugins
4885
4879
  ]
@@ -4889,12 +4883,7 @@ const generateConfigs = (context, options = {}) => {
4889
4883
  rollupOptions[0].plugins = [
4890
4884
  {
4891
4885
  name: "jiek-plugin-watcher",
4892
- watchChange: (id) => void sendMessage(
4893
- {
4894
- type: "watchChange",
4895
- data: { id, name: JIEK_NAME, path, input }
4896
- }
4897
- )
4886
+ watchChange: (id) => void publishInEntry("watchChange", { id })
4898
4887
  },
4899
4888
  ...rollupOptions[0].plugins
4900
4889
  ];
@@ -4966,15 +4955,7 @@ function template(packageJSON) {
4966
4955
  }
4967
4956
  })
4968
4957
  );
4969
- void sendMessage(
4970
- {
4971
- type: "init",
4972
- data: {
4973
- leafMap,
4974
- targetsLength: configs.length
4975
- }
4976
- }
4977
- );
4958
+ void publish("init", { leafMap, targetsLength: configs.length });
4978
4959
  return configs.map((c) => ({
4979
4960
  ...COMMON_OPTIONS,
4980
4961
  ...c,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.1.12",
4
+ "version": "2.1.13",
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",
@@ -10,6 +10,16 @@
10
10
  "directory": "packages/jiek"
11
11
  },
12
12
  "bugs": "https://github.com/NWYLZW/jiek/issues?q=is%3Aissue+is%3Aopen+jiek",
13
+ "keywords": [
14
+ "cli",
15
+ "zero-config",
16
+ "bundler",
17
+ "library",
18
+ "monorepo",
19
+ "builder",
20
+ "rollup",
21
+ "workspace"
22
+ ],
13
23
  "exports": {
14
24
  "./package.json": "./package.json",
15
25
  ".": {
@@ -55,7 +65,7 @@
55
65
  "rollup-plugin-postcss": "^4.0.2",
56
66
  "rollup-plugin-swc3": "^0.12.1",
57
67
  "typescript": "^4.0.0||^5.0.0",
58
- "vite-bundle-analyzer": "^0.15.1"
68
+ "vite-bundle-analyzer": "^0.15.2"
59
69
  },
60
70
  "dependencies": {
61
71
  "@inquirer/prompts": "^7.1.0",
@@ -71,6 +81,7 @@
71
81
  "execa": "~9.3.1",
72
82
  "js-yaml": "^4.1.0",
73
83
  "jsonc-parser": "^3.2.1",
84
+ "koa": "^2.15.3",
74
85
  "rollup": "^4.0.0",
75
86
  "@jiek/pkger": "^0.2.1",
76
87
  "@jiek/utils": "^0.2.3"
package/src/bridge.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { Module } from '#~/rollup/bundle-analyzer.ts'
2
+
3
+ import { sendMessage } from 'execa'
4
+
5
+ export interface RollupBuildEntryCtx {
6
+ type: 'esm' | 'cjs'
7
+ name: string
8
+ path: string
9
+ exportConditions: string[]
10
+ input: string
11
+ }
12
+
13
+ export interface RollupBuildEventMap {
14
+ init: {
15
+ leafMap: Map<string, string[][]>
16
+ targetsLength: number
17
+ }
18
+ progress: RollupBuildEntryCtx & {
19
+ tags?: string[]
20
+ event?: string
21
+ message?: string
22
+ }
23
+ watchChange: RollupBuildEntryCtx & {
24
+ id: string
25
+ }
26
+ modulesAnalyze: RollupBuildEntryCtx & {
27
+ modules: Module[]
28
+ }
29
+ debug: unknown
30
+ }
31
+
32
+ export type RollupBuildEvent = keyof RollupBuildEventMap extends infer K
33
+ ? K extends infer Item extends keyof RollupBuildEventMap ? {
34
+ type: Item
35
+ data: RollupBuildEventMap[Item]
36
+ }
37
+ : never
38
+ : never
39
+
40
+ export const publish = async <K extends keyof RollupBuildEventMap>(type: K, data: RollupBuildEventMap[K]) => {
41
+ return sendMessage({ type, data })
42
+ }