jiek 2.2.7 → 2.3.0
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/build.cjs +2 -0
- package/bin/index.cjs +2 -0
- package/bin-helper/index.cjs +19 -31
- package/dist/.internal/.chunks/filterSupport.4rM7f6jB.cjs +114 -0
- package/dist/.internal/.chunks/filterSupport.BXWpLBpT.js +104 -0
- package/dist/{cli.js → .internal/.chunks/index.B6RQz1DZ.js} +1 -737
- package/dist/.internal/.chunks/index.BHuJRlvZ.js +9059 -0
- package/dist/.internal/.chunks/index.Daihq2aI.cjs +9071 -0
- package/dist/{cli.cjs → .internal/.chunks/index.DlHFuTjM.cjs} +1 -759
- package/dist/.internal/.chunks/loadConfig.CFfzkm_p.js +110 -0
- package/dist/.internal/.chunks/loadConfig.OOKddvHF.cjs +117 -0
- package/dist/{cli-only-build.cjs → .internal/bin/common.cjs} +225 -444
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/{cli-only-build.js → .internal/bin/common.js} +220 -438
- package/dist/.internal/bin/parseArgv.cjs +33 -0
- package/dist/.internal/bin/parseArgv.d.cts +5 -0
- package/dist/.internal/bin/parseArgv.d.ts +5 -0
- package/dist/.internal/bin/parseArgv.js +27 -0
- package/dist/.internal/bridge.cjs +30 -0
- package/dist/.internal/bridge.d.cts +39 -0
- package/dist/.internal/bridge.d.ts +39 -0
- package/dist/.internal/bridge.js +27 -0
- package/dist/.internal/rollup/base.cjs +10 -0
- package/dist/{cli-only-build.d.cts → .internal/rollup/base.d.cts} +8 -15
- package/dist/{cli-only-build.d.ts → .internal/rollup/base.d.ts} +8 -15
- package/dist/.internal/rollup/base.js +7 -0
- package/dist/.internal/rollup/bundle-analyzer.cjs +51 -0
- package/dist/.internal/rollup/bundle-analyzer.d.cts +92 -0
- package/dist/.internal/rollup/bundle-analyzer.d.ts +92 -0
- package/dist/.internal/rollup/bundle-analyzer.js +45 -0
- package/dist/.internal/utils/filterSupport.cjs +18 -0
- package/dist/.internal/utils/filterSupport.d.cts +15 -0
- package/dist/.internal/utils/filterSupport.d.ts +15 -0
- package/dist/.internal/utils/filterSupport.js +8 -0
- package/dist/.internal/utils/getInternalModuleName.cjs +5 -0
- package/dist/.internal/utils/getInternalModuleName.d.cts +3 -0
- package/dist/.internal/utils/getInternalModuleName.d.ts +3 -0
- package/dist/.internal/utils/getInternalModuleName.js +3 -0
- package/dist/.internal/utils/intersection.cjs +5 -0
- package/dist/.internal/utils/intersection.d.cts +3 -0
- package/dist/.internal/utils/intersection.d.ts +3 -0
- package/dist/.internal/utils/intersection.js +3 -0
- package/dist/.internal/utils/loadConfig.cjs +14 -0
- package/dist/.internal/utils/loadConfig.d.cts +10 -0
- package/dist/.internal/utils/loadConfig.d.ts +10 -0
- package/dist/.internal/utils/loadConfig.js +9 -0
- package/dist/.internal/utils/recursiveListFiles.cjs +19 -0
- package/dist/.internal/utils/recursiveListFiles.d.cts +3 -0
- package/dist/.internal/utils/recursiveListFiles.d.ts +3 -0
- package/dist/.internal/utils/recursiveListFiles.js +13 -0
- package/dist/.internal/utils/resolveExports.cjs +118 -0
- package/dist/.internal/utils/resolveExports.d.cts +26 -0
- package/dist/.internal/utils/resolveExports.d.ts +26 -0
- package/dist/.internal/utils/resolveExports.js +111 -0
- package/dist/.internal/utils/ts.cjs +68 -0
- package/dist/.internal/utils/ts.d.cts +3 -0
- package/dist/.internal/utils/ts.d.ts +3 -0
- package/dist/.internal/utils/ts.js +62 -0
- package/dist/bin/build.cjs +10 -0
- package/dist/bin/index.cjs +501 -0
- package/dist/index.d.cts +12 -114
- package/dist/index.d.ts +12 -114
- package/dist/rollup/index.cjs +280 -4573
- package/dist/rollup/index.d.cts +7 -1
- package/dist/rollup/index.d.ts +7 -1
- package/dist/rollup/index.js +268 -4558
- package/package.json +15 -23
- package/src/bin/build.cts +5 -0
- package/src/bin/common.ts +3 -0
- package/src/bin/index.cts +7 -0
- package/src/bridge.ts +1 -1
- package/src/commands/base.ts +3 -3
- package/src/commands/build/analyzer.ts +5 -5
- package/src/commands/build/client/analyzer.tsx +1 -1
- package/src/commands/build/client/index.ts +5 -7
- package/src/commands/build.ts +226 -211
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +113 -32
- package/src/index.ts +6 -1
- package/src/rollup/base.ts +2 -2
- package/src/rollup/index.ts +321 -124
- package/src/rollup/plugins/with-external.ts +23 -0
- package/src/rollup/utils/externalResolver.ts +20 -8
- package/src/utils/checkDependency.ts +1 -1
- package/src/utils/filterSupport.ts +17 -16
- package/src/utils/getInternalModuleName.ts +5 -0
- package/src/utils/intersection.ts +1 -0
- package/src/utils/{recusiveListFiles.ts → recursiveListFiles.ts} +2 -2
- package/src/utils/{getExports.ts → resolveExports.ts} +16 -14
- package/bin/jiek-build.js +0 -16
- package/bin/jiek.js +0 -13
- package/cli/package.json +0 -1
- package/cli-only-build/package.json +0 -1
- package/dist/cli.d.cts +0 -14
- package/dist/cli.d.ts +0 -14
- package/src/cli-only-build.ts +0 -11
- package/src/cli.ts +0 -6
- /package/{src/bin/build.ts → .jiek-production-tag} +0 -0
- /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
@@ -1,124 +1,43 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
var filterSupport = require('../.chunks/filterSupport.4rM7f6jB.cjs');
|
4
|
+
var commander = require('commander');
|
3
5
|
var fs = require('node:fs');
|
4
6
|
var path = require('node:path');
|
5
|
-
var
|
6
|
-
var jsYaml = require('js-yaml');
|
7
|
-
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
8
|
-
var process$1 = require('node:process');
|
7
|
+
var process = require('node:process');
|
9
8
|
var cliProgress = require('cli-progress');
|
10
|
-
var
|
9
|
+
var index = require('../.chunks/index.Daihq2aI.cjs');
|
11
10
|
var node_child_process = require('node:child_process');
|
12
11
|
var prompts = require('@inquirer/prompts');
|
12
|
+
var base = require('../rollup/base.cjs');
|
13
13
|
var Koa = require('koa');
|
14
|
+
var loadConfig = require('../.chunks/loadConfig.OOKddvHF.cjs');
|
15
|
+
require('js-yaml');
|
16
|
+
require('@jiek/utils/getWorkspaceDir');
|
17
|
+
require('node:url');
|
18
|
+
require('node:string_decoder');
|
19
|
+
require('node:util');
|
20
|
+
require('node:tty');
|
21
|
+
require('child_process');
|
22
|
+
require('path');
|
23
|
+
require('fs');
|
24
|
+
require('node:timers/promises');
|
25
|
+
require('node:os');
|
26
|
+
require('node:events');
|
27
|
+
require('node:v8');
|
28
|
+
require('node:stream');
|
29
|
+
require('node:buffer');
|
30
|
+
require('node:stream/promises');
|
14
31
|
|
15
32
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
16
33
|
|
17
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
18
34
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
19
|
-
var process__default = /*#__PURE__*/_interopDefault(process
|
35
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
20
36
|
var Koa__default = /*#__PURE__*/_interopDefault(Koa);
|
21
37
|
|
22
|
-
var require$1 = require;
|
23
|
-
|
24
|
-
let root;
|
25
|
-
function getRoot() {
|
26
|
-
if (root) return root;
|
27
|
-
const rootOption = process.env.JIEK_ROOT;
|
28
|
-
root = rootOption ? path__default.default.isAbsolute(rootOption) ? rootOption : path__default.default.resolve(process.cwd(), rootOption) : void 0;
|
29
|
-
return root;
|
30
|
-
}
|
31
|
-
|
32
|
-
let wd;
|
33
|
-
let notWorkspace$1 = false;
|
34
|
-
function getWD() {
|
35
|
-
if (wd) return { wd, notWorkspace: notWorkspace$1 };
|
36
|
-
const root = getRoot();
|
37
|
-
if (root !== void 0) {
|
38
|
-
const isWorkspace = getWorkspaceDir.isWorkspaceDir(root, type$1);
|
39
|
-
notWorkspace$1 = !isWorkspace;
|
40
|
-
wd = root;
|
41
|
-
return { wd, notWorkspace: notWorkspace$1 };
|
42
|
-
}
|
43
|
-
try {
|
44
|
-
wd = getWorkspaceDir.getWorkspaceDir(type$1);
|
45
|
-
} catch (e) {
|
46
|
-
if ("message" in e && e.message === "workspace root not found") {
|
47
|
-
wd = root ?? process.cwd();
|
48
|
-
notWorkspace$1 = true;
|
49
|
-
} else {
|
50
|
-
throw e;
|
51
|
-
}
|
52
|
-
}
|
53
|
-
return { wd, notWorkspace: notWorkspace$1 };
|
54
|
-
}
|
55
|
-
|
56
|
-
let type$1 = "";
|
57
|
-
try {
|
58
|
-
require$1.resolve("@pnpm/filter-workspace-packages");
|
59
|
-
type$1 = "pnpm";
|
60
|
-
} catch {
|
61
|
-
}
|
62
|
-
async function filterPackagesGraph(filters) {
|
63
|
-
return Promise.all(filters.map(async (filter) => getSelectedProjectsGraph(filter)));
|
64
|
-
}
|
65
|
-
async function getSelectedProjectsGraph(filter = commander.program.getOptionValue("filter")) {
|
66
|
-
const { wd, notWorkspace } = getWD();
|
67
|
-
let root = getRoot();
|
68
|
-
if (notWorkspace) {
|
69
|
-
return {
|
70
|
-
wd,
|
71
|
-
root,
|
72
|
-
value: {
|
73
|
-
[wd]: JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(wd, "package.json"), "utf-8"))
|
74
|
-
}
|
75
|
-
};
|
76
|
-
}
|
77
|
-
if (type$1 === "pnpm") {
|
78
|
-
const pnpmWorkspaceFilePath = path__default.default.resolve(wd, "pnpm-workspace.yaml");
|
79
|
-
const pnpmWorkspaceFileContent = fs__default.default.readFileSync(pnpmWorkspaceFilePath, "utf-8");
|
80
|
-
const pnpmWorkspace = jsYaml.load(pnpmWorkspaceFileContent);
|
81
|
-
if (root === wd && !filter) {
|
82
|
-
throw new Error("root path is workspace root, please provide a filter");
|
83
|
-
}
|
84
|
-
if (root === void 0) {
|
85
|
-
root = process.cwd();
|
86
|
-
}
|
87
|
-
if (root !== wd && !filter) {
|
88
|
-
const packageJSONIsExist = fs__default.default.existsSync(path__default.default.resolve(root, "package.json"));
|
89
|
-
if (!packageJSONIsExist) {
|
90
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
91
|
-
}
|
92
|
-
const packageJSON = JSON.parse(fs__default.default.readFileSync(path__default.default.resolve(root, "package.json"), "utf-8"));
|
93
|
-
if (!packageJSON.name) {
|
94
|
-
throw new Error("root path is not workspace root, please provide a filter");
|
95
|
-
}
|
96
|
-
filter = packageJSON.name;
|
97
|
-
}
|
98
|
-
const { filterPackagesFromDir } = await import('@pnpm/filter-workspace-packages');
|
99
|
-
const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{
|
100
|
-
filter: filter ?? "",
|
101
|
-
followProdDepsOnly: true
|
102
|
-
}], {
|
103
|
-
prefix: root,
|
104
|
-
workspaceDir: wd,
|
105
|
-
patterns: pnpmWorkspace.packages
|
106
|
-
});
|
107
|
-
return {
|
108
|
-
wd,
|
109
|
-
root,
|
110
|
-
value: Object.entries(selectedProjectsGraph).reduce((acc, [key, value]) => {
|
111
|
-
acc[key] = value.package.manifest;
|
112
|
-
return acc;
|
113
|
-
}, {})
|
114
|
-
};
|
115
|
-
}
|
116
|
-
throw new Error(`not supported package manager ${type$1}`);
|
117
|
-
}
|
118
|
-
|
119
38
|
var name = "jiek";
|
120
39
|
var type = "module";
|
121
|
-
var version = "2.2.
|
40
|
+
var version = "2.2.7-alpha.5";
|
122
41
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
123
42
|
var author = "YiJie <yijie4188@gmail.com>";
|
124
43
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -144,22 +63,16 @@ var exports$1 = {
|
|
144
63
|
require: "./bin-helper/index.cjs",
|
145
64
|
"default": "./bin-helper/index.js"
|
146
65
|
},
|
147
|
-
"./cli": "./src/cli.ts",
|
148
|
-
"./cli-only-build": "./src/cli-only-build.ts",
|
149
66
|
"./rollup": "./src/rollup/index.ts"
|
150
67
|
};
|
151
68
|
var imports = {
|
152
|
-
"#~/*":
|
153
|
-
"./src/*",
|
154
|
-
"./src/*/index.ts",
|
155
|
-
"./src/*/index.tsx"
|
156
|
-
]
|
69
|
+
"#~/*": "./src/*.ts"
|
157
70
|
};
|
158
71
|
var bin = {
|
159
|
-
jiek: "bin/
|
160
|
-
jk: "bin/
|
161
|
-
"jiek-build": "bin/
|
162
|
-
jb: "bin/
|
72
|
+
jiek: "bin/index.cjs",
|
73
|
+
jk: "bin/index.cjs",
|
74
|
+
"jiek-build": "bin/build.cjs",
|
75
|
+
jb: "bin/build.cjs"
|
163
76
|
};
|
164
77
|
var files = [
|
165
78
|
"LICENSE",
|
@@ -183,12 +96,12 @@ var peerDependencies = {
|
|
183
96
|
"rollup-plugin-postcss": "^4.0.2",
|
184
97
|
"rollup-plugin-swc3": "^0.12.1",
|
185
98
|
typescript: "^4.0.0||^5.0.0",
|
186
|
-
"vite-bundle-analyzer": "0.16.0-beta.
|
99
|
+
"vite-bundle-analyzer": "0.16.0-beta.3"
|
187
100
|
};
|
188
101
|
var dependencies = {
|
189
102
|
"@inquirer/prompts": "^7.2.0",
|
190
103
|
"@jiek/pkger": "workspace:^",
|
191
|
-
"@jiek/rollup-plugin-dts": "^6.
|
104
|
+
"@jiek/rollup-plugin-dts": "^6.3.8",
|
192
105
|
"@jiek/utils": "workspace:^",
|
193
106
|
"@rollup/plugin-commonjs": "^28.0.0",
|
194
107
|
"@rollup/plugin-inject": "^5.0.5",
|
@@ -197,7 +110,6 @@ var dependencies = {
|
|
197
110
|
"cli-progress": "^3.12.0",
|
198
111
|
commander: "^12.0.0",
|
199
112
|
"detect-indent": "^6.1.0",
|
200
|
-
execa: "~9.3.1",
|
201
113
|
"js-yaml": "^4.1.0",
|
202
114
|
"jsonc-parser": "^3.2.1",
|
203
115
|
koa: "^2.15.3",
|
@@ -215,13 +127,17 @@ var devDependencies = {
|
|
215
127
|
"@types/micromatch": "^4.0.6",
|
216
128
|
"@types/react": "^18.3.14",
|
217
129
|
"esbuild-register": "^3.5.0",
|
130
|
+
execa: "~9.3.1",
|
218
131
|
micromatch: "^4.0.5",
|
219
132
|
"node-sass": "^9.0.0",
|
220
133
|
postcss: "^8.4.47",
|
221
134
|
"rollup-plugin-esbuild": "^6.1.0",
|
222
135
|
"rollup-plugin-postcss": "^4.0.2",
|
223
136
|
"rollup-plugin-swc3": "^0.12.1",
|
224
|
-
"vite-bundle-analyzer": "0.16.0-beta.
|
137
|
+
"vite-bundle-analyzer": "0.16.0-beta.3"
|
138
|
+
};
|
139
|
+
var publishConfig = {
|
140
|
+
directory: "./dist/.internal"
|
225
141
|
};
|
226
142
|
var pkg = {
|
227
143
|
name: name,
|
@@ -240,7 +156,8 @@ var pkg = {
|
|
240
156
|
scripts: scripts,
|
241
157
|
peerDependencies: peerDependencies,
|
242
158
|
dependencies: dependencies,
|
243
|
-
devDependencies: devDependencies
|
159
|
+
devDependencies: devDependencies,
|
160
|
+
publishConfig: publishConfig
|
244
161
|
};
|
245
162
|
|
246
163
|
const entriesDescription = `
|
@@ -259,11 +176,11 @@ Support with variables: 'PKG_NAME',
|
|
259
176
|
.e.g. 'dist/{{PKG_NAME}}'.
|
260
177
|
`.trim();
|
261
178
|
|
262
|
-
const { notWorkspace } = getWD();
|
179
|
+
const { notWorkspace } = filterSupport.getWD();
|
263
180
|
const IS_WORKSPACE = !notWorkspace;
|
264
181
|
|
265
182
|
commander.program.name("jk/jiek").version(pkg.version).description(`${pkg.description} - Version ${pkg.version}`).option("-c, --config-path <configPath>", "Custom jiek config path").option("--env.<name>=<value>", "Set the environment variable.");
|
266
|
-
if (type
|
183
|
+
if (filterSupport.type !== "" && IS_WORKSPACE) {
|
267
184
|
commander.program.option("-f, --filter <filter>", filterDescription);
|
268
185
|
}
|
269
186
|
|
@@ -355,13 +272,11 @@ function Main() {
|
|
355
272
|
|
356
273
|
function render() {
|
357
274
|
CUSTOM_SIDE_BAR = true;
|
358
|
-
window.addEventListener("client:ready", () =>
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
);
|
364
|
-
}, 0));
|
275
|
+
window.addEventListener("client:ready", () => window.dispatchEvent(
|
276
|
+
new CustomEvent("send:ui", {
|
277
|
+
detail: { type: "Main", Component: __REPLACE_INJECT__ }
|
278
|
+
})
|
279
|
+
));
|
365
280
|
}
|
366
281
|
const CLIENT_CUSTOM_RENDER_SCRIPT = [
|
367
282
|
Main.toString(),
|
@@ -376,10 +291,10 @@ function parseBoolean(v) {
|
|
376
291
|
|
377
292
|
async function checkDependency(dependency) {
|
378
293
|
try {
|
379
|
-
require
|
294
|
+
filterSupport.require.resolve(dependency);
|
380
295
|
} catch {
|
381
296
|
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
382
|
-
const { notWorkspace } = getWD();
|
297
|
+
const { notWorkspace } = filterSupport.getWD();
|
383
298
|
const command = `pnpm add -${notWorkspace ? "" : "w"}D ${dependency}`;
|
384
299
|
if (await prompts.confirm({ message: `Do you want to add it now? (${command})` })) {
|
385
300
|
node_child_process.execSync(command, {
|
@@ -473,12 +388,6 @@ const useAnalyzer = async (options, server) => {
|
|
473
388
|
};
|
474
389
|
};
|
475
390
|
|
476
|
-
const BUILDER_TYPES = ["esbuild", "swc"];
|
477
|
-
const BUILDER_TYPE_PACKAGE_NAME_MAP = {
|
478
|
-
esbuild: "rollup-plugin-esbuild",
|
479
|
-
swc: "rollup-plugin-swc3"
|
480
|
-
};
|
481
|
-
|
482
391
|
const createServer = (port, host) => {
|
483
392
|
const app = new Koa__default.default();
|
484
393
|
app.listen(port, host);
|
@@ -503,119 +412,20 @@ const createServer = (port, host) => {
|
|
503
412
|
};
|
504
413
|
};
|
505
414
|
|
506
|
-
function packageIsExist(name) {
|
507
|
-
try {
|
508
|
-
require$1.resolve(name);
|
509
|
-
return true;
|
510
|
-
} catch (e) {
|
511
|
-
return false;
|
512
|
-
}
|
513
|
-
}
|
514
|
-
let tsRegisterName;
|
515
|
-
const registers = [
|
516
|
-
process.env.JIEK_TS_REGISTER,
|
517
|
-
"esbuild-register",
|
518
|
-
"@swc-node/register",
|
519
|
-
"ts-node/register"
|
520
|
-
].filter(Boolean);
|
521
|
-
for (const register of registers) {
|
522
|
-
if (packageIsExist(register)) {
|
523
|
-
tsRegisterName = register;
|
524
|
-
break;
|
525
|
-
}
|
526
|
-
}
|
527
|
-
|
528
|
-
let configName = "jiek.config";
|
529
|
-
function getConfigPath(root, dir) {
|
530
|
-
const isSupportTsLoader = !!tsRegisterName;
|
531
|
-
function configWithExtIsExist(ext) {
|
532
|
-
const filenames = [
|
533
|
-
path__default.default.resolve(process.cwd(), `${configName}.${ext}`),
|
534
|
-
path__default.default.resolve(process.cwd(), `.${configName}.${ext}`),
|
535
|
-
path__default.default.resolve(root, `${configName}.${ext}`),
|
536
|
-
path__default.default.resolve(root, `.${configName}.${ext}`)
|
537
|
-
];
|
538
|
-
if (dir) {
|
539
|
-
filenames.unshift(...[
|
540
|
-
path__default.default.resolve(dir, `${configName}.${ext}`),
|
541
|
-
path__default.default.resolve(dir, `.${configName}.${ext}`)
|
542
|
-
]);
|
543
|
-
}
|
544
|
-
for (const filename of filenames) {
|
545
|
-
if (fs__default.default.existsSync(filename) && fs__default.default.lstatSync(filename).isFile()) {
|
546
|
-
return filename;
|
547
|
-
}
|
548
|
-
}
|
549
|
-
return;
|
550
|
-
}
|
551
|
-
configName = configWithExtIsExist("js") ?? configName;
|
552
|
-
configName = configWithExtIsExist("json") ?? configName;
|
553
|
-
configName = configWithExtIsExist("yaml") ?? configName;
|
554
|
-
if (isSupportTsLoader) {
|
555
|
-
configName = configWithExtIsExist("ts") ?? configName;
|
556
|
-
}
|
557
|
-
return path__default.default.resolve(root, configName);
|
558
|
-
}
|
559
|
-
function loadConfig(dirOrOptions) {
|
560
|
-
let dir;
|
561
|
-
let root;
|
562
|
-
{
|
563
|
-
dir = dirOrOptions;
|
564
|
-
root = getWD().wd;
|
565
|
-
}
|
566
|
-
let configPath = commander.program.getOptionValue("configPath");
|
567
|
-
if (!configPath) {
|
568
|
-
configPath = getConfigPath(root, dir);
|
569
|
-
} else {
|
570
|
-
if (!fs__default.default.existsSync(configPath)) {
|
571
|
-
throw new Error(`config file not found: ${configPath}`);
|
572
|
-
}
|
573
|
-
if (!path__default.default.isAbsolute(configPath)) {
|
574
|
-
configPath = path__default.default.resolve(root, configPath);
|
575
|
-
}
|
576
|
-
}
|
577
|
-
const ext = path__default.default.extname(configPath);
|
578
|
-
let module;
|
579
|
-
switch (ext) {
|
580
|
-
case ".js":
|
581
|
-
module = require$1(configPath);
|
582
|
-
break;
|
583
|
-
case ".json":
|
584
|
-
return require$1(configPath);
|
585
|
-
case ".yaml":
|
586
|
-
return jsYaml.load(fs__default.default.readFileSync(configPath, "utf-8"));
|
587
|
-
case ".ts":
|
588
|
-
if (tsRegisterName) {
|
589
|
-
require$1(tsRegisterName);
|
590
|
-
module = require$1(configPath);
|
591
|
-
break;
|
592
|
-
}
|
593
|
-
throw new Error(
|
594
|
-
"ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register"
|
595
|
-
);
|
596
|
-
case ".config":
|
597
|
-
module = {};
|
598
|
-
break;
|
599
|
-
default:
|
600
|
-
throw new Error(`unsupported config file type: ${ext}`);
|
601
|
-
}
|
602
|
-
if (!module) throw new Error("config file is empty");
|
603
|
-
return module.default ?? module;
|
604
|
-
}
|
605
|
-
|
606
415
|
const FILE_TEMPLATE = (manifest) => `
|
607
416
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
608
417
|
`.trimStart();
|
609
|
-
const
|
418
|
+
const ROLLUP_BIN = filterSupport.require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
419
|
+
const isDefault = process__default.default.env.JIEK_BIN__FILENAME === "build.cjs";
|
610
420
|
const description = `
|
611
421
|
Build the package according to the 'exports' field from the package.json.
|
612
422
|
If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
|
613
423
|
${isDefault ? "This command is the default command." : ""}
|
614
424
|
`.trim();
|
615
425
|
let DEFAULT_BUILDER_TYPE;
|
616
|
-
Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
426
|
+
Object.entries(base.BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
617
427
|
try {
|
618
|
-
require
|
428
|
+
filterSupport.require.resolve(packageName);
|
619
429
|
DEFAULT_BUILDER_TYPE = type;
|
620
430
|
} catch {
|
621
431
|
}
|
@@ -640,9 +450,9 @@ let command = isDefault ? (() => {
|
|
640
450
|
}
|
641
451
|
return c;
|
642
452
|
})() : commander.program.command(`build [${IS_WORKSPACE ? "filters" : "entries"}]`);
|
643
|
-
command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
|
644
|
-
if (!BUILDER_TYPES.includes(v)) {
|
645
|
-
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
453
|
+
command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
|
454
|
+
if (!base.BUILDER_TYPES.includes(v)) {
|
455
|
+
throw new Error(`The value of 'type' must be ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
646
456
|
}
|
647
457
|
return String(v);
|
648
458
|
}, "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(
|
@@ -659,6 +469,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
659
469
|
"Only output minify files, but dts files will still be output, it only replaces the js files.",
|
660
470
|
parseBoolean
|
661
471
|
);
|
472
|
+
command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
|
662
473
|
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);
|
663
474
|
command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
|
664
475
|
command = registerAnalyzerCommandOptions(command);
|
@@ -684,7 +495,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
684
495
|
} = options;
|
685
496
|
const resolvedType = type ?? DEFAULT_BUILDER_TYPE;
|
686
497
|
if (!withoutJs) {
|
687
|
-
await checkDependency(BUILDER_TYPE_PACKAGE_NAME_MAP[resolvedType]);
|
498
|
+
await checkDependency(base.BUILDER_TYPE_PACKAGE_NAME_MAP[resolvedType]);
|
688
499
|
if (minifyType === "builder") {
|
689
500
|
minifyType = resolvedType;
|
690
501
|
}
|
@@ -713,7 +524,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
713
524
|
ANALYZER_ENV,
|
714
525
|
refreshAnalyzer
|
715
526
|
} = await useAnalyzer(options, server);
|
716
|
-
const { build } = loadConfig();
|
527
|
+
const { build } = loadConfig.loadConfig();
|
717
528
|
silent = silent ?? build?.silent ?? false;
|
718
529
|
if (withoutMin && onlyMin) {
|
719
530
|
throw new Error("Cannot use both --without-minify and --only-minify");
|
@@ -743,6 +554,9 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
743
554
|
JIEK_MINIFY_TYPE: minifyType,
|
744
555
|
JIEK_TSCONFIG: tsconfig,
|
745
556
|
JIEK_DTSCONFIG: dtsconfig,
|
557
|
+
JIEK_FEATURES: JSON.stringify({
|
558
|
+
keepImportAttributes: options["features.keepImportAttributes"]
|
559
|
+
}),
|
746
560
|
...process__default.default.env
|
747
561
|
};
|
748
562
|
const multiBars = new cliProgress.MultiBar({
|
@@ -750,183 +564,179 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
750
564
|
hideCursor: true,
|
751
565
|
format: "- {bar} | {status} | {pkgName} | {input} | {message}"
|
752
566
|
}, cliProgress.Presets.shades_classic);
|
753
|
-
const
|
754
|
-
|
755
|
-
|
567
|
+
const { wd } = filterSupport.getWD();
|
568
|
+
const wdNodeModules = path__default.default.resolve(wd, "node_modules");
|
569
|
+
if (!fs.existsSync(wdNodeModules)) {
|
570
|
+
fs.mkdirSync(wdNodeModules);
|
571
|
+
}
|
572
|
+
const resolveByJiekTemp = (...paths) => path__default.default.resolve(wdNodeModules, ".jiek", ...paths);
|
573
|
+
const jiekTemp = resolveByJiekTemp();
|
574
|
+
if (!fs.existsSync(jiekTemp)) {
|
575
|
+
try {
|
576
|
+
fs.mkdirSync(jiekTemp);
|
577
|
+
} catch (e) {
|
578
|
+
if (e.code !== "EEXIST") {
|
579
|
+
throw e;
|
580
|
+
}
|
581
|
+
}
|
582
|
+
}
|
583
|
+
let i = 0;
|
584
|
+
const buildPackage = async ([pkgCWD, manifest], {
|
585
|
+
resolveByJiekTemp: resolveByJiekTemp2
|
756
586
|
}) => {
|
757
|
-
if (
|
758
|
-
throw new Error("
|
587
|
+
if (manifest.name == null) {
|
588
|
+
throw new Error("package.json must have a name field");
|
759
589
|
}
|
760
|
-
const
|
761
|
-
|
762
|
-
|
590
|
+
const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
|
591
|
+
const configFile = resolveByJiekTemp2(
|
592
|
+
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
593
|
+
);
|
594
|
+
fs.writeFileSync(configFile, FILE_TEMPLATE(manifest));
|
595
|
+
const command2 = [ROLLUP_BIN, "--silent", "-c", configFile];
|
596
|
+
if (loadConfig.tsRegisterName != null) {
|
597
|
+
command2.unshift(`node -r ${loadConfig.tsRegisterName}`);
|
763
598
|
}
|
764
|
-
|
765
|
-
|
766
|
-
if (!fs.existsSync(jiekTemp)) {
|
767
|
-
try {
|
768
|
-
fs.mkdirSync(jiekTemp);
|
769
|
-
} catch {
|
770
|
-
}
|
599
|
+
if (watch) {
|
600
|
+
command2.push("--watch");
|
771
601
|
}
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
602
|
+
command2.push(...passThroughOptions);
|
603
|
+
const child = index.execaCommand(command2.join(" "), {
|
604
|
+
ipc: true,
|
605
|
+
cwd: pkgCWD,
|
606
|
+
windowsHide: true,
|
607
|
+
env: {
|
608
|
+
...env,
|
609
|
+
JIEK_NAME: manifest.name,
|
610
|
+
JIEK_ROOT: wd
|
611
|
+
}
|
612
|
+
});
|
613
|
+
const bars = {};
|
614
|
+
const times = {};
|
615
|
+
const locks = {};
|
616
|
+
let inputMaxLen = 10;
|
617
|
+
child.on("message", (e) => {
|
618
|
+
if (silent && [
|
619
|
+
"init",
|
620
|
+
"progress",
|
621
|
+
"watchChange"
|
622
|
+
].includes(e.type)) return;
|
623
|
+
switch (e.type) {
|
624
|
+
case "init": {
|
625
|
+
const { leafMap, targetsLength } = e.data;
|
626
|
+
const leafs = Array.from(leafMap.entries()).flatMap(
|
627
|
+
([input, pathAndConditions]) => pathAndConditions.map(([path2, ...conditions]) => ({
|
628
|
+
input,
|
629
|
+
path: path2,
|
630
|
+
conditions
|
631
|
+
}))
|
632
|
+
);
|
633
|
+
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`;
|
634
|
+
if (watch) {
|
635
|
+
initMessage += " and watching...";
|
636
|
+
}
|
637
|
+
console.log(initMessage);
|
638
|
+
leafs.forEach(({ input }) => {
|
639
|
+
inputMaxLen = Math.max(inputMaxLen, input.length);
|
640
|
+
});
|
641
|
+
leafs.forEach(({ input, path: path2 }) => {
|
642
|
+
const key = `${input}:${path2}`;
|
643
|
+
if (bars[key]) return;
|
644
|
+
bars[key] = multiBars.create(50, 0, {
|
645
|
+
pkgName: manifest.name,
|
646
|
+
input: input.padEnd(inputMaxLen + 5),
|
647
|
+
status: "waiting".padEnd(10)
|
648
|
+
}, {
|
649
|
+
barsize: 20,
|
650
|
+
linewrap: true
|
651
|
+
});
|
652
|
+
});
|
653
|
+
break;
|
787
654
|
}
|
788
|
-
|
789
|
-
|
655
|
+
case "progress": {
|
656
|
+
const {
|
657
|
+
path: path2,
|
658
|
+
tags,
|
659
|
+
input,
|
660
|
+
event,
|
661
|
+
message
|
662
|
+
} = e.data;
|
663
|
+
const bar = bars[`${input}:${path2}`];
|
664
|
+
if (!bar) return;
|
665
|
+
const time = times[`${input}:${path2}`];
|
666
|
+
bar.update(
|
667
|
+
{
|
668
|
+
start: 0,
|
669
|
+
resolve: 20,
|
670
|
+
end: 50
|
671
|
+
}[event ?? "start"] ?? 0,
|
672
|
+
{
|
673
|
+
input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
|
674
|
+
status: event?.padEnd(10),
|
675
|
+
message: `${tags?.join(", ")}: ${message}`
|
676
|
+
}
|
677
|
+
);
|
678
|
+
break;
|
790
679
|
}
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
680
|
+
case "watchChange": {
|
681
|
+
const {
|
682
|
+
path: path2,
|
683
|
+
input
|
684
|
+
} = e.data;
|
685
|
+
const key = `${input}:${path2}`;
|
686
|
+
const bar = bars[key];
|
687
|
+
if (!bar) return;
|
688
|
+
let time = times[key] ?? 1;
|
689
|
+
if (!locks[key]) {
|
690
|
+
time += 1;
|
691
|
+
times[key] = time;
|
692
|
+
setTimeout(() => {
|
693
|
+
locks[key] = false;
|
694
|
+
}, 100);
|
695
|
+
bar.update(0, {
|
696
|
+
input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
|
697
|
+
status: "watching".padEnd(10),
|
698
|
+
message: "watching..."
|
699
|
+
});
|
799
700
|
}
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
"progress",
|
809
|
-
"watchChange"
|
810
|
-
].includes(e.type)) return;
|
811
|
-
switch (e.type) {
|
812
|
-
case "init": {
|
813
|
-
const { leafMap, targetsLength } = e.data;
|
814
|
-
const leafs = Array.from(leafMap.entries()).flatMap(
|
815
|
-
([input, pathAndCondiions]) => pathAndCondiions.map(([path2, ...conditions]) => ({
|
816
|
-
input,
|
817
|
-
path: path2,
|
818
|
-
conditions
|
819
|
-
}))
|
820
|
-
);
|
821
|
-
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`;
|
822
|
-
if (watch) {
|
823
|
-
initMessage += " and watching...";
|
824
|
-
}
|
825
|
-
console.log(initMessage);
|
826
|
-
leafs.forEach(({ input }) => {
|
827
|
-
inputMaxLen = Math.max(inputMaxLen, input.length);
|
828
|
-
});
|
829
|
-
leafs.forEach(({ input, path: path2 }) => {
|
830
|
-
const key = `${input}:${path2}`;
|
831
|
-
if (bars[key]) return;
|
832
|
-
bars[key] = multiBars.create(50, 0, {
|
833
|
-
pkgName: manifest.name,
|
834
|
-
input: input.padEnd(inputMaxLen + 5),
|
835
|
-
status: "waiting".padEnd(10)
|
836
|
-
}, {
|
837
|
-
barsize: 20,
|
838
|
-
linewrap: true
|
839
|
-
});
|
840
|
-
});
|
841
|
-
break;
|
842
|
-
}
|
843
|
-
case "progress": {
|
844
|
-
const {
|
845
|
-
path: path2,
|
846
|
-
tags,
|
847
|
-
input,
|
848
|
-
event,
|
849
|
-
message
|
850
|
-
} = e.data;
|
851
|
-
const bar = bars[`${input}:${path2}`];
|
852
|
-
if (!bar) return;
|
853
|
-
const time = times[`${input}:${path2}`];
|
854
|
-
bar.update(
|
855
|
-
{
|
856
|
-
start: 0,
|
857
|
-
resolve: 20,
|
858
|
-
end: 50
|
859
|
-
}[event ?? "start"] ?? 0,
|
860
|
-
{
|
861
|
-
input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
|
862
|
-
status: event?.padEnd(10),
|
863
|
-
message: `${tags?.join(", ")}: ${message}`
|
864
|
-
}
|
865
|
-
);
|
866
|
-
break;
|
867
|
-
}
|
868
|
-
case "watchChange": {
|
869
|
-
const {
|
870
|
-
path: path2,
|
871
|
-
input
|
872
|
-
} = e.data;
|
873
|
-
const key = `${input}:${path2}`;
|
874
|
-
const bar = bars[key];
|
875
|
-
if (!bar) return;
|
876
|
-
let time = times[key] ?? 1;
|
877
|
-
if (!locks[key]) {
|
878
|
-
time += 1;
|
879
|
-
times[key] = time;
|
880
|
-
setTimeout(() => {
|
881
|
-
locks[key] = false;
|
882
|
-
}, 100);
|
883
|
-
bar.update(0, {
|
884
|
-
input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
|
885
|
-
status: "watching".padEnd(10),
|
886
|
-
message: "watching..."
|
887
|
-
});
|
888
|
-
}
|
889
|
-
locks[key] = true;
|
890
|
-
break;
|
891
|
-
}
|
892
|
-
case "modulesAnalyze": {
|
893
|
-
const {
|
894
|
-
data: {
|
895
|
-
type: type2,
|
896
|
-
modules: pkgModules
|
897
|
-
}
|
898
|
-
} = e;
|
899
|
-
void refreshAnalyzer(
|
900
|
-
pkgCWD,
|
901
|
-
pkgModules.map((m) => ({
|
902
|
-
...m,
|
903
|
-
type: type2,
|
904
|
-
filename: `${manifest.name}/${m.filename}`,
|
905
|
-
label: `${manifest.name}/${m.label}`
|
906
|
-
}))
|
907
|
-
);
|
908
|
-
break;
|
909
|
-
}
|
910
|
-
case "debug": {
|
911
|
-
console.log(...Array.isArray(e.data) ? e.data : [e.data]);
|
912
|
-
break;
|
701
|
+
locks[key] = true;
|
702
|
+
break;
|
703
|
+
}
|
704
|
+
case "modulesAnalyze": {
|
705
|
+
const {
|
706
|
+
data: {
|
707
|
+
type: type2,
|
708
|
+
modules: pkgModules
|
913
709
|
}
|
914
|
-
}
|
915
|
-
|
916
|
-
|
917
|
-
|
710
|
+
} = e;
|
711
|
+
void refreshAnalyzer(
|
712
|
+
pkgCWD,
|
713
|
+
pkgModules.map((m) => ({
|
714
|
+
...m,
|
715
|
+
type: type2,
|
716
|
+
filename: `${manifest.name}/${m.filename}`,
|
717
|
+
label: `${manifest.name}/${m.label}`
|
718
|
+
}))
|
719
|
+
);
|
720
|
+
break;
|
721
|
+
}
|
722
|
+
case "debug": {
|
723
|
+
console.log(...Array.isArray(e.data) ? e.data : [e.data]);
|
724
|
+
break;
|
725
|
+
}
|
726
|
+
}
|
727
|
+
});
|
728
|
+
await new Promise((resolve, reject) => {
|
729
|
+
let errorStr = `rollup build failed
|
918
730
|
package name: ${manifest.name}
|
919
731
|
cwd: ${pkgCWD}
|
920
732
|
|
921
733
|
`;
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
})
|
929
|
-
);
|
734
|
+
child.stderr?.on("data", (data) => {
|
735
|
+
errorStr += data;
|
736
|
+
});
|
737
|
+
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(errorStr)));
|
738
|
+
verbose && child.stdout?.pipe(process__default.default.stdout);
|
739
|
+
});
|
930
740
|
};
|
931
741
|
const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : void 0;
|
932
742
|
const filters = [
|
@@ -936,41 +746,12 @@ cwd: ${pkgCWD}
|
|
936
746
|
])
|
937
747
|
];
|
938
748
|
try {
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
await buildPackage(await getSelectedProjectsGraph());
|
944
|
-
}
|
749
|
+
const packages = (filters.length > 0 ? await filterSupport.filterPackagesGraph(filters) : [await filterSupport.getSelectedProjectsGraph()]).flatMap(({ value }) => Object.entries(value ?? {}));
|
750
|
+
await Promise.allSettled(
|
751
|
+
packages.map(async ([cwd, manifest]) => buildPackage([cwd, manifest], { resolveByJiekTemp }))
|
752
|
+
);
|
945
753
|
} finally {
|
946
754
|
multiBars.stop();
|
947
755
|
!silent && console.log("Build complete");
|
948
756
|
}
|
949
757
|
});
|
950
|
-
|
951
|
-
const { argv } = process__default.default;
|
952
|
-
const env = {};
|
953
|
-
let isPassThrough = false;
|
954
|
-
const newArgv = argv.filter((arg) => {
|
955
|
-
if (isPassThrough) {
|
956
|
-
return true;
|
957
|
-
}
|
958
|
-
if (arg === "--") {
|
959
|
-
isPassThrough = true;
|
960
|
-
return false;
|
961
|
-
}
|
962
|
-
const m = /^--env\.(\w+)=(.*)$/.exec(arg);
|
963
|
-
if (m) {
|
964
|
-
env[m[1]] = m[2];
|
965
|
-
return false;
|
966
|
-
}
|
967
|
-
return true;
|
968
|
-
});
|
969
|
-
for (const [key, value] of Object.entries(env)) {
|
970
|
-
process__default.default.env[key] = value;
|
971
|
-
}
|
972
|
-
var parseArgv = () => commander.program.parse(newArgv);
|
973
|
-
|
974
|
-
if (process__default.default.env.JIEK_IS_ONLY_BUILD === "true") {
|
975
|
-
parseArgv();
|
976
|
-
}
|