jiek 2.1.11 → 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.
@@ -1,19 +1,22 @@
1
1
  import fs from 'node:fs';
2
- import path, { resolve, isAbsolute, relative, dirname, extname } from 'node:path';
2
+ import path, { isAbsolute, relative, resolve, dirname, extname } from 'node:path';
3
+ import process$1 from 'node:process';
3
4
  import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports, getAllLeafs } from '@jiek/pkger/entrypoints';
4
5
  import { dts } from '@jiek/rollup-plugin-dts';
5
6
  import { isWorkspaceDir, getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
6
7
  import commonjs from '@rollup/plugin-commonjs';
7
8
  import json from '@rollup/plugin-json';
8
9
  import { nodeResolve } from '@rollup/plugin-node-resolve';
9
- import { sendMessage } from 'execa';
10
10
  import require$$0 from 'util';
11
11
  import require$$0$1 from 'path';
12
12
  import ts from 'typescript';
13
- import { createRequire, builtinModules } from 'node:module';
13
+ import { sendMessage } from 'execa';
14
+ import { createRequire as createRequire$1, builtinModules } from 'node:module';
14
15
  import { program } from 'commander';
15
16
  import { load } from 'js-yaml';
16
17
  import { parse } from 'jsonc-parser';
18
+ import inject from '@rollup/plugin-inject';
19
+ import replace from '@rollup/plugin-replace';
17
20
 
18
21
  var utils$1 = {};
19
22
 
@@ -4121,15 +4124,52 @@ function requireMicromatch () {
4121
4124
 
4122
4125
  var micromatchExports = requireMicromatch();
4123
4126
 
4124
- const recusiveListFiles = (dir) => fs.readdirSync(dir).reduce((acc, file) => {
4125
- const filePath = resolve(dir, file);
4126
- if (fs.statSync(filePath).isDirectory()) {
4127
- if (filePath.endsWith("/node_modules"))
4128
- return acc;
4129
- return [...acc, ...recusiveListFiles(filePath)];
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 [];
4130
4138
  }
4131
- return [...acc, filePath];
4132
- }, []);
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
+ }
4133
4173
 
4134
4174
  const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
4135
4175
  const {
@@ -4233,7 +4273,7 @@ function getRoot() {
4233
4273
 
4234
4274
  let type = "";
4235
4275
  try {
4236
- const require = createRequire(import.meta.url);
4276
+ const require = createRequire$1(import.meta.url);
4237
4277
  require.resolve("@pnpm/filter-workspace-packages");
4238
4278
  type = "pnpm";
4239
4279
  } catch {
@@ -4264,7 +4304,7 @@ function getWD() {
4264
4304
  return { wd, notWorkspace };
4265
4305
  }
4266
4306
 
4267
- const require$1 = createRequire(import.meta.url);
4307
+ const require$1 = createRequire$1(import.meta.url);
4268
4308
  function packageIsExist(name) {
4269
4309
  try {
4270
4310
  require$1.resolve(name);
@@ -4287,7 +4327,7 @@ for (const register of registers) {
4287
4327
  }
4288
4328
  }
4289
4329
 
4290
- const require = createRequire(import.meta.url);
4330
+ const require = createRequire$1(import.meta.url);
4291
4331
  let configName = "jiek.config";
4292
4332
  function getConfigPath(root, dir) {
4293
4333
  const isSupportTsLoader = !!tsRegisterName;
@@ -4370,6 +4410,16 @@ function loadConfig(dirOrOptions) {
4370
4410
  return module.default ?? module;
4371
4411
  }
4372
4412
 
4413
+ const recusiveListFiles = (dir) => fs.readdirSync(dir).reduce((acc, file) => {
4414
+ const filePath = resolve(dir, file);
4415
+ if (fs.statSync(filePath).isDirectory()) {
4416
+ if (filePath.endsWith("/node_modules"))
4417
+ return acc;
4418
+ return [...acc, ...recusiveListFiles(filePath)];
4419
+ }
4420
+ return [...acc, filePath];
4421
+ }, []);
4422
+
4373
4423
  const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
4374
4424
  const getExtendTSConfig = (tsconfigPath) => {
4375
4425
  tsconfigPath = resolve(tsconfigPath);
@@ -4429,6 +4479,44 @@ const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
4429
4479
  return tsconfig.compilerOptions;
4430
4480
  };
4431
4481
 
4482
+ const virtualModuleName = "jiek:create-require";
4483
+ const isEsmVariableName = `IS_ESM${Math.random().toString(36).slice(2)}`;
4484
+ const INSERT_STR = `
4485
+ import { createRequire } from 'node:module'
4486
+
4487
+ export default (
4488
+ ${isEsmVariableName}
4489
+ ? /* @__PURE__ */ createRequire(import.meta.url)
4490
+ : require
4491
+ )
4492
+ `.trim();
4493
+ var createRequire = () => ({
4494
+ ...inject({
4495
+ require: virtualModuleName
4496
+ }),
4497
+ name: "create-require",
4498
+ resolveId: (source) => source === virtualModuleName ? source : null,
4499
+ load: (id) => {
4500
+ if (id !== virtualModuleName) {
4501
+ return null;
4502
+ }
4503
+ return INSERT_STR;
4504
+ }
4505
+ });
4506
+ const isFormatEsm = (isEsm) => {
4507
+ const handler = replace({
4508
+ [isEsmVariableName]: isEsm
4509
+ }).renderChunk;
4510
+ return {
4511
+ name: "create-require-insert-format",
4512
+ // Pick out renderChunk because it's used as an output plugin
4513
+ renderChunk: {
4514
+ order: "pre",
4515
+ handler: typeof handler === "function" ? handler : handler.handler
4516
+ }
4517
+ };
4518
+ };
4519
+
4432
4520
  var progress = (options = {}) => {
4433
4521
  const { onEvent } = options;
4434
4522
  return {
@@ -4494,7 +4582,7 @@ const {
4494
4582
  JIEK_ONLY_MINIFY,
4495
4583
  JIEK_TSCONFIG,
4496
4584
  JIEK_DTSCONFIG
4497
- } = process.env;
4585
+ } = process$1.env;
4498
4586
  const resolveArrayString = (str) => {
4499
4587
  const arr = [
4500
4588
  ...new Set(
@@ -4577,10 +4665,15 @@ const resolvedMinifyOptions = resolveMinifyOptions(build.output?.minifyOptions ?
4577
4665
  const { type: _resolvedMinifyOptionsType, ...noTypeResolvedMinifyOptions } = resolvedMinifyOptions;
4578
4666
  const resolvedBuilderOptions = resolveBuilderOptions(build.builder ?? BUILDER_OPTIONS);
4579
4667
  const { type: _resolvedBuilderOptionsType, ...noTypeResolvedBuilderOptions } = resolvedBuilderOptions;
4580
- const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE) => {
4581
- if (minify === false)
4668
+ const withMinify = (output, onlyOncePlugins = []) => {
4669
+ const minify = build?.output?.minify ?? MINIFY_DEFAULT_VALUE;
4670
+ output.plugins = output.plugins ?? [];
4671
+ if (minify === false) {
4672
+ output.plugins.push(...onlyOncePlugins);
4582
4673
  return [output];
4674
+ }
4583
4675
  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));
4676
+ const notOnlyOncePlugins = output.plugins;
4584
4677
  return minify === "only-minify" ? [{
4585
4678
  ...output,
4586
4679
  // TODO replace suffix when pubish to npm and the `build.output.minify` is 'only-minify'
@@ -4589,7 +4682,7 @@ const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VAL
4589
4682
  throw new Error("entryFileNames must be a function");
4590
4683
  })(),
4591
4684
  plugins: [
4592
- ...output.plugins ?? [],
4685
+ ...notOnlyOncePlugins,
4593
4686
  minifyPlugin
4594
4687
  ]
4595
4688
  }] : [
@@ -4601,7 +4694,7 @@ const withMinify = (output, minify = build?.output?.minify ?? MINIFY_DEFAULT_VAL
4601
4694
  })(),
4602
4695
  file: output.file?.replace(/(\.[cm]?js)$/, ".min$1"),
4603
4696
  plugins: [
4604
- ...output.plugins ?? [],
4697
+ ...notOnlyOncePlugins,
4605
4698
  minifyPlugin
4606
4699
  ]
4607
4700
  }
@@ -4621,6 +4714,7 @@ const generateConfigs = (context, options = {}) => {
4621
4714
  const isModule = conditionals.includes("import");
4622
4715
  const isCommonJS = conditionals.includes("require");
4623
4716
  const isBrowser = conditionals.includes("browser");
4717
+ const format = isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs";
4624
4718
  const dtsTSConfigPaths = [
4625
4719
  resolveWorkspacePath("tsconfig.json"),
4626
4720
  resolveWorkspacePath("tsconfig.dts.json")
@@ -4658,17 +4752,26 @@ const generateConfigs = (context, options = {}) => {
4658
4752
  delete compilerOptions.composite;
4659
4753
  }
4660
4754
  const exportConditions = [...conditionals, ...compilerOptions.customConditions ?? []];
4661
- const throughEventProps = {
4662
- type: "progress",
4663
- data: { name, path, exportConditions, input }
4664
- };
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
+ );
4665
4768
  const { js: jsPlugins, dts: dtsPlugins } = resolveBuildPlugins(context, build.plugins);
4666
4769
  if (input.includes("**")) {
4667
4770
  throw new Error(
4668
4771
  'input should not include "**", please read the [documentation](https://nodejs.org/api/packages.html#subpath-patterns).'
4669
4772
  );
4670
4773
  }
4671
- const inputObj = !input.includes("*") ? input : recusiveListFiles(process.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => relative(process.cwd(), p)).filter((p) => micromatchExports.isMatch(p, input.slice(2)));
4774
+ const inputObj = !input.includes("*") ? input : recusiveListFiles(process$1.cwd()).filter((p) => /(?<!\.d)\.[cm]?tsx?$/.test(p)).map((p) => relative(process$1.cwd(), p)).filter((p) => micromatchExports.isMatch(p, input.slice(2)));
4672
4775
  const globCommonDir = input.includes("*") ? input.split("*")[0].replace("./", "") : "";
4673
4776
  const pathCommonDir = path.includes("*") ? path.split("*")[0].replace("./", "") : "";
4674
4777
  if (globCommonDir.length > 0 && pathCommonDir.length === 0 || globCommonDir.length === 0 && pathCommonDir.length > 0) {
@@ -4699,6 +4802,10 @@ const generateConfigs = (context, options = {}) => {
4699
4802
  ...noTypeResolvedBuilderOptions
4700
4803
  })
4701
4804
  );
4805
+ const [ana, anaOutputPlugin] = bundleAnalyzer((modules) => void publishInEntry("modulesAnalyze", { modules }));
4806
+ const onlyOncePlugins = [
4807
+ anaOutputPlugin
4808
+ ];
4702
4809
  rollupOptions.push({
4703
4810
  input: inputObj,
4704
4811
  external,
@@ -4707,11 +4814,14 @@ const generateConfigs = (context, options = {}) => {
4707
4814
  dir: jsOutdir,
4708
4815
  name,
4709
4816
  interop: "auto",
4710
- entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix) : output.replace(`${jsOutdir}/`, ""),
4817
+ entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process$1.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, jsOutputSuffix) : output.replace(`${jsOutdir}/`, ""),
4711
4818
  sourcemap,
4712
- format: isModule ? "esm" : isCommonJS ? "cjs" : isBrowser ? "umd" : pkgIsModule ? "esm" : "cjs",
4713
- strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict
4714
- })
4819
+ format,
4820
+ strict: typeof options?.output?.strict === "object" ? options.output.strict.js : options?.output?.strict,
4821
+ plugins: [
4822
+ isFormatEsm(format === "esm")
4823
+ ]
4824
+ }, onlyOncePlugins)
4715
4825
  ],
4716
4826
  plugins: [
4717
4827
  ...commonPlugins,
@@ -4721,15 +4831,12 @@ const generateConfigs = (context, options = {}) => {
4721
4831
  minimize: true
4722
4832
  })
4723
4833
  ).catch(() => void 0),
4724
- builder,
4725
4834
  commonjs(),
4835
+ createRequire(),
4836
+ builder,
4837
+ ana,
4726
4838
  progress({
4727
- onEvent: (event, message) => sendMessage(
4728
- {
4729
- ...throughEventProps,
4730
- data: { ...throughEventProps.data, event, message, tags: ["js"] }
4731
- }
4732
- )
4839
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["js"] })
4733
4840
  }),
4734
4841
  jsPlugins
4735
4842
  ]
@@ -4743,7 +4850,7 @@ const generateConfigs = (context, options = {}) => {
4743
4850
  {
4744
4851
  dir: dtsOutdir,
4745
4852
  sourcemap: typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap,
4746
- entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix) : output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, tsOutputSuffix),
4853
+ entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process$1.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix) : output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, tsOutputSuffix),
4747
4854
  strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
4748
4855
  }
4749
4856
  ],
@@ -4766,12 +4873,7 @@ const generateConfigs = (context, options = {}) => {
4766
4873
  tsconfig: dtsTSConfigPath
4767
4874
  }),
4768
4875
  progress({
4769
- onEvent: (event, message) => sendMessage(
4770
- {
4771
- ...throughEventProps,
4772
- data: { ...throughEventProps.data, event, message, tags: ["dts"] }
4773
- }
4774
- )
4876
+ onEvent: (event, message) => void publishInEntry("progress", { event, message, tags: ["dts"] })
4775
4877
  }),
4776
4878
  dtsPlugins
4777
4879
  ]
@@ -4781,12 +4883,7 @@ const generateConfigs = (context, options = {}) => {
4781
4883
  rollupOptions[0].plugins = [
4782
4884
  {
4783
4885
  name: "jiek-plugin-watcher",
4784
- watchChange: (id) => sendMessage(
4785
- {
4786
- type: "watchChange",
4787
- data: { id, name: JIEK_NAME, path, input }
4788
- }
4789
- )
4886
+ watchChange: (id) => void publishInEntry("watchChange", { id })
4790
4887
  },
4791
4888
  ...rollupOptions[0].plugins
4792
4889
  ];
@@ -4858,15 +4955,7 @@ function template(packageJSON) {
4858
4955
  }
4859
4956
  })
4860
4957
  );
4861
- sendMessage(
4862
- {
4863
- type: "init",
4864
- data: {
4865
- leafMap,
4866
- targetsLength: configs.length
4867
- }
4868
- }
4869
- );
4958
+ void publish("init", { leafMap, targetsLength: configs.length });
4870
4959
  return configs.map((c) => ({
4871
4960
  ...COMMON_OPTIONS,
4872
4961
  ...c,
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.1.11",
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
+ "homepage": "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme",
7
8
  "repository": {
8
9
  "url": "nwylzw/jiek",
9
10
  "directory": "packages/jiek"
10
11
  },
11
- "homepage": "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme",
12
12
  "bugs": "https://github.com/NWYLZW/jiek/issues?q=is%3Aissue+is%3Aopen+jiek",
13
- "bin": {
14
- "jiek": "bin/jiek.js",
15
- "jk": "bin/jiek.js",
16
- "jiek-build": "bin/jiek-build.js",
17
- "jb": "bin/jiek-build.js"
18
- },
13
+ "keywords": [
14
+ "cli",
15
+ "zero-config",
16
+ "bundler",
17
+ "library",
18
+ "monorepo",
19
+ "builder",
20
+ "rollup",
21
+ "workspace"
22
+ ],
19
23
  "exports": {
20
24
  "./package.json": "./package.json",
21
25
  ".": {
@@ -23,6 +27,10 @@
23
27
  "require": "./dist/index.cjs",
24
28
  "default": "./dist/index.js"
25
29
  },
30
+ "./bin-helper": {
31
+ "require": "./bin-helper.cjs",
32
+ "default": "./bin-helper.js"
33
+ },
26
34
  "./cli": {
27
35
  "jiek/__source__": "./src/cli.ts",
28
36
  "require": "./dist/cli.cjs",
@@ -42,54 +50,47 @@
42
50
  "imports": {
43
51
  "#~/*": "./src/*"
44
52
  },
53
+ "bin": {
54
+ "jiek": "bin/jiek.js",
55
+ "jk": "bin/jiek.js",
56
+ "jiek-build": "bin/jiek-build.js",
57
+ "jb": "bin/jiek-build.js"
58
+ },
59
+ "peerDependencies": {
60
+ "@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
61
+ "@rollup/plugin-terser": "^0.4.4",
62
+ "esbuild-register": "^3.5.0",
63
+ "postcss": "^8.4.47",
64
+ "rollup-plugin-esbuild": "^6.1.0",
65
+ "rollup-plugin-postcss": "^4.0.2",
66
+ "rollup-plugin-swc3": "^0.12.1",
67
+ "typescript": "^4.0.0||^5.0.0",
68
+ "vite-bundle-analyzer": "^0.15.2"
69
+ },
45
70
  "dependencies": {
46
- "@jiek/rollup-plugin-dts": "^6.2.1",
47
71
  "@inquirer/prompts": "^7.1.0",
72
+ "@jiek/rollup-plugin-dts": "^6.2.1",
48
73
  "@rollup/plugin-commonjs": "^28.0.0",
74
+ "@rollup/plugin-inject": "^5.0.5",
49
75
  "@rollup/plugin-json": "^6.0.1",
50
76
  "@rollup/plugin-node-resolve": "^15.3.0",
77
+ "@rollup/plugin-replace": "^6.0.1",
51
78
  "cli-progress": "^3.12.0",
52
79
  "commander": "^12.0.0",
53
80
  "detect-indent": "^6.1.0",
54
- "execa": "9.3.1",
81
+ "execa": "~9.3.1",
55
82
  "js-yaml": "^4.1.0",
56
83
  "jsonc-parser": "^3.2.1",
57
- "rollup": "4.13.2",
84
+ "koa": "^2.15.3",
85
+ "rollup": "^4.0.0",
58
86
  "@jiek/pkger": "^0.2.1",
59
87
  "@jiek/utils": "^0.2.3"
60
88
  },
61
- "peerDependencies": {
62
- "@rollup/plugin-terser": "^0.4.4",
63
- "@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0",
64
- "esbuild-register": "^3.5.0",
65
- "postcss": "^8.4.47",
66
- "rollup-plugin-postcss": "^4.0.2",
67
- "rollup-plugin-esbuild": "^6.1.0",
68
- "rollup-plugin-swc3": "^0.12.1",
69
- "typescript": "^4.0.0||^5.0.0"
70
- },
71
- "devDependencies": {
72
- "@npm/types": "^1.0.2",
73
- "@pnpm/filter-workspace-packages": "^7.2.13",
74
- "@pnpm/workspace.pkgs-graph": "^2.0.15",
75
- "@rollup/plugin-terser": "^0.4.4",
76
- "@types/cli-progress": "^3.11.5",
77
- "@types/inquirer": "^9.0.7",
78
- "@types/js-yaml": "^4.0.9",
79
- "@types/micromatch": "^4.0.6",
80
- "esbuild-register": "^3.5.0",
81
- "micromatch": "^4.0.5",
82
- "node-sass": "^9.0.0",
83
- "postcss": "^8.4.47",
84
- "rollup-plugin-postcss": "^4.0.2",
85
- "rollup-plugin-esbuild": "^6.1.0",
86
- "rollup-plugin-swc3": "^0.12.1"
87
- },
88
89
  "peerDependenciesMeta": {
89
- "@rollup/plugin-terser": {
90
+ "@pnpm/filter-workspace-packages": {
90
91
  "optional": true
91
92
  },
92
- "@pnpm/filter-workspace-packages": {
93
+ "@rollup/plugin-terser": {
93
94
  "optional": true
94
95
  },
95
96
  "esbuild-register": {
@@ -98,10 +99,10 @@
98
99
  "postcss": {
99
100
  "optional": true
100
101
  },
101
- "rollup-plugin-postcss": {
102
+ "rollup-plugin-esbuild": {
102
103
  "optional": true
103
104
  },
104
- "rollup-plugin-esbuild": {
105
+ "rollup-plugin-postcss": {
105
106
  "optional": true
106
107
  },
107
108
  "rollup-plugin-swc3": {
@@ -109,6 +110,9 @@
109
110
  },
110
111
  "typescript": {
111
112
  "optional": true
113
+ },
114
+ "vite-bundle-analyzer": {
115
+ "optional": true
112
116
  }
113
117
  },
114
118
  "scripts": {
File without changes
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
+ }
@@ -2,8 +2,10 @@ import './utils/filterSupport'
2
2
  import './commands/base'
3
3
  import './commands/build'
4
4
 
5
+ import parseArgv from './parseArgv'
6
+
7
+ import process from 'node:process'
8
+
5
9
  if (process.env.JIEK_IS_ONLY_BUILD === 'true') {
6
- import('commander').then(({ program }) => {
7
- program.parse(process.argv)
8
- })
10
+ parseArgv()
9
11
  }
package/src/cli.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './commands/publish'
2
2
  import 'jiek/cli-only-build'
3
3
 
4
- import { program } from 'commander'
4
+ import parseArgv from './parseArgv'
5
5
 
6
- program.parse(process.argv)
6
+ parseArgv()
@@ -10,6 +10,7 @@ program
10
10
  .version(pkg.version)
11
11
  .description(`${pkg.description} - Version ${pkg.version}`)
12
12
  .option('-c, --config-path <configPath>', 'Custom jiek config path')
13
+ .option('--env.<name>=<value>', 'Set the environment variable.')
13
14
 
14
15
  if (type !== '' && IS_WORKSPACE) {
15
16
  program