jiek 2.2.4 → 2.2.5
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.
- package/bin-helper/package.json +1 -0
- package/cli/package.json +1 -0
- package/cli-only-build/package.json +1 -0
- package/dist/cli-only-build.cjs +5 -3
- package/dist/cli-only-build.d.cts +24 -0
- package/dist/cli-only-build.d.ts +24 -0
- package/dist/cli-only-build.js +5 -3
- package/dist/cli.cjs +50 -30
- package/dist/cli.js +50 -30
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/rollup/index.cjs +13 -6
- package/dist/rollup/index.js +13 -6
- package/package.json +3 -3
- package/rollup/package.json +1 -1
- package/src/commands/build.ts +4 -0
- package/src/commands/publish.ts +56 -27
- package/src/rollup/base.ts +24 -0
- package/src/rollup/index.ts +9 -4
- package/src/utils/filterSupport.ts +1 -1
- package/src/utils/getExports.ts +7 -2
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../bin-helper.js","main":"../bin-helper.cjs"}
|
package/cli/package.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../dist/cli.js","main":"../dist/cli.cjs"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"type":"module","module":"../dist/cli-only-build.js","main":"../dist/cli-only-build.cjs"}
|
package/dist/cli-only-build.cjs
CHANGED
@@ -59,7 +59,7 @@ try {
|
|
59
59
|
type$1 = "pnpm";
|
60
60
|
} catch {
|
61
61
|
}
|
62
|
-
function filterPackagesGraph(filters) {
|
62
|
+
async function filterPackagesGraph(filters) {
|
63
63
|
return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
|
64
64
|
}
|
65
65
|
async function getSelectedProjectsGraph(filter = commander.program.getOptionValue("filter")) {
|
@@ -118,7 +118,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
|
|
118
118
|
|
119
119
|
var name = "jiek";
|
120
120
|
var type = "module";
|
121
|
-
var version = "2.2.
|
121
|
+
var version = "2.2.4";
|
122
122
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
123
123
|
var author = "YiJie <yijie4188@gmail.com>";
|
124
124
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -646,7 +646,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
646
646
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
647
647
|
}
|
648
648
|
return String(v);
|
649
|
-
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
649
|
+
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
650
650
|
"--minType <MINTYPE>",
|
651
651
|
'The type of minify, support "builder" and "terser".',
|
652
652
|
(v) => {
|
@@ -673,6 +673,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
673
673
|
verbose,
|
674
674
|
entries: optionEntries,
|
675
675
|
external,
|
676
|
+
noConvert,
|
676
677
|
noJs: withoutJs,
|
677
678
|
noDts: withoutDts,
|
678
679
|
noMin: withoutMin,
|
@@ -735,6 +736,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
735
736
|
JIEK_CLEAN: String(!noClean),
|
736
737
|
JIEK_ENTRIES: entries,
|
737
738
|
JIEK_EXTERNAL: external,
|
739
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
738
740
|
JIEK_WITHOUT_JS: String(withoutJs),
|
739
741
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
740
742
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
package/dist/cli-only-build.d.ts
CHANGED
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
package/dist/cli-only-build.js
CHANGED
@@ -51,7 +51,7 @@ try {
|
|
51
51
|
type$1 = "pnpm";
|
52
52
|
} catch {
|
53
53
|
}
|
54
|
-
function filterPackagesGraph(filters) {
|
54
|
+
async function filterPackagesGraph(filters) {
|
55
55
|
return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
|
56
56
|
}
|
57
57
|
async function getSelectedProjectsGraph(filter = program.getOptionValue("filter")) {
|
@@ -110,7 +110,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
|
|
110
110
|
|
111
111
|
var name = "jiek";
|
112
112
|
var type = "module";
|
113
|
-
var version = "2.2.
|
113
|
+
var version = "2.2.4";
|
114
114
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
115
115
|
var author = "YiJie <yijie4188@gmail.com>";
|
116
116
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -638,7 +638,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
638
638
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
639
639
|
}
|
640
640
|
return String(v);
|
641
|
-
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
641
|
+
}, "esbuild").option("-o, --outdir <OUTDIR>", outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", parseBoolean).option("-nj, --noJs", "Do not output js files.", parseBoolean).option("-nd, --noDts", "Do not output dts files.", parseBoolean).option("-nm, --noMin", "Do not output minify files.", parseBoolean).option(
|
642
642
|
"--minType <MINTYPE>",
|
643
643
|
'The type of minify, support "builder" and "terser".',
|
644
644
|
(v) => {
|
@@ -665,6 +665,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
665
665
|
verbose,
|
666
666
|
entries: optionEntries,
|
667
667
|
external,
|
668
|
+
noConvert,
|
668
669
|
noJs: withoutJs,
|
669
670
|
noDts: withoutDts,
|
670
671
|
noMin: withoutMin,
|
@@ -727,6 +728,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
727
728
|
JIEK_CLEAN: String(!noClean),
|
728
729
|
JIEK_ENTRIES: entries,
|
729
730
|
JIEK_EXTERNAL: external,
|
731
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
730
732
|
JIEK_WITHOUT_JS: String(withoutJs),
|
731
733
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
732
734
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
package/dist/cli.cjs
CHANGED
@@ -4245,11 +4245,13 @@ var micromatchExports = requireMicromatch();
|
|
4245
4245
|
|
4246
4246
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4247
4247
|
const {
|
4248
|
-
JIEK_OUT_DIR
|
4249
|
-
|
4248
|
+
JIEK_OUT_DIR,
|
4249
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4250
|
+
} = process__default.default.env;
|
4250
4251
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4252
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4251
4253
|
function getOutDirs({
|
4252
|
-
cwd =
|
4254
|
+
cwd = process__default.default.cwd(),
|
4253
4255
|
defaultOutdir = OUTDIR,
|
4254
4256
|
config,
|
4255
4257
|
pkgName
|
@@ -4289,7 +4291,7 @@ function getExports({
|
|
4289
4291
|
} = {}
|
4290
4292
|
} = config ?? {};
|
4291
4293
|
const {
|
4292
|
-
crossModuleConvertor =
|
4294
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4293
4295
|
} = build;
|
4294
4296
|
const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
|
4295
4297
|
if (entries) {
|
@@ -4693,33 +4695,51 @@ async function prepublish({ bumper: bumper$1 } = {}) {
|
|
4693
4695
|
fs__default.default.writeFileSync(resolveByDir(jiekTempDir, "package.json"), modifyVersionPackageJSON);
|
4694
4696
|
fs__default.default.writeFileSync(resolveByDir("package.json"), withPublishConfigDirectoryOldJSONString);
|
4695
4697
|
const allBuildFiles = fs__default.default.readdirSync(resolveByDir(resolvedOutdir), { recursive: true }).filter((file) => typeof file === "string").filter((file) => file !== "package.json");
|
4696
|
-
|
4697
|
-
|
4698
|
-
|
4699
|
-
if (
|
4700
|
-
|
4701
|
-
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4705
|
-
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4698
|
+
const resolvedExports = manifest.exports;
|
4699
|
+
Object.keys(resolvedExports).forEach((key) => {
|
4700
|
+
if (key === ".") return;
|
4701
|
+
if (/\.[cm]?js$/.test(key)) return;
|
4702
|
+
const resourceFileSuffixes = [
|
4703
|
+
".d.ts",
|
4704
|
+
".d.mts",
|
4705
|
+
".d.cts",
|
4706
|
+
".css",
|
4707
|
+
".scss",
|
4708
|
+
".sass",
|
4709
|
+
".less",
|
4710
|
+
".styl",
|
4711
|
+
".stylus",
|
4712
|
+
".json",
|
4713
|
+
".json5"
|
4714
|
+
];
|
4715
|
+
if (resourceFileSuffixes.find((suffix) => key.endsWith(suffix))) return;
|
4716
|
+
const value = resolvedExports[key];
|
4717
|
+
const filepath = resolveByDir(resolvedOutdir, key);
|
4718
|
+
fs__default.default.mkdirSync(filepath, { recursive: true });
|
4719
|
+
const pkgJSONPath = resolveByDir(resolvedOutdir, key, "package.json");
|
4720
|
+
const relativePath = Array.from({ length: key.split("/").length - 1 }, () => "..").join("/");
|
4721
|
+
const { type } = manifest;
|
4722
|
+
const pkgJSON = { type };
|
4723
|
+
if ("default" in value) {
|
4724
|
+
pkgJSON[type === "module" ? "module" : "main"] = [
|
4725
|
+
relativePath,
|
4726
|
+
value.default?.replace(/^\.\//, "")
|
4727
|
+
].join("/");
|
4721
4728
|
}
|
4722
|
-
|
4729
|
+
if ("import" in value) {
|
4730
|
+
pkgJSON.module = [
|
4731
|
+
relativePath,
|
4732
|
+
value.import?.replace(/^\.\//, "")
|
4733
|
+
].join("/");
|
4734
|
+
}
|
4735
|
+
if ("require" in value) {
|
4736
|
+
pkgJSON.main = [
|
4737
|
+
relativePath,
|
4738
|
+
value.require?.replace(/^\.\//, "")
|
4739
|
+
].join("/");
|
4740
|
+
}
|
4741
|
+
fs__default.default.writeFileSync(pkgJSONPath, JSON.stringify(pkgJSON));
|
4742
|
+
});
|
4723
4743
|
fs__default.default.mkdirSync(resolveByDir(resolvedOutdir, resolvedOutdir));
|
4724
4744
|
for (const file of allBuildFiles) {
|
4725
4745
|
const filepath = resolveByDir(resolvedOutdir, file);
|
package/dist/cli.js
CHANGED
@@ -4216,11 +4216,13 @@ var micromatchExports = requireMicromatch();
|
|
4216
4216
|
|
4217
4217
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4218
4218
|
const {
|
4219
|
-
JIEK_OUT_DIR
|
4220
|
-
|
4219
|
+
JIEK_OUT_DIR,
|
4220
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4221
|
+
} = process$1.env;
|
4221
4222
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4223
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4222
4224
|
function getOutDirs({
|
4223
|
-
cwd = process.cwd(),
|
4225
|
+
cwd = process$1.cwd(),
|
4224
4226
|
defaultOutdir = OUTDIR,
|
4225
4227
|
config,
|
4226
4228
|
pkgName
|
@@ -4260,7 +4262,7 @@ function getExports({
|
|
4260
4262
|
} = {}
|
4261
4263
|
} = config ?? {};
|
4262
4264
|
const {
|
4263
|
-
crossModuleConvertor =
|
4265
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4264
4266
|
} = build;
|
4265
4267
|
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
|
4266
4268
|
if (entries) {
|
@@ -4664,33 +4666,51 @@ async function prepublish({ bumper } = {}) {
|
|
4664
4666
|
fs.writeFileSync(resolveByDir(jiekTempDir, "package.json"), modifyVersionPackageJSON);
|
4665
4667
|
fs.writeFileSync(resolveByDir("package.json"), withPublishConfigDirectoryOldJSONString);
|
4666
4668
|
const allBuildFiles = fs.readdirSync(resolveByDir(resolvedOutdir), { recursive: true }).filter((file) => typeof file === "string").filter((file) => file !== "package.json");
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
if (
|
4671
|
-
|
4672
|
-
|
4673
|
-
|
4674
|
-
|
4675
|
-
|
4676
|
-
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4680
|
-
|
4681
|
-
|
4682
|
-
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4669
|
+
const resolvedExports = manifest.exports;
|
4670
|
+
Object.keys(resolvedExports).forEach((key) => {
|
4671
|
+
if (key === ".") return;
|
4672
|
+
if (/\.[cm]?js$/.test(key)) return;
|
4673
|
+
const resourceFileSuffixes = [
|
4674
|
+
".d.ts",
|
4675
|
+
".d.mts",
|
4676
|
+
".d.cts",
|
4677
|
+
".css",
|
4678
|
+
".scss",
|
4679
|
+
".sass",
|
4680
|
+
".less",
|
4681
|
+
".styl",
|
4682
|
+
".stylus",
|
4683
|
+
".json",
|
4684
|
+
".json5"
|
4685
|
+
];
|
4686
|
+
if (resourceFileSuffixes.find((suffix) => key.endsWith(suffix))) return;
|
4687
|
+
const value = resolvedExports[key];
|
4688
|
+
const filepath = resolveByDir(resolvedOutdir, key);
|
4689
|
+
fs.mkdirSync(filepath, { recursive: true });
|
4690
|
+
const pkgJSONPath = resolveByDir(resolvedOutdir, key, "package.json");
|
4691
|
+
const relativePath = Array.from({ length: key.split("/").length - 1 }, () => "..").join("/");
|
4692
|
+
const { type } = manifest;
|
4693
|
+
const pkgJSON = { type };
|
4694
|
+
if ("default" in value) {
|
4695
|
+
pkgJSON[type === "module" ? "module" : "main"] = [
|
4696
|
+
relativePath,
|
4697
|
+
value.default?.replace(/^\.\//, "")
|
4698
|
+
].join("/");
|
4692
4699
|
}
|
4693
|
-
|
4700
|
+
if ("import" in value) {
|
4701
|
+
pkgJSON.module = [
|
4702
|
+
relativePath,
|
4703
|
+
value.import?.replace(/^\.\//, "")
|
4704
|
+
].join("/");
|
4705
|
+
}
|
4706
|
+
if ("require" in value) {
|
4707
|
+
pkgJSON.main = [
|
4708
|
+
relativePath,
|
4709
|
+
value.require?.replace(/^\.\//, "")
|
4710
|
+
].join("/");
|
4711
|
+
}
|
4712
|
+
fs.writeFileSync(pkgJSONPath, JSON.stringify(pkgJSON));
|
4713
|
+
});
|
4694
4714
|
fs.mkdirSync(resolveByDir(resolvedOutdir, resolvedOutdir));
|
4695
4715
|
for (const file of allBuildFiles) {
|
4696
4716
|
const filepath = resolveByDir(resolvedOutdir, file);
|
package/dist/index.d.cts
CHANGED
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
package/dist/index.d.ts
CHANGED
@@ -86,6 +86,30 @@ interface TemplateOptions {
|
|
86
86
|
js?: InputPluginOption;
|
87
87
|
dts: InputPluginOption;
|
88
88
|
};
|
89
|
+
/**
|
90
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
91
|
+
*
|
92
|
+
* @example
|
93
|
+
* ```js
|
94
|
+
* {
|
95
|
+
* // import { Promise } from 'es6-promise'
|
96
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
97
|
+
*
|
98
|
+
* // import { Promise as P } from 'es6-promise'
|
99
|
+
* P: [ 'es6-promise', 'Promise' ],
|
100
|
+
*
|
101
|
+
* // import $ from 'jquery'
|
102
|
+
* $: 'jquery',
|
103
|
+
*
|
104
|
+
* // import * as fs from 'fs'
|
105
|
+
* fs: [ 'fs', '*' ],
|
106
|
+
*
|
107
|
+
* // use a local module instead of a third-party one
|
108
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
109
|
+
* }
|
110
|
+
* ```
|
111
|
+
*/
|
112
|
+
injects?: Record<string, string | [string, string]>;
|
89
113
|
}
|
90
114
|
|
91
115
|
declare module 'jiek' {
|
package/dist/rollup/index.cjs
CHANGED
@@ -4185,11 +4185,13 @@ function bundleAnalyzer(modulesResolved) {
|
|
4185
4185
|
|
4186
4186
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4187
4187
|
const {
|
4188
|
-
JIEK_OUT_DIR
|
4189
|
-
|
4188
|
+
JIEK_OUT_DIR,
|
4189
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4190
|
+
} = process__default.default.env;
|
4190
4191
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4192
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4191
4193
|
function getOutDirs({
|
4192
|
-
cwd =
|
4194
|
+
cwd = process__default.default.cwd(),
|
4193
4195
|
defaultOutdir = OUTDIR,
|
4194
4196
|
config,
|
4195
4197
|
pkgName
|
@@ -4229,7 +4231,7 @@ function getExports({
|
|
4229
4231
|
} = {}
|
4230
4232
|
} = config ?? {};
|
4231
4233
|
const {
|
4232
|
-
crossModuleConvertor =
|
4234
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4233
4235
|
} = build;
|
4234
4236
|
const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
|
4235
4237
|
if (entries) {
|
@@ -4865,7 +4867,11 @@ const generateConfigs = (context, options = {}) => {
|
|
4865
4867
|
builder,
|
4866
4868
|
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4867
4869
|
inject__default.default({
|
4868
|
-
|
4870
|
+
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4871
|
+
modules: {
|
4872
|
+
...build.injects ?? {},
|
4873
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4874
|
+
}
|
4869
4875
|
}),
|
4870
4876
|
createRequire(format === "esm"),
|
4871
4877
|
ana,
|
@@ -4877,13 +4883,14 @@ const generateConfigs = (context, options = {}) => {
|
|
4877
4883
|
});
|
4878
4884
|
}
|
4879
4885
|
if (dtsOutput && !WITHOUT_DTS) {
|
4886
|
+
const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap;
|
4880
4887
|
rollupOptions.push({
|
4881
4888
|
input: inputObj,
|
4882
4889
|
external,
|
4883
4890
|
output: [
|
4884
4891
|
{
|
4885
4892
|
dir: dtsOutdir,
|
4886
|
-
sourcemap
|
4893
|
+
sourcemap,
|
4887
4894
|
entryFileNames: (chunkInfo) => Array.isArray(inputObj) ? chunkInfo.facadeModuleId.replace(`${process__default.default.cwd()}/`, "").replace(globCommonDir, pathCommonDir).replace(/(\.[cm]?)ts$/, tsOutputSuffix) : output.replace(`${jsOutdir}/`, "").replace(/(\.[cm]?)js$/, tsOutputSuffix),
|
4888
4895
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
|
4889
4896
|
}
|
package/dist/rollup/index.js
CHANGED
@@ -4171,11 +4171,13 @@ function bundleAnalyzer(modulesResolved) {
|
|
4171
4171
|
|
4172
4172
|
const intersection = (a, b) => new Set([...a].filter((i) => b.has(i)));
|
4173
4173
|
const {
|
4174
|
-
JIEK_OUT_DIR
|
4175
|
-
|
4174
|
+
JIEK_OUT_DIR,
|
4175
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
4176
|
+
} = process$1.env;
|
4176
4177
|
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
4178
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
4177
4179
|
function getOutDirs({
|
4178
|
-
cwd = process.cwd(),
|
4180
|
+
cwd = process$1.cwd(),
|
4179
4181
|
defaultOutdir = OUTDIR,
|
4180
4182
|
config,
|
4181
4183
|
pkgName
|
@@ -4215,7 +4217,7 @@ function getExports({
|
|
4215
4217
|
} = {}
|
4216
4218
|
} = config ?? {};
|
4217
4219
|
const {
|
4218
|
-
crossModuleConvertor =
|
4220
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
4219
4221
|
} = build;
|
4220
4222
|
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
|
4221
4223
|
if (entries) {
|
@@ -4851,7 +4853,11 @@ const generateConfigs = (context, options = {}) => {
|
|
4851
4853
|
builder,
|
4852
4854
|
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
4853
4855
|
inject({
|
4854
|
-
|
4856
|
+
sourceMap: sourcemap === "hidden" ? false : !!sourcemap,
|
4857
|
+
modules: {
|
4858
|
+
...build.injects ?? {},
|
4859
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
4860
|
+
}
|
4855
4861
|
}),
|
4856
4862
|
createRequire(format === "esm"),
|
4857
4863
|
ana,
|
@@ -4863,13 +4869,14 @@ const generateConfigs = (context, options = {}) => {
|
|
4863
4869
|
});
|
4864
4870
|
}
|
4865
4871
|
if (dtsOutput && !WITHOUT_DTS) {
|
4872
|
+
const sourcemap = typeof options?.output?.sourcemap === "object" ? options.output.sourcemap.dts : options?.output?.sourcemap;
|
4866
4873
|
rollupOptions.push({
|
4867
4874
|
input: inputObj,
|
4868
4875
|
external,
|
4869
4876
|
output: [
|
4870
4877
|
{
|
4871
4878
|
dir: dtsOutdir,
|
4872
|
-
sourcemap
|
4879
|
+
sourcemap,
|
4873
4880
|
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),
|
4874
4881
|
strict: typeof options?.output?.strict === "object" ? options.output.strict.dts : options?.output?.strict
|
4875
4882
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.2.
|
4
|
+
"version": "2.2.5",
|
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",
|
@@ -86,8 +86,8 @@
|
|
86
86
|
"jsonc-parser": "^3.2.1",
|
87
87
|
"koa": "^2.15.3",
|
88
88
|
"rollup": "^4.0.0",
|
89
|
-
"@jiek/
|
90
|
-
"@jiek/
|
89
|
+
"@jiek/pkger": "^0.2.1",
|
90
|
+
"@jiek/utils": "^0.2.3"
|
91
91
|
},
|
92
92
|
"peerDependenciesMeta": {
|
93
93
|
"@pnpm/filter-workspace-packages": {
|
package/rollup/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"type":"module","
|
1
|
+
{"type":"module","module":"../dist/rollup/index.js","main":"../dist/rollup/index.cjs"}
|
package/src/commands/build.ts
CHANGED
@@ -72,6 +72,7 @@ interface BuildOptions extends AnalyzerBuildOptions {
|
|
72
72
|
verbose: boolean
|
73
73
|
entries?: string
|
74
74
|
external?: string
|
75
|
+
noConvert: boolean
|
75
76
|
noJs: boolean
|
76
77
|
noDts: boolean
|
77
78
|
noMin: boolean
|
@@ -151,6 +152,7 @@ command = command
|
|
151
152
|
.option('-o, --outdir <OUTDIR>', outdirDescription, String, 'dist')
|
152
153
|
.option('-e, --entries <ENTRIES>', entriesDescription)
|
153
154
|
.option('--external <EXTERNAL>', 'Specify the external dependencies of the package.', String)
|
155
|
+
.option('--noConvert', 'Specify the `crossModuleConvertor` option to false.', parseBoolean)
|
154
156
|
.option('-nj, --noJs', 'Do not output js files.', parseBoolean)
|
155
157
|
.option('-nd, --noDts', 'Do not output dts files.', parseBoolean)
|
156
158
|
.option('-nm, --noMin', 'Do not output minify files.', parseBoolean)
|
@@ -195,6 +197,7 @@ command
|
|
195
197
|
verbose,
|
196
198
|
entries: optionEntries,
|
197
199
|
external,
|
200
|
+
noConvert,
|
198
201
|
noJs: withoutJs,
|
199
202
|
noDts: withoutDts,
|
200
203
|
noMin: withoutMin,
|
@@ -266,6 +269,7 @@ command
|
|
266
269
|
JIEK_CLEAN: String(!noClean),
|
267
270
|
JIEK_ENTRIES: entries,
|
268
271
|
JIEK_EXTERNAL: external,
|
272
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
269
273
|
JIEK_WITHOUT_JS: String(withoutJs),
|
270
274
|
JIEK_WITHOUT_DTS: String(withoutDts),
|
271
275
|
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
package/src/commands/publish.ts
CHANGED
@@ -324,34 +324,63 @@ async function prepublish({ bumper }: {
|
|
324
324
|
.readdirSync(resolveByDir(resolvedOutdir), { recursive: true })
|
325
325
|
.filter(file => typeof file === 'string')
|
326
326
|
.filter(file => file !== 'package.json')
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
327
|
+
const resolvedExports = manifest.exports as Record<string, unknown>
|
328
|
+
Object
|
329
|
+
.keys(resolvedExports)
|
330
|
+
.forEach(key => {
|
331
|
+
if (key === '.') return
|
332
|
+
if (/\.[cm]?js$/.test(key)) return
|
333
|
+
// resource file suffix
|
334
|
+
const resourceFileSuffixes = [
|
335
|
+
'.d.ts',
|
336
|
+
'.d.mts',
|
337
|
+
'.d.cts',
|
338
|
+
'.css',
|
339
|
+
'.scss',
|
340
|
+
'.sass',
|
341
|
+
'.less',
|
342
|
+
'.styl',
|
343
|
+
'.stylus',
|
344
|
+
'.json',
|
345
|
+
'.json5'
|
346
|
+
]
|
347
|
+
if (resourceFileSuffixes.find(suffix => key.endsWith(suffix))) return
|
348
|
+
|
349
|
+
const value = resolvedExports[key] as {
|
350
|
+
import?: string
|
351
|
+
require?: string
|
352
|
+
default?: string
|
352
353
|
}
|
353
|
-
|
354
|
-
|
354
|
+
|
355
|
+
const filepath = resolveByDir(resolvedOutdir, key)
|
356
|
+
|
357
|
+
fs.mkdirSync(filepath, { recursive: true })
|
358
|
+
const pkgJSONPath = resolveByDir(resolvedOutdir, key, 'package.json')
|
359
|
+
const relativePath = Array.from({ length: key.split('/').length - 1 }, () => '..').join('/')
|
360
|
+
const { type } = manifest
|
361
|
+
const pkgJSON: Record<string, unknown> = { type }
|
362
|
+
if ('default' in value) {
|
363
|
+
pkgJSON[
|
364
|
+
type === 'module' ? 'module' : 'main'
|
365
|
+
] = [
|
366
|
+
relativePath,
|
367
|
+
value.default?.replace(/^\.\//, '')
|
368
|
+
].join('/')
|
369
|
+
}
|
370
|
+
if ('import' in value) {
|
371
|
+
pkgJSON.module = [
|
372
|
+
relativePath,
|
373
|
+
value.import?.replace(/^\.\//, '')
|
374
|
+
].join('/')
|
375
|
+
}
|
376
|
+
if ('require' in value) {
|
377
|
+
pkgJSON.main = [
|
378
|
+
relativePath,
|
379
|
+
value.require?.replace(/^\.\//, '')
|
380
|
+
].join('/')
|
381
|
+
}
|
382
|
+
fs.writeFileSync(pkgJSONPath, JSON.stringify(pkgJSON))
|
383
|
+
})
|
355
384
|
fs.mkdirSync(resolveByDir(resolvedOutdir, resolvedOutdir))
|
356
385
|
for (const file of allBuildFiles) {
|
357
386
|
const filepath = resolveByDir(resolvedOutdir, file)
|
package/src/rollup/base.ts
CHANGED
@@ -110,4 +110,28 @@ export interface TemplateOptions {
|
|
110
110
|
js?: InputPluginOption
|
111
111
|
dts: InputPluginOption
|
112
112
|
}
|
113
|
+
/**
|
114
|
+
* https://www.npmjs.com/package/@rollup/plugin-inject#usage
|
115
|
+
*
|
116
|
+
* @example
|
117
|
+
* ```js
|
118
|
+
* {
|
119
|
+
* // import { Promise } from 'es6-promise'
|
120
|
+
* Promise: [ 'es6-promise', 'Promise' ],
|
121
|
+
*
|
122
|
+
* // import { Promise as P } from 'es6-promise'
|
123
|
+
* P: [ 'es6-promise', 'Promise' ],
|
124
|
+
*
|
125
|
+
* // import $ from 'jquery'
|
126
|
+
* $: 'jquery',
|
127
|
+
*
|
128
|
+
* // import * as fs from 'fs'
|
129
|
+
* fs: [ 'fs', '*' ],
|
130
|
+
*
|
131
|
+
* // use a local module instead of a third-party one
|
132
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
133
|
+
* }
|
134
|
+
* ```
|
135
|
+
*/
|
136
|
+
injects?: Record<string, string | [string, string]>
|
113
137
|
}
|
package/src/rollup/index.ts
CHANGED
@@ -486,7 +486,11 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
486
486
|
builder,
|
487
487
|
// inject plugin can't resolve `import type`, so we should register it after the builder plugin
|
488
488
|
inject({
|
489
|
-
|
489
|
+
sourceMap: sourcemap === 'hidden' ? false : !!sourcemap,
|
490
|
+
modules: {
|
491
|
+
...build.injects ?? {},
|
492
|
+
require: CREATE_REQUIRE_VIRTUAL_MODULE_NAME
|
493
|
+
}
|
490
494
|
}),
|
491
495
|
createRequire(format === 'esm'),
|
492
496
|
ana,
|
@@ -499,15 +503,16 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
|
|
499
503
|
}
|
500
504
|
|
501
505
|
if (dtsOutput && !WITHOUT_DTS) {
|
506
|
+
const sourcemap = typeof options?.output?.sourcemap === 'object'
|
507
|
+
? options.output.sourcemap.dts
|
508
|
+
: options?.output?.sourcemap
|
502
509
|
rollupOptions.push({
|
503
510
|
input: inputObj,
|
504
511
|
external,
|
505
512
|
output: [
|
506
513
|
{
|
507
514
|
dir: dtsOutdir,
|
508
|
-
sourcemap
|
509
|
-
? options.output.sourcemap.dts
|
510
|
-
: options?.output?.sourcemap,
|
515
|
+
sourcemap,
|
511
516
|
entryFileNames: (chunkInfo) => (
|
512
517
|
Array.isArray(inputObj)
|
513
518
|
? chunkInfo.facadeModuleId!.replace(`${process.cwd()}/`, '')
|
@@ -24,7 +24,7 @@ export interface ProjectsGraph {
|
|
24
24
|
}>
|
25
25
|
}
|
26
26
|
|
27
|
-
export function filterPackagesGraph(filters: string[]): Promise<ProjectsGraph[]> {
|
27
|
+
export async function filterPackagesGraph(filters: string[]): Promise<ProjectsGraph[]> {
|
28
28
|
return Promise.all(filters.map(async filter => getSelectedProjectsGraph(filter)))
|
29
29
|
}
|
30
30
|
|
package/src/utils/getExports.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { isAbsolute, relative, resolve } from 'node:path'
|
2
|
+
import process from 'node:process'
|
2
3
|
|
3
4
|
import {
|
4
5
|
type Entrypoints2ExportsOptions,
|
@@ -14,10 +15,14 @@ import { isMatch } from 'micromatch'
|
|
14
15
|
const intersection = <T>(a: Set<T>, b: Set<T>) => new Set([...a].filter(i => b.has(i)))
|
15
16
|
|
16
17
|
const {
|
17
|
-
JIEK_OUT_DIR
|
18
|
+
JIEK_OUT_DIR,
|
19
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
18
20
|
} = process.env
|
19
21
|
|
20
22
|
const OUTDIR = JIEK_OUT_DIR ?? 'dist'
|
23
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === undefined
|
24
|
+
? true
|
25
|
+
: JIEK_CROSS_MODULE_CONVERTOR === 'true'
|
21
26
|
|
22
27
|
export function getOutDirs({
|
23
28
|
cwd = process.cwd(),
|
@@ -85,7 +90,7 @@ export function getExports({
|
|
85
90
|
} = {}
|
86
91
|
} = config ?? {}
|
87
92
|
const {
|
88
|
-
crossModuleConvertor =
|
93
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
89
94
|
} = build
|
90
95
|
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints)
|
91
96
|
if (entries) {
|