jiek 2.3.0 → 2.3.1

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.
@@ -37,7 +37,7 @@ var Koa__default = /*#__PURE__*/_interopDefault(Koa);
37
37
 
38
38
  var name = "jiek";
39
39
  var type = "module";
40
- var version = "2.2.7-alpha.5";
40
+ var version = "2.3.0";
41
41
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
42
42
  var author = "YiJie <yijie4188@gmail.com>";
43
43
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
@@ -469,6 +469,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
469
469
  "Only output minify files, but dts files will still be output, it only replaces the js files.",
470
470
  parseBoolean
471
471
  );
472
+ command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
472
473
  command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
473
474
  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);
474
475
  command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
@@ -491,7 +492,8 @@ command.action(async (commandFiltersOrEntries, options) => {
491
492
  noClean,
492
493
  onlyMin,
493
494
  tsconfig,
494
- dtsconfig
495
+ dtsconfig,
496
+ skipJS
495
497
  } = options;
496
498
  const resolvedType = type ?? DEFAULT_BUILDER_TYPE;
497
499
  if (!withoutJs) {
@@ -554,6 +556,7 @@ command.action(async (commandFiltersOrEntries, options) => {
554
556
  JIEK_MINIFY_TYPE: minifyType,
555
557
  JIEK_TSCONFIG: tsconfig,
556
558
  JIEK_DTSCONFIG: dtsconfig,
559
+ JIEK_SKIP_JS: String(skipJS),
557
560
  JIEK_FEATURES: JSON.stringify({
558
561
  keepImportAttributes: options["features.keepImportAttributes"]
559
562
  }),
@@ -6,6 +6,10 @@ import 'rollup';
6
6
 
7
7
  declare module 'jiek' {
8
8
  interface Config {
9
+ /**
10
+ * Skip entries which end with '.js'.
11
+ */
12
+ skipJS?: boolean;
9
13
  build?: TemplateOptions & {
10
14
  /**
11
15
  * Whether to run in silent mode, only active when configured in the workspace root or cwd.
@@ -6,6 +6,10 @@ import 'rollup';
6
6
 
7
7
  declare module 'jiek' {
8
8
  interface Config {
9
+ /**
10
+ * Skip entries which end with '.js'.
11
+ */
12
+ skipJS?: boolean;
9
13
  build?: TemplateOptions & {
10
14
  /**
11
15
  * Whether to run in silent mode, only active when configured in the workspace root or cwd.
@@ -30,7 +30,7 @@ import 'node:stream/promises';
30
30
 
31
31
  var name = "jiek";
32
32
  var type = "module";
33
- var version = "2.2.7-alpha.5";
33
+ var version = "2.3.0";
34
34
  var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
35
35
  var author = "YiJie <yijie4188@gmail.com>";
36
36
  var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
@@ -462,6 +462,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
462
462
  "Only output minify files, but dts files will still be output, it only replaces the js files.",
463
463
  parseBoolean
464
464
  );
465
+ command = command.option("--skipJS", 'Skip entries which end with ".js".', parseBoolean);
465
466
  command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
466
467
  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);
467
468
  command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
@@ -484,7 +485,8 @@ command.action(async (commandFiltersOrEntries, options) => {
484
485
  noClean,
485
486
  onlyMin,
486
487
  tsconfig,
487
- dtsconfig
488
+ dtsconfig,
489
+ skipJS
488
490
  } = options;
489
491
  const resolvedType = type ?? DEFAULT_BUILDER_TYPE;
490
492
  if (!withoutJs) {
@@ -547,6 +549,7 @@ command.action(async (commandFiltersOrEntries, options) => {
547
549
  JIEK_MINIFY_TYPE: minifyType,
548
550
  JIEK_TSCONFIG: tsconfig,
549
551
  JIEK_DTSCONFIG: dtsconfig,
552
+ JIEK_SKIP_JS: String(skipJS),
550
553
  JIEK_FEATURES: JSON.stringify({
551
554
  keepImportAttributes: options["features.keepImportAttributes"]
552
555
  }),
@@ -49,7 +49,8 @@ function resolveExports({
49
49
  // FIXME dts support
50
50
  outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
51
51
  noFilter,
52
- isPublish
52
+ isPublish,
53
+ skipJS
53
54
  }) {
54
55
  const {
55
56
  build = {},
@@ -61,7 +62,9 @@ function resolveExports({
61
62
  const {
62
63
  crossModuleConvertor = crossModuleConvertorDefault
63
64
  } = build;
64
- const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
65
+ const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1, {
66
+ allowJS: !skipJS
67
+ });
65
68
  if (entries) {
66
69
  Object.entries(resolvedEntrypoints).forEach(([key]) => {
67
70
  if (!entries.some((e) => index.micromatchExports.isMatch(key, e, { matchBase: true }))) {
@@ -75,7 +78,9 @@ function resolveExports({
75
78
  skipValue: [
76
79
  // ignore values that filename starts with `.jk-noentry`
77
80
  /(^|\/)\.jk-noentry/,
78
- ...entrypoints.DEFAULT_SKIP_VALUES
81
+ ...entrypoints.getDefaultSkipValues({
82
+ allowJS: !skipJS
83
+ })
79
84
  ]
80
85
  }
81
86
  );
@@ -108,7 +113,8 @@ function resolveExports({
108
113
  withSource: isPublish ? withSource : void 0,
109
114
  withConditional: {
110
115
  ...crossModuleWithConditional
111
- }
116
+ },
117
+ allowJS: !skipJS
112
118
  }),
113
119
  outdir
114
120
  ];
@@ -20,7 +20,8 @@ interface ResolveExportsOptions {
20
20
  defaultOutdir?: string;
21
21
  noFilter?: boolean;
22
22
  isPublish?: boolean;
23
+ skipJS?: boolean;
23
24
  }
24
- declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
25
+ declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish, skipJS }: ResolveExportsOptions): readonly [any, any, string];
25
26
 
26
27
  export { type ResolveExportsOptions, getOutDirs, resolveExports };
@@ -20,7 +20,8 @@ interface ResolveExportsOptions {
20
20
  defaultOutdir?: string;
21
21
  noFilter?: boolean;
22
22
  isPublish?: boolean;
23
+ skipJS?: boolean;
23
24
  }
24
- declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
25
+ declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish, skipJS }: ResolveExportsOptions): readonly [any, any, string];
25
26
 
26
27
  export { type ResolveExportsOptions, getOutDirs, resolveExports };
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, relative, resolve } from 'node:path';
2
2
  import process from 'node:process';
3
- import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports } from '@jiek/pkger/entrypoints';
3
+ import { resolveEntrypoints, filterLeafs, getDefaultSkipValues, entrypoints2Exports } from '@jiek/pkger/entrypoints';
4
4
  import { m as micromatchExports } from '../.chunks/index.B6RQz1DZ.js';
5
5
  import { intersection } from './intersection.js';
6
6
  import 'util';
@@ -43,7 +43,8 @@ function resolveExports({
43
43
  // FIXME dts support
44
44
  outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
45
45
  noFilter,
46
- isPublish
46
+ isPublish,
47
+ skipJS
47
48
  }) {
48
49
  const {
49
50
  build = {},
@@ -55,7 +56,9 @@ function resolveExports({
55
56
  const {
56
57
  crossModuleConvertor = crossModuleConvertorDefault
57
58
  } = build;
58
- const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
59
+ const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints, {
60
+ allowJS: !skipJS
61
+ });
59
62
  if (entries) {
60
63
  Object.entries(resolvedEntrypoints).forEach(([key]) => {
61
64
  if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
@@ -69,7 +72,9 @@ function resolveExports({
69
72
  skipValue: [
70
73
  // ignore values that filename starts with `.jk-noentry`
71
74
  /(^|\/)\.jk-noentry/,
72
- ...DEFAULT_SKIP_VALUES
75
+ ...getDefaultSkipValues({
76
+ allowJS: !skipJS
77
+ })
73
78
  ]
74
79
  }
75
80
  );
@@ -102,7 +107,8 @@ function resolveExports({
102
107
  withSource: isPublish ? withSource : void 0,
103
108
  withConditional: {
104
109
  ...crossModuleWithConditional
105
- }
110
+ },
111
+ allowJS: !skipJS
106
112
  }),
107
113
  outdir
108
114
  ];
@@ -62,7 +62,14 @@ async function forEachSelectedProjectsGraphEntries(callback) {
62
62
  callback(dir, manifest);
63
63
  }
64
64
  }
65
- commander.program.command("publish").description(description).aliases(["pub", "p"]).option("-b, --bumper <bumper>", "bump version", "patch").option("-no-b, --no-bumper", "no bump version").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").action(async ({ outdir, bumper: bumper$1 }) => {
65
+ const attachPublishOptions = (command) => command.option("-b, --bumper <bumper>", "bump version", "patch").option("-no-b, --no-bumper", "no bump version").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("--skipJS", 'skip entries which end with ".js"');
66
+ attachPublishOptions(
67
+ commander.program.command("publish").description(description).aliases(["pub", "p"])
68
+ ).action(async ({
69
+ outdir,
70
+ bumper: bumper$1,
71
+ skipJS
72
+ }) => {
66
73
  let shouldPassThrough = false;
67
74
  const passThroughOptions = process__default.default.argv.reduce(
68
75
  (acc, value) => {
@@ -88,18 +95,24 @@ commander.program.command("publish").description(description).aliases(["pub", "p
88
95
  env: {
89
96
  ...process__default.default.env,
90
97
  JIEK_PUBLISH_OUTDIR: JSON.stringify(outdir),
91
- JIEK_PUBLISH_BUMPER: JSON.stringify(bumper$1)
98
+ JIEK_PUBLISH_BUMPER: JSON.stringify(bumper$1),
99
+ JIEK_PUBLISH_SKIP_JS: JSON.stringify(skipJS)
92
100
  }
93
101
  });
94
102
  });
95
103
  });
96
- async function prepublish({ bumper: bumper$1 } = {}) {
104
+ async function prepublish({
105
+ bumper: bumper$1,
106
+ skipJS
107
+ }) {
97
108
  const {
98
109
  JIEK_PUBLISH_OUTDIR: outdirEnv,
99
- JIEK_PUBLISH_BUMPER: bumperEnv
110
+ JIEK_PUBLISH_BUMPER: bumperEnv,
111
+ JIEK_PUBLISH_SKIP_JS: skipJSEnv
100
112
  } = process__default.default.env;
101
113
  const outdir = outdirEnv ? JSON.parse(outdirEnv) : "dist";
102
114
  bumper$1 = bumper$1 ?? (bumperEnv ? JSON.parse(bumperEnv) : false);
115
+ skipJS = skipJS ?? (skipJSEnv ? JSON.parse(skipJSEnv) : void 0);
103
116
  const generateNewManifest = (dir, manifest, config) => {
104
117
  const {
105
118
  name,
@@ -118,7 +131,8 @@ async function prepublish({ bumper: bumper$1 } = {}) {
118
131
  config,
119
132
  dir,
120
133
  noFilter: true,
121
- isPublish: true
134
+ isPublish: true,
135
+ skipJS: skipJS ?? config.skipJS
122
136
  };
123
137
  let resolvedOutdir = outdir;
124
138
  if (entrypoints) {
@@ -297,7 +311,7 @@ async function prepublish({ bumper: bumper$1 } = {}) {
297
311
  tabSize: indent.length,
298
312
  insertSpaces: true
299
313
  };
300
- const newVersion = bumper$1 ? bumper.bump(oldJSON.version, bumper$1 === true ? "patch" : bumper$1) : oldJSON.version;
314
+ const newVersion = bumper$1 ? bumper.bump(oldJSON.version, bumper$1) : oldJSON.version;
301
315
  const modifyVersionPackageJSON = jsoncParser.applyEdits(
302
316
  oldJSONString,
303
317
  jsoncParser.modify(oldJSONString, ["version"], newVersion, { formattingOptions })
@@ -442,7 +456,7 @@ async function prepublish({ bumper: bumper$1 } = {}) {
442
456
  }
443
457
  });
444
458
  }
445
- async function postpublish() {
459
+ async function postpublish({}) {
446
460
  await forEachSelectedProjectsGraphEntries((dir) => {
447
461
  const jiekTempDir = path__default.default.resolve(dir, "node_modules/.jiek/.tmp");
448
462
  const packageJSONPath = path__default.default.resolve(dir, "package.json");
@@ -462,21 +476,6 @@ async function postpublish() {
462
476
  }
463
477
  });
464
478
  }
465
- commander.program.action(async () => {
466
- const {
467
- npm_lifecycle_event: NPM_LIFECYCLE_EVENT
468
- } = process__default.default.env;
469
- switch (NPM_LIFECYCLE_EVENT) {
470
- case "prepublish":
471
- await prepublish();
472
- break;
473
- case "postpublish":
474
- await postpublish();
475
- break;
476
- default:
477
- commander.program.help();
478
- }
479
- });
480
479
  const prepublishDescription = `
481
480
  Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` script in package.json, the command will automatically run \`jk prepublish\`.
482
481
  .e.g
@@ -486,7 +485,9 @@ Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` scrip
486
485
  }
487
486
  }
488
487
  `.trim();
489
- commander.program.command("prepublish").description(prepublishDescription).option("-b, --bumper <bumper>", "bump version").option("-no-b, --no-bumper", "no bump version").action(prepublish);
488
+ attachPublishOptions(
489
+ commander.program.command("prepublish").description(prepublishDescription)
490
+ ).action(prepublish);
490
491
  const postpublishDescription = `
491
492
  Restore package.json after publish, you can add \`jk\` to the \`postpublish\` script in package.json, the command will automatically run \`jk postpublish\`.
492
493
  .e.g
@@ -496,6 +497,26 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
496
497
  }
497
498
  }
498
499
  `.trim();
499
- commander.program.command("postpublish").description(postpublishDescription).action(postpublish);
500
+ attachPublishOptions(
501
+ commander.program.command("postpublish").description(postpublishDescription)
502
+ ).action(postpublish);
503
+ const {
504
+ npm_lifecycle_event: NPM_LIFECYCLE_EVENT
505
+ } = process__default.default.env;
506
+ if (NPM_LIFECYCLE_EVENT && [
507
+ "prepublish",
508
+ "postpublish"
509
+ ].includes(NPM_LIFECYCLE_EVENT)) {
510
+ attachPublishOptions(commander.program).action(async (options) => {
511
+ switch (NPM_LIFECYCLE_EVENT) {
512
+ case "prepublish":
513
+ await prepublish(options);
514
+ break;
515
+ case "postpublish":
516
+ await postpublish(options);
517
+ break;
518
+ }
519
+ });
520
+ }
500
521
 
501
522
  parseArgv__default.default();
package/dist/index.d.cts CHANGED
@@ -2,6 +2,10 @@ import { TemplateOptions } from '#~/rollup/base';
2
2
 
3
3
  declare module 'jiek' {
4
4
  interface Config {
5
+ /**
6
+ * Skip entries which end with '.js'.
7
+ */
8
+ skipJS?: boolean;
5
9
  build?: TemplateOptions & {
6
10
  /**
7
11
  * Whether to run in silent mode, only active when configured in the workspace root or cwd.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,10 @@ import { TemplateOptions } from '#~/rollup/base';
2
2
 
3
3
  declare module 'jiek' {
4
4
  interface Config {
5
+ /**
6
+ * Skip entries which end with '.js'.
7
+ */
8
+ skipJS?: boolean;
5
9
  build?: TemplateOptions & {
6
10
  /**
7
11
  * Whether to run in silent mode, only active when configured in the workspace root or cwd.
@@ -124,6 +124,7 @@ const {
124
124
  JIEK_ONLY_MINIFY,
125
125
  JIEK_TSCONFIG,
126
126
  JIEK_DTSCONFIG,
127
+ JIEK_SKIP_JS,
127
128
  JIEK_FEATURES
128
129
  } = process__default.default.env;
129
130
  const resolveArrayString = (str) => {
@@ -147,6 +148,7 @@ const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
147
148
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
148
149
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
149
150
  const CLEAN = JIEK_CLEAN === "true";
151
+ const SKIP_JS = JIEK_SKIP_JS === "false" ? false : JIEK_SKIP_JS === "true" ? true : void 0;
150
152
  const FEATURES = JSON.parse(JIEK_FEATURES ?? "{}");
151
153
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
152
154
  const BUILDER_OPTIONS = {
@@ -158,7 +160,11 @@ const MINIFY_OPTIONS = {
158
160
  const config = loadConfig.loadConfig({
159
161
  root: WORKSPACE_ROOT
160
162
  }) ?? {};
161
- const { experimental, build = {} } = config;
163
+ const {
164
+ experimental,
165
+ skipJS,
166
+ build = {}
167
+ } = config;
162
168
  const { js: jsOutdir, dts: dtsOutdir } = resolveExports.getOutDirs({
163
169
  config,
164
170
  pkgName: JIEK_NAME
@@ -583,7 +589,8 @@ function template(packageJSON) {
583
589
  entries,
584
590
  pkgName: JIEK_NAME,
585
591
  outdir: jsOutdir,
586
- config
592
+ config,
593
+ skipJS: skipJS ?? SKIP_JS
587
594
  });
588
595
  entrypoints.getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
589
596
  if (typeof value === "string") {
@@ -626,7 +633,8 @@ function template(packageJSON) {
626
633
  pkgIsModule,
627
634
  pkgName: JIEK_NAME,
628
635
  outdir: `${jsOutdir}/.internal`,
629
- config
636
+ config,
637
+ skipJS: SKIP_JS ?? skipJS
630
638
  });
631
639
  entrypoints.getAllLeafs(filteredResolvedInternalEntrypoints, ({ keys, value }) => {
632
640
  if (typeof value === "string") {
@@ -664,7 +672,29 @@ function template(packageJSON) {
664
672
  Array.isArray(inputOptions.input) ? inputOptions.input : [inputOptions.input],
665
673
  internalModules
666
674
  )];
675
+ if (inputOptions.input.length === 0) {
676
+ inputOptions.input = "__jiek_empty__";
677
+ const plugins = await inputOptions.plugins;
678
+ if (!Array.isArray(plugins)) {
679
+ throw new TypeError("plugins is not an array");
680
+ }
681
+ inputOptions.plugins = plugins.filter(
682
+ (p) => typeof p !== "object" ? true : p === null ? true : "name" in p && p.name === "jiek:loadInternalModules"
683
+ );
684
+ }
667
685
  return inputOptions;
686
+ },
687
+ resolveId: {
688
+ order: "post",
689
+ handler(id) {
690
+ if (id === "__jiek_empty__") return id;
691
+ }
692
+ },
693
+ load: {
694
+ order: "post",
695
+ handler(id) {
696
+ if (id === "__jiek_empty__") return "";
697
+ }
668
698
  }
669
699
  }
670
700
  ],
@@ -113,6 +113,7 @@ const {
113
113
  JIEK_ONLY_MINIFY,
114
114
  JIEK_TSCONFIG,
115
115
  JIEK_DTSCONFIG,
116
+ JIEK_SKIP_JS,
116
117
  JIEK_FEATURES
117
118
  } = process.env;
118
119
  const resolveArrayString = (str) => {
@@ -136,6 +137,7 @@ const WITHOUT_DTS = JIEK_WITHOUT_DTS === "true";
136
137
  const WITHOUT_MINIFY = JIEK_WITHOUT_MINIFY === "true";
137
138
  const ONLY_MINIFY = JIEK_ONLY_MINIFY === "true";
138
139
  const CLEAN = JIEK_CLEAN === "true";
140
+ const SKIP_JS = JIEK_SKIP_JS === "false" ? false : JIEK_SKIP_JS === "true" ? true : void 0;
139
141
  const FEATURES = JSON.parse(JIEK_FEATURES ?? "{}");
140
142
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY ? false : ONLY_MINIFY ? "only-minify" : true;
141
143
  const BUILDER_OPTIONS = {
@@ -147,7 +149,11 @@ const MINIFY_OPTIONS = {
147
149
  const config = loadConfig({
148
150
  root: WORKSPACE_ROOT
149
151
  }) ?? {};
150
- const { experimental, build = {} } = config;
152
+ const {
153
+ experimental,
154
+ skipJS,
155
+ build = {}
156
+ } = config;
151
157
  const { js: jsOutdir, dts: dtsOutdir } = getOutDirs({
152
158
  config,
153
159
  pkgName: JIEK_NAME
@@ -572,7 +578,8 @@ function template(packageJSON) {
572
578
  entries,
573
579
  pkgName: JIEK_NAME,
574
580
  outdir: jsOutdir,
575
- config
581
+ config,
582
+ skipJS: skipJS ?? SKIP_JS
576
583
  });
577
584
  getAllLeafs(filteredResolvedEntrypoints, ({ keys, value }) => {
578
585
  if (typeof value === "string") {
@@ -615,7 +622,8 @@ function template(packageJSON) {
615
622
  pkgIsModule,
616
623
  pkgName: JIEK_NAME,
617
624
  outdir: `${jsOutdir}/.internal`,
618
- config
625
+ config,
626
+ skipJS: SKIP_JS ?? skipJS
619
627
  });
620
628
  getAllLeafs(filteredResolvedInternalEntrypoints, ({ keys, value }) => {
621
629
  if (typeof value === "string") {
@@ -653,7 +661,29 @@ function template(packageJSON) {
653
661
  Array.isArray(inputOptions.input) ? inputOptions.input : [inputOptions.input],
654
662
  internalModules
655
663
  )];
664
+ if (inputOptions.input.length === 0) {
665
+ inputOptions.input = "__jiek_empty__";
666
+ const plugins = await inputOptions.plugins;
667
+ if (!Array.isArray(plugins)) {
668
+ throw new TypeError("plugins is not an array");
669
+ }
670
+ inputOptions.plugins = plugins.filter(
671
+ (p) => typeof p !== "object" ? true : p === null ? true : "name" in p && p.name === "jiek:loadInternalModules"
672
+ );
673
+ }
656
674
  return inputOptions;
675
+ },
676
+ resolveId: {
677
+ order: "post",
678
+ handler(id) {
679
+ if (id === "__jiek_empty__") return id;
680
+ }
681
+ },
682
+ load: {
683
+ order: "post",
684
+ handler(id) {
685
+ if (id === "__jiek_empty__") return "";
686
+ }
657
687
  }
658
688
  }
659
689
  ],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "2.3.0",
4
+ "version": "2.3.1",
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",
@@ -75,7 +75,7 @@
75
75
  "jsonc-parser": "^3.2.1",
76
76
  "koa": "^2.15.3",
77
77
  "rollup": "^4.0.0",
78
- "@jiek/pkger": "^0.2.1",
78
+ "@jiek/pkger": "^0.2.2",
79
79
  "@jiek/utils": "^0.2.3"
80
80
  },
81
81
  "publishConfig": {
@@ -5,6 +5,7 @@ import process from 'node:process'
5
5
  import { MultiBar, Presets } from 'cli-progress'
6
6
  import { program } from 'commander'
7
7
  import { execaCommand } from 'execa'
8
+ import type { Config } from 'jiek'
8
9
 
9
10
  import type { RollupBuildEvent } from '#~/bridge'
10
11
  import type { AnalyzerBuildOptions } from '#~/commands/build/analyzer'
@@ -24,6 +25,10 @@ import { tsRegisterName } from '#~/utils/tsRegister'
24
25
 
25
26
  declare module 'jiek' {
26
27
  interface Config {
28
+ /**
29
+ * Skip entries which end with '.js'.
30
+ */
31
+ skipJS?: boolean
27
32
  build?: TemplateOptions & {
28
33
  /**
29
34
  * Whether to run in silent mode, only active when configured in the workspace root or cwd.
@@ -51,7 +56,13 @@ If you want to through the options to the \`rollup\` command, you can pass the o
51
56
  ${isDefault ? 'This command is the default command.' : ''}
52
57
  `.trim()
53
58
 
54
- interface BuildOptions extends AnalyzerBuildOptions {
59
+ interface BuildOptions extends
60
+ AnalyzerBuildOptions,
61
+ Pick<
62
+ Config,
63
+ 'skipJS'
64
+ >
65
+ {
55
66
  /**
56
67
  * Auto-detect the builder from the installed dependencies.
57
68
  * If the builder is not installed, it will prompt the user to install it.
@@ -179,6 +190,9 @@ command = command
179
190
  parseBoolean
180
191
  )
181
192
 
193
+ command = command
194
+ .option('--skipJS', 'Skip entries which end with ".js".', parseBoolean)
195
+
182
196
  command = command
183
197
  .option('--features.keepImportAttributes', 'Keep the import attributes in the output.')
184
198
 
@@ -214,7 +228,8 @@ command
214
228
  noClean,
215
229
  onlyMin,
216
230
  tsconfig,
217
- dtsconfig
231
+ dtsconfig,
232
+ skipJS
218
233
  } = options
219
234
  const resolvedType = type ?? DEFAULT_BUILDER_TYPE
220
235
  if (!withoutJs) {
@@ -286,6 +301,7 @@ command
286
301
  JIEK_MINIFY_TYPE: minifyType,
287
302
  JIEK_TSCONFIG: tsconfig,
288
303
  JIEK_DTSCONFIG: dtsconfig,
304
+ JIEK_SKIP_JS: String(skipJS),
289
305
  JIEK_FEATURES: JSON.stringify({
290
306
  keepImportAttributes: options['features.keepImportAttributes']
291
307
  }),
@@ -5,7 +5,7 @@ import path from 'node:path'
5
5
  import process from 'node:process'
6
6
 
7
7
  import { type BumperType, TAGS, bump } from '@jiek/utils/bumper'
8
- import { program } from 'commander'
8
+ import { type Command, program } from 'commander'
9
9
  import detectIndent from 'detect-indent'
10
10
  import type { Config } from 'jiek'
11
11
  import type { JSONPath } from 'jsonc-parser'
@@ -60,17 +60,33 @@ async function forEachSelectedProjectsGraphEntries(
60
60
  }
61
61
  }
62
62
 
63
- program
64
- .command('publish')
65
- .description(description)
66
- .aliases(['pub', 'p'])
67
- .option('-b, --bumper <bumper>', 'bump version', 'patch')
68
- .option('-no-b, --no-bumper', 'no bump version')
69
- .option('-o, --outdir <OUTDIR>', outdirDescription, String, 'dist')
70
- .action(async ({ outdir, bumper }: {
71
- outdir?: string
72
- bumper: false | BumperType
73
- }) => {
63
+ interface PublishOptions {
64
+ outdir?: string
65
+ bumper: false | BumperType
66
+ /**
67
+ * Skip entries which end with '.js'.
68
+ */
69
+ skipJS: boolean
70
+ }
71
+
72
+ const attachPublishOptions = (command: Command) =>
73
+ command
74
+ .option('-b, --bumper <bumper>', 'bump version', 'patch')
75
+ .option('-no-b, --no-bumper', 'no bump version')
76
+ .option('-o, --outdir <OUTDIR>', outdirDescription, String, 'dist')
77
+ .option('--skipJS', 'skip entries which end with ".js"')
78
+
79
+ attachPublishOptions(
80
+ program
81
+ .command('publish')
82
+ .description(description)
83
+ .aliases(['pub', 'p'])
84
+ )
85
+ .action(async ({
86
+ outdir,
87
+ bumper,
88
+ skipJS
89
+ }: PublishOptions) => {
74
90
  let shouldPassThrough = false
75
91
 
76
92
  const passThroughOptions = process.argv
@@ -99,18 +115,21 @@ program
99
115
  env: {
100
116
  ...process.env,
101
117
  JIEK_PUBLISH_OUTDIR: JSON.stringify(outdir),
102
- JIEK_PUBLISH_BUMPER: JSON.stringify(bumper)
118
+ JIEK_PUBLISH_BUMPER: JSON.stringify(bumper),
119
+ JIEK_PUBLISH_SKIP_JS: JSON.stringify(skipJS)
103
120
  }
104
121
  })
105
122
  })
106
123
  })
107
124
 
108
- async function prepublish({ bumper }: {
109
- bumper?: boolean | BumperType
110
- } = {}) {
125
+ async function prepublish({
126
+ bumper,
127
+ skipJS
128
+ }: PublishOptions) {
111
129
  const {
112
130
  JIEK_PUBLISH_OUTDIR: outdirEnv,
113
- JIEK_PUBLISH_BUMPER: bumperEnv
131
+ JIEK_PUBLISH_BUMPER: bumperEnv,
132
+ JIEK_PUBLISH_SKIP_JS: skipJSEnv
114
133
  } = process.env
115
134
  const outdir = outdirEnv
116
135
  ? JSON.parse(outdirEnv) as string
@@ -118,6 +137,9 @@ async function prepublish({ bumper }: {
118
137
  bumper = bumper ?? (
119
138
  bumperEnv ? JSON.parse(bumperEnv) as string | boolean : false
120
139
  )
140
+ skipJS = skipJS ?? (
141
+ skipJSEnv ? JSON.parse(skipJSEnv) as boolean : undefined
142
+ )
121
143
 
122
144
  const generateNewManifest = (
123
145
  dir: string,
@@ -142,7 +164,8 @@ async function prepublish({ bumper }: {
142
164
  config,
143
165
  dir,
144
166
  noFilter: true,
145
- isPublish: true
167
+ isPublish: true,
168
+ skipJS: skipJS ?? config.skipJS
146
169
  } satisfies Partial<ResolveExportsOptions>
147
170
  let resolvedOutdir = outdir
148
171
  if (entrypoints) {
@@ -346,7 +369,7 @@ async function prepublish({ bumper }: {
346
369
  }
347
370
 
348
371
  const newVersion = bumper
349
- ? bump(oldJSON.version, bumper === true ? 'patch' : bumper)
372
+ ? bump(oldJSON.version, bumper)
350
373
  : oldJSON.version
351
374
  const modifyVersionPackageJSON = applyEdits(
352
375
  oldJSONString,
@@ -522,7 +545,8 @@ async function prepublish({ bumper }: {
522
545
  })
523
546
  }
524
547
 
525
- async function postpublish() {
548
+ // eslint-disable-next-line no-empty-pattern
549
+ async function postpublish({}: PublishOptions) {
526
550
  await forEachSelectedProjectsGraphEntries(dir => {
527
551
  const jiekTempDir = path.resolve(dir, 'node_modules/.jiek/.tmp')
528
552
  const packageJSONPath = path.resolve(dir, 'package.json')
@@ -548,24 +572,6 @@ async function postpublish() {
548
572
  })
549
573
  }
550
574
 
551
- program
552
- .action(async () => {
553
- const {
554
- npm_lifecycle_event: NPM_LIFECYCLE_EVENT
555
- } = process.env
556
- // eslint-disable-next-line ts/switch-exhaustiveness-check
557
- switch (NPM_LIFECYCLE_EVENT) {
558
- case 'prepublish':
559
- await prepublish()
560
- break
561
- case 'postpublish':
562
- await postpublish()
563
- break
564
- default:
565
- program.help()
566
- }
567
- })
568
-
569
575
  const prepublishDescription = `
570
576
  Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` script in package.json, the command will automatically run \`jk prepublish\`.
571
577
  .e.g
@@ -575,11 +581,11 @@ Prepare package.json for publish, you can add \`jk\` to the \`prepublish\` scrip
575
581
  }
576
582
  }
577
583
  `.trim()
578
- program
579
- .command('prepublish')
580
- .description(prepublishDescription)
581
- .option('-b, --bumper <bumper>', 'bump version')
582
- .option('-no-b, --no-bumper', 'no bump version')
584
+ attachPublishOptions(
585
+ program
586
+ .command('prepublish')
587
+ .description(prepublishDescription)
588
+ )
583
589
  .action(prepublish)
584
590
 
585
591
  const postpublishDescription = `
@@ -591,7 +597,32 @@ Restore package.json after publish, you can add \`jk\` to the \`postpublish\` sc
591
597
  }
592
598
  }
593
599
  `.trim()
594
- program
595
- .command('postpublish')
596
- .description(postpublishDescription)
600
+ attachPublishOptions(
601
+ program
602
+ .command('postpublish')
603
+ .description(postpublishDescription)
604
+ )
597
605
  .action(postpublish)
606
+
607
+ const {
608
+ npm_lifecycle_event: NPM_LIFECYCLE_EVENT
609
+ } = process.env
610
+
611
+ if (
612
+ NPM_LIFECYCLE_EVENT && [
613
+ 'prepublish',
614
+ 'postpublish'
615
+ ].includes(NPM_LIFECYCLE_EVENT)
616
+ ) {
617
+ attachPublishOptions(program)
618
+ .action(async (options: PublishOptions) => {
619
+ switch (NPM_LIFECYCLE_EVENT) {
620
+ case 'prepublish':
621
+ await prepublish(options)
622
+ break
623
+ case 'postpublish':
624
+ await postpublish(options)
625
+ break
626
+ }
627
+ })
628
+ }
@@ -46,6 +46,7 @@ const {
46
46
  JIEK_ONLY_MINIFY,
47
47
  JIEK_TSCONFIG,
48
48
  JIEK_DTSCONFIG,
49
+ JIEK_SKIP_JS,
49
50
  JIEK_FEATURES
50
51
  } = process.env
51
52
 
@@ -82,6 +83,12 @@ const ONLY_MINIFY = JIEK_ONLY_MINIFY === 'true'
82
83
 
83
84
  const CLEAN = JIEK_CLEAN === 'true'
84
85
 
86
+ const SKIP_JS = JIEK_SKIP_JS === 'false'
87
+ ? false
88
+ : JIEK_SKIP_JS === 'true'
89
+ ? true
90
+ : undefined
91
+
85
92
  const FEATURES = JSON.parse(JIEK_FEATURES ?? '{}') as Record<string, unknown>
86
93
 
87
94
  const MINIFY_DEFAULT_VALUE = WITHOUT_MINIFY
@@ -105,7 +112,11 @@ const MINIFY_OPTIONS = {
105
112
  const config = loadConfig({
106
113
  root: WORKSPACE_ROOT
107
114
  }) ?? {}
108
- const { experimental, build = {} } = config
115
+ const {
116
+ experimental,
117
+ skipJS,
118
+ build = {}
119
+ } = config
109
120
  const { js: jsOutdir, dts: dtsOutdir } = getOutDirs({
110
121
  config,
111
122
  pkgName: JIEK_NAME
@@ -698,7 +709,8 @@ export function template(packageJSON: PackageJSON): RollupOptions[] {
698
709
  entries,
699
710
  pkgName: JIEK_NAME!,
700
711
  outdir: jsOutdir,
701
- config
712
+ config,
713
+ skipJS: skipJS ?? SKIP_JS
702
714
  })
703
715
  getAllLeafs(filteredResolvedEntrypoints as RecursiveRecord<string>, ({ keys, value }) => {
704
716
  if (typeof value === 'string') {
@@ -748,7 +760,8 @@ export function template(packageJSON: PackageJSON): RollupOptions[] {
748
760
  pkgIsModule,
749
761
  pkgName: JIEK_NAME!,
750
762
  outdir: `${jsOutdir}/.internal`,
751
- config
763
+ config,
764
+ skipJS: SKIP_JS ?? skipJS
752
765
  })
753
766
  getAllLeafs(filteredResolvedInternalEntrypoints as RecursiveRecord<string>, ({ keys, value }) => {
754
767
  if (typeof value === 'string') {
@@ -792,7 +805,34 @@ export function template(packageJSON: PackageJSON): RollupOptions[] {
792
805
  : [inputOptions.input as string],
793
806
  internalModules
794
807
  )]
808
+ if (inputOptions.input.length === 0) {
809
+ inputOptions.input = '__jiek_empty__'
810
+ const plugins = await inputOptions.plugins
811
+ if (!Array.isArray(plugins)) {
812
+ throw new TypeError('plugins is not an array')
813
+ }
814
+ inputOptions.plugins = plugins.filter(
815
+ p =>
816
+ typeof p !== 'object'
817
+ ? true
818
+ : p === null
819
+ ? true
820
+ : 'name' in p && p.name === 'jiek:loadInternalModules'
821
+ )
822
+ }
795
823
  return inputOptions
824
+ },
825
+ resolveId: {
826
+ order: 'post',
827
+ handler(id) {
828
+ if (id === '__jiek_empty__') return id
829
+ }
830
+ },
831
+ load: {
832
+ order: 'post',
833
+ handler(id) {
834
+ if (id === '__jiek_empty__') return ''
835
+ }
796
836
  }
797
837
  }
798
838
  ],
@@ -4,9 +4,9 @@ import process from 'node:process'
4
4
  import {
5
5
  type Entrypoints2ExportsOptions,
6
6
  type RecursiveRecord,
7
- DEFAULT_SKIP_VALUES,
8
7
  entrypoints2Exports,
9
8
  filterLeafs,
9
+ getDefaultSkipValues,
10
10
  resolveEntrypoints
11
11
  } from '@jiek/pkger/entrypoints'
12
12
  import type { Config } from 'jiek'
@@ -69,6 +69,7 @@ export interface ResolveExportsOptions {
69
69
  defaultOutdir?: string
70
70
  noFilter?: boolean
71
71
  isPublish?: boolean
72
+ skipJS?: boolean
72
73
  }
73
74
 
74
75
  export function resolveExports({
@@ -82,7 +83,8 @@ export function resolveExports({
82
83
  // FIXME dts support
83
84
  outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
84
85
  noFilter,
85
- isPublish
86
+ isPublish,
87
+ skipJS
86
88
  }: ResolveExportsOptions) {
87
89
  const {
88
90
  build = {},
@@ -94,7 +96,9 @@ export function resolveExports({
94
96
  const {
95
97
  crossModuleConvertor = crossModuleConvertorDefault
96
98
  } = build
97
- const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints)
99
+ const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints, {
100
+ allowJS: !skipJS
101
+ })
98
102
  if (entries) {
99
103
  Object
100
104
  .entries(resolvedEntrypoints)
@@ -110,7 +114,9 @@ export function resolveExports({
110
114
  skipValue: [
111
115
  // ignore values that filename starts with `.jk-noentry`
112
116
  /(^|\/)\.jk-noentry/,
113
- ...DEFAULT_SKIP_VALUES
117
+ ...getDefaultSkipValues({
118
+ allowJS: !skipJS
119
+ })
114
120
  ]
115
121
  }
116
122
  )
@@ -151,7 +157,8 @@ export function resolveExports({
151
157
  withSource: isPublish ? withSource : undefined,
152
158
  withConditional: {
153
159
  ...crossModuleWithConditional
154
- }
160
+ },
161
+ allowJS: !skipJS
155
162
  }),
156
163
  outdir
157
164
  ] as const