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