jiek 2.2.6 → 2.2.7-alpha.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 +31 -0
- package/bin-helper/index.d.cts +1 -0
- package/bin-helper/index.d.ts +1 -0
- package/bin-helper/package.json +5 -1
- 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 +12 -0
- package/dist/.internal/+/bridge.d.cts +39 -0
- package/dist/.internal/+/bridge.d.ts +39 -0
- package/dist/.internal/+/bridge.js +9 -0
- package/dist/.internal/+/commands/build/analyzer.cjs +201 -0
- package/dist/.internal/+/commands/build/analyzer.d.cts +30 -0
- package/dist/.internal/+/commands/build/analyzer.d.ts +30 -0
- package/dist/.internal/+/commands/build/analyzer.js +195 -0
- package/dist/.internal/+/commands/descriptions.cjs +21 -0
- package/dist/.internal/+/commands/descriptions.d.cts +5 -0
- package/dist/.internal/+/commands/descriptions.d.ts +5 -0
- package/dist/.internal/+/commands/descriptions.js +17 -0
- package/dist/.internal/+/commands/meta.cjs +16 -0
- package/dist/.internal/+/commands/meta.d.cts +3 -0
- package/dist/.internal/+/commands/meta.d.ts +3 -0
- package/dist/.internal/+/commands/meta.js +15 -0
- package/dist/.internal/+/commands/utils/optionParser.cjs +8 -0
- package/dist/.internal/+/commands/utils/optionParser.d.cts +3 -0
- package/dist/.internal/+/commands/utils/optionParser.d.ts +3 -0
- package/dist/.internal/+/commands/utils/optionParser.js +6 -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/+/server.cjs +33 -0
- package/dist/.internal/+/server.d.cts +8 -0
- package/dist/.internal/+/server.d.ts +8 -0
- package/dist/.internal/+/server.js +27 -0
- package/dist/.internal/+/utils/checkDependency.cjs +39 -0
- package/dist/.internal/+/utils/checkDependency.d.cts +3 -0
- package/dist/.internal/+/utils/checkDependency.d.ts +3 -0
- package/dist/.internal/+/utils/checkDependency.js +34 -0
- package/dist/.internal/+/utils/filterSupport.cjs +20 -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 +10 -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/getRoot.cjs +17 -0
- package/dist/.internal/+/utils/getRoot.d.cts +3 -0
- package/dist/.internal/+/utils/getRoot.d.ts +3 -0
- package/dist/.internal/+/utils/getRoot.js +11 -0
- package/dist/.internal/+/utils/getWD.cjs +15 -0
- package/dist/.internal/+/utils/getWD.d.cts +6 -0
- package/dist/.internal/+/utils/getWD.d.ts +6 -0
- package/dist/.internal/+/utils/getWD.js +10 -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 +100 -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 +94 -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/.internal/+/utils/tsRegister.cjs +25 -0
- package/dist/.internal/+/utils/tsRegister.d.cts +3 -0
- package/dist/.internal/+/utils/tsRegister.d.ts +3 -0
- package/dist/.internal/+/utils/tsRegister.js +26 -0
- package/dist/.internal/getWD-BRJ3PK1S.js +105 -0
- package/dist/.internal/getWD-Cmxzjf-f.js +95 -0
- package/dist/{cli.js → .internal/index-B6RQz1DZ.js} +1 -735
- package/dist/{cli.cjs → .internal/index-DlHFuTjM.js} +1 -757
- package/dist/.internal/jiek_create-require-CWFWNQHj.js +5 -0
- package/dist/.internal/jiek_create-require-CxSGbkTB.js +5 -0
- package/dist/.internal/package.json +10 -0
- package/dist/bin/build.cjs +505 -0
- package/dist/bin/index.cjs +488 -0
- package/dist/index.d.cts +1 -113
- package/dist/index.d.ts +1 -113
- package/dist/rollup/index.cjs +282 -4569
- package/dist/rollup/index.d.cts +7 -1
- package/dist/rollup/index.d.ts +7 -1
- package/dist/rollup/index.js +270 -4554
- package/package.json +25 -28
- package/src/bin/build.cts +11 -0
- package/src/bin/index.cts +6 -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 +218 -209
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +87 -25
- package/src/rollup/base.ts +2 -2
- package/src/rollup/index.ts +309 -115
- 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/bin-helper.cjs +0 -43
- package/cli/package.json +0 -1
- package/cli-only-build/package.json +0 -1
- package/dist/cli-only-build.cjs +0 -977
- package/dist/cli-only-build.js +0 -969
- package/dist/cli.d.cts +0 -14
- package/dist/cli.d.ts +0 -14
- package/src/bin/build.ts +0 -0
- package/src/cli-only-build.ts +0 -11
- package/src/cli.ts +0 -6
- /package/{bin-helper.js → bin-helper/index.js} +0 -0
- /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
@@ -0,0 +1,505 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var fs = require('node:fs');
|
4
|
+
var path = require('node:path');
|
5
|
+
var process = require('node:process');
|
6
|
+
var commander = require('commander');
|
7
|
+
require('js-yaml');
|
8
|
+
require('@jiek/__internal__/+/utils/getRoot');
|
9
|
+
var getWD = require('@jiek/__internal__/+/utils/getWD');
|
10
|
+
var descriptions = require('@jiek/__internal__/+/commands/descriptions');
|
11
|
+
var meta = require('@jiek/__internal__/+/commands/meta');
|
12
|
+
var filterSupport = require('@jiek/__internal__/+/utils/filterSupport');
|
13
|
+
var cliProgress = require('cli-progress');
|
14
|
+
var execa = require('execa');
|
15
|
+
var analyzer = require('@jiek/__internal__/+/commands/build/analyzer');
|
16
|
+
var optionParser = require('@jiek/__internal__/+/commands/utils/optionParser');
|
17
|
+
var base = require('@jiek/__internal__/+/rollup/base');
|
18
|
+
var server = require('@jiek/__internal__/+/server');
|
19
|
+
var checkDependency = require('@jiek/__internal__/+/utils/checkDependency');
|
20
|
+
var loadConfig = require('@jiek/__internal__/+/utils/loadConfig');
|
21
|
+
var tsRegister = require('@jiek/__internal__/+/utils/tsRegister');
|
22
|
+
var parseArgv = require('@jiek/__internal__/+/bin/parseArgv');
|
23
|
+
|
24
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
25
|
+
|
26
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
27
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
28
|
+
var parseArgv__default = /*#__PURE__*/_interopDefault(parseArgv);
|
29
|
+
|
30
|
+
var require$1 = require;
|
31
|
+
|
32
|
+
let type$1 = "";
|
33
|
+
try {
|
34
|
+
require$1.resolve("@pnpm/filter-workspace-packages");
|
35
|
+
type$1 = "pnpm";
|
36
|
+
} catch {
|
37
|
+
}
|
38
|
+
|
39
|
+
var name = "jiek";
|
40
|
+
var type = "module";
|
41
|
+
var version = "2.2.7";
|
42
|
+
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
43
|
+
var author = "YiJie <yijie4188@gmail.com>";
|
44
|
+
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
45
|
+
var repository = {
|
46
|
+
url: "nwylzw/jiek",
|
47
|
+
directory: "packages/jiek"
|
48
|
+
};
|
49
|
+
var bugs = "https://github.com/NWYLZW/jiek/issues?q=is%3Aissue+is%3Aopen+jiek";
|
50
|
+
var keywords = [
|
51
|
+
"cli",
|
52
|
+
"zero-config",
|
53
|
+
"bundler",
|
54
|
+
"library",
|
55
|
+
"monorepo",
|
56
|
+
"builder",
|
57
|
+
"rollup",
|
58
|
+
"workspace"
|
59
|
+
];
|
60
|
+
var exports$1 = {
|
61
|
+
"./package.json": "./package.json",
|
62
|
+
".": "./src/index.ts",
|
63
|
+
"./bin-helper": {
|
64
|
+
require: "./bin-helper/index.cjs",
|
65
|
+
"default": "./bin-helper/index.js"
|
66
|
+
},
|
67
|
+
"./rollup": "./src/rollup/index.ts"
|
68
|
+
};
|
69
|
+
var imports = {
|
70
|
+
"#~/*": "./src/*.ts"
|
71
|
+
};
|
72
|
+
var bin = {
|
73
|
+
jiek: "bin/index.cjs",
|
74
|
+
jk: "bin/index.cjs",
|
75
|
+
"jiek-build": "bin/build.cjs",
|
76
|
+
jb: "bin/build.cjs"
|
77
|
+
};
|
78
|
+
var files = [
|
79
|
+
"LICENSE",
|
80
|
+
"README.md",
|
81
|
+
"bin",
|
82
|
+
"bin-helper",
|
83
|
+
"dist",
|
84
|
+
"src"
|
85
|
+
];
|
86
|
+
var scripts = {
|
87
|
+
prepublish: "jk build -nm && jk",
|
88
|
+
postpublish: "jk",
|
89
|
+
test: "vitest run"
|
90
|
+
};
|
91
|
+
var peerDependencies = {
|
92
|
+
"@pnpm/filter-workspace-packages": "^7.2.13||^8.0.0||^9.0.0||^10.0.0||>=1000.0.0",
|
93
|
+
"@rollup/plugin-terser": "^0.4.4",
|
94
|
+
"esbuild-register": "^3.5.0",
|
95
|
+
postcss: "^8.4.47",
|
96
|
+
"rollup-plugin-esbuild": "^6.1.0",
|
97
|
+
"rollup-plugin-postcss": "^4.0.2",
|
98
|
+
"rollup-plugin-swc3": "^0.12.1",
|
99
|
+
typescript: "^4.0.0||^5.0.0",
|
100
|
+
"vite-bundle-analyzer": "0.16.0-beta.3"
|
101
|
+
};
|
102
|
+
var dependencies = {
|
103
|
+
"@inquirer/prompts": "^7.2.0",
|
104
|
+
"@jiek/pkger": "workspace:^",
|
105
|
+
"@jiek/rollup-plugin-dts": "^6.3.8",
|
106
|
+
"@jiek/utils": "workspace:^",
|
107
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
108
|
+
"@rollup/plugin-inject": "^5.0.5",
|
109
|
+
"@rollup/plugin-json": "^6.0.1",
|
110
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
111
|
+
"cli-progress": "^3.12.0",
|
112
|
+
commander: "^12.0.0",
|
113
|
+
"detect-indent": "^6.1.0",
|
114
|
+
execa: "~9.3.1",
|
115
|
+
"js-yaml": "^4.1.0",
|
116
|
+
"jsonc-parser": "^3.2.1",
|
117
|
+
koa: "^2.15.3",
|
118
|
+
rollup: "^4.0.0"
|
119
|
+
};
|
120
|
+
var devDependencies = {
|
121
|
+
"@npm/types": "^1.0.2",
|
122
|
+
"@pnpm/filter-workspace-packages": "^7.2.13",
|
123
|
+
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
124
|
+
"@rollup/plugin-terser": "^0.4.4",
|
125
|
+
"@types/cli-progress": "^3.11.5",
|
126
|
+
"@types/inquirer": "^9.0.7",
|
127
|
+
"@types/js-yaml": "^4.0.9",
|
128
|
+
"@types/koa": "^2.15.0",
|
129
|
+
"@types/micromatch": "^4.0.6",
|
130
|
+
"@types/react": "^18.3.14",
|
131
|
+
"esbuild-register": "^3.5.0",
|
132
|
+
micromatch: "^4.0.5",
|
133
|
+
"node-sass": "^9.0.0",
|
134
|
+
postcss: "^8.4.47",
|
135
|
+
"rollup-plugin-esbuild": "^6.1.0",
|
136
|
+
"rollup-plugin-postcss": "^4.0.2",
|
137
|
+
"rollup-plugin-swc3": "^0.12.1",
|
138
|
+
"vite-bundle-analyzer": "0.16.0-beta.3"
|
139
|
+
};
|
140
|
+
var pkg = {
|
141
|
+
name: name,
|
142
|
+
type: type,
|
143
|
+
version: version,
|
144
|
+
description: description$1,
|
145
|
+
author: author,
|
146
|
+
homepage: homepage,
|
147
|
+
repository: repository,
|
148
|
+
bugs: bugs,
|
149
|
+
keywords: keywords,
|
150
|
+
exports: exports$1,
|
151
|
+
imports: imports,
|
152
|
+
bin: bin,
|
153
|
+
files: files,
|
154
|
+
scripts: scripts,
|
155
|
+
peerDependencies: peerDependencies,
|
156
|
+
dependencies: dependencies,
|
157
|
+
devDependencies: devDependencies
|
158
|
+
};
|
159
|
+
|
160
|
+
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.");
|
161
|
+
if (filterSupport.type !== "" && meta.IS_WORKSPACE) {
|
162
|
+
commander.program.option("-f, --filter <filter>", descriptions.filterDescription);
|
163
|
+
}
|
164
|
+
|
165
|
+
const FILE_TEMPLATE = (manifest) => `
|
166
|
+
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
167
|
+
`.trimStart();
|
168
|
+
const ROLLUP_BIN = require$1.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
169
|
+
const isDefault = process__default.default.env.JIEK_BIN__FILENAME === "build.cjs";
|
170
|
+
const description = `
|
171
|
+
Build the package according to the 'exports' field from the package.json.
|
172
|
+
If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
|
173
|
+
${isDefault ? "This command is the default command." : ""}
|
174
|
+
`.trim();
|
175
|
+
let DEFAULT_BUILDER_TYPE;
|
176
|
+
Object.entries(base.BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
177
|
+
try {
|
178
|
+
require$1.resolve(packageName);
|
179
|
+
DEFAULT_BUILDER_TYPE = type;
|
180
|
+
} catch {
|
181
|
+
}
|
182
|
+
});
|
183
|
+
if (!DEFAULT_BUILDER_TYPE) {
|
184
|
+
DEFAULT_BUILDER_TYPE = "esbuild";
|
185
|
+
}
|
186
|
+
const buildFilterDescription = `
|
187
|
+
${descriptions.filterDescription}
|
188
|
+
If you pass the --filter option, it will merge into the filters of the command.
|
189
|
+
`.trim();
|
190
|
+
const buildEntriesDescription = `
|
191
|
+
${descriptions.entriesDescription}
|
192
|
+
If you pass the --entries option, it will merge into the entries of the command.
|
193
|
+
`.trim();
|
194
|
+
let command = isDefault ? (() => {
|
195
|
+
const c = commander.program.name("jb/jiek-build").helpCommand(false);
|
196
|
+
if (meta.IS_WORKSPACE) {
|
197
|
+
c.argument("[filters]", buildFilterDescription);
|
198
|
+
} else {
|
199
|
+
c.argument("[entries]", buildEntriesDescription);
|
200
|
+
}
|
201
|
+
return c;
|
202
|
+
})() : commander.program.command(`build [${meta.IS_WORKSPACE ? "filters" : "entries"}]`);
|
203
|
+
command = command.description(description).option("-t, --type <TYPE>", `The type of build, support ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}.`, (v) => {
|
204
|
+
if (!base.BUILDER_TYPES.includes(v)) {
|
205
|
+
throw new Error(`The value of 'type' must be ${base.BUILDER_TYPES.map((s) => `"${s}"`).join(", ")}`);
|
206
|
+
}
|
207
|
+
return String(v);
|
208
|
+
}, "esbuild").option("-o, --outdir <OUTDIR>", descriptions.outdirDescription, String, "dist").option("-e, --entries <ENTRIES>", descriptions.entriesDescription).option("--external <EXTERNAL>", "Specify the external dependencies of the package.", String).option("--noConvert", "Specify the `crossModuleConvertor` option to false.", optionParser.parseBoolean).option("-nj, --noJs", "Do not output js files.", optionParser.parseBoolean).option("-nd, --noDts", "Do not output dts files.", optionParser.parseBoolean).option("-nm, --noMin", "Do not output minify files.", optionParser.parseBoolean).option(
|
209
|
+
"--minType <MINTYPE>",
|
210
|
+
'The type of minify, support "builder" and "terser".',
|
211
|
+
(v) => {
|
212
|
+
if (!["builder", "terser"].includes(v)) {
|
213
|
+
throw new Error('The value of `minType` must be "builder" or "terser"');
|
214
|
+
}
|
215
|
+
return String(v);
|
216
|
+
}
|
217
|
+
).option("-nc, --noClean", "Do not clean the output directory before building.", optionParser.parseBoolean).option(
|
218
|
+
"-om, --onlyMin",
|
219
|
+
"Only output minify files, but dts files will still be output, it only replaces the js files.",
|
220
|
+
optionParser.parseBoolean
|
221
|
+
);
|
222
|
+
command = command.option("--features.keepImportAttributes", "Keep the import attributes in the output.");
|
223
|
+
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);
|
224
|
+
command = command.option("-w, --watch", "Watch the file changes.", optionParser.parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
|
225
|
+
command = analyzer.registerAnalyzerCommandOptions(command);
|
226
|
+
command = command.option("-s, --silent", "Don't display logs.", optionParser.parseBoolean).option("-v, --verbose", "Display debug logs.", optionParser.parseBoolean);
|
227
|
+
command.action(async (commandFiltersOrEntries, options) => {
|
228
|
+
let {
|
229
|
+
type,
|
230
|
+
outdir,
|
231
|
+
watch,
|
232
|
+
silent,
|
233
|
+
verbose,
|
234
|
+
entries: optionEntries,
|
235
|
+
external,
|
236
|
+
noConvert,
|
237
|
+
noJs: withoutJs,
|
238
|
+
noDts: withoutDts,
|
239
|
+
noMin: withoutMin,
|
240
|
+
minType: minifyType,
|
241
|
+
noClean,
|
242
|
+
onlyMin,
|
243
|
+
tsconfig,
|
244
|
+
dtsconfig
|
245
|
+
} = options;
|
246
|
+
const resolvedType = type ?? DEFAULT_BUILDER_TYPE;
|
247
|
+
if (!withoutJs) {
|
248
|
+
await checkDependency.checkDependency(base.BUILDER_TYPE_PACKAGE_NAME_MAP[resolvedType]);
|
249
|
+
if (minifyType === "builder") {
|
250
|
+
minifyType = resolvedType;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
if (!withoutMin && minifyType === "terser") {
|
254
|
+
await checkDependency.checkDependency("@rollup/plugin-terser");
|
255
|
+
}
|
256
|
+
let shouldPassThrough = false;
|
257
|
+
const passThroughOptions = process__default.default.argv.reduce(
|
258
|
+
(acc, value) => {
|
259
|
+
if (shouldPassThrough) {
|
260
|
+
acc.push(value);
|
261
|
+
}
|
262
|
+
if (value === "--") {
|
263
|
+
shouldPassThrough = true;
|
264
|
+
}
|
265
|
+
return acc;
|
266
|
+
},
|
267
|
+
[]
|
268
|
+
);
|
269
|
+
const shouldCreateServer = [
|
270
|
+
options.ana === true && options["ana.mode"] === "server"
|
271
|
+
].some(Boolean);
|
272
|
+
const server$1 = shouldCreateServer ? server.createServer(options.port, "localhost") : void 0;
|
273
|
+
const {
|
274
|
+
ANALYZER_ENV,
|
275
|
+
refreshAnalyzer
|
276
|
+
} = await analyzer.useAnalyzer(options, server$1);
|
277
|
+
const { build } = loadConfig.loadConfig();
|
278
|
+
silent = silent ?? build?.silent ?? false;
|
279
|
+
if (withoutMin && onlyMin) {
|
280
|
+
throw new Error("Cannot use both --without-minify and --only-minify");
|
281
|
+
}
|
282
|
+
if (onlyMin && withoutJs) {
|
283
|
+
throw new Error("Cannot use --without-js and --only-minify at the same time");
|
284
|
+
}
|
285
|
+
let entries = [
|
286
|
+
optionEntries,
|
287
|
+
meta.IS_WORKSPACE ? void 0 : commandFiltersOrEntries
|
288
|
+
].filter(Boolean).join(",");
|
289
|
+
if (entries.length === 0) {
|
290
|
+
entries = void 0;
|
291
|
+
}
|
292
|
+
const env = {
|
293
|
+
...ANALYZER_ENV,
|
294
|
+
JIEK_BUILDER: type,
|
295
|
+
JIEK_OUT_DIR: outdir,
|
296
|
+
JIEK_CLEAN: String(!noClean),
|
297
|
+
JIEK_ENTRIES: entries,
|
298
|
+
JIEK_EXTERNAL: external,
|
299
|
+
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
300
|
+
JIEK_WITHOUT_JS: String(withoutJs),
|
301
|
+
JIEK_WITHOUT_DTS: String(withoutDts),
|
302
|
+
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
303
|
+
JIEK_ONLY_MINIFY: String(onlyMin),
|
304
|
+
JIEK_MINIFY_TYPE: minifyType,
|
305
|
+
JIEK_TSCONFIG: tsconfig,
|
306
|
+
JIEK_DTSCONFIG: dtsconfig,
|
307
|
+
JIEK_FEATURES: JSON.stringify({
|
308
|
+
keepImportAttributes: options["features.keepImportAttributes"]
|
309
|
+
}),
|
310
|
+
...process__default.default.env
|
311
|
+
};
|
312
|
+
const multiBars = new cliProgress.MultiBar({
|
313
|
+
clearOnComplete: false,
|
314
|
+
hideCursor: true,
|
315
|
+
format: "- {bar} | {status} | {pkgName} | {input} | {message}"
|
316
|
+
}, cliProgress.Presets.shades_classic);
|
317
|
+
const { wd } = getWD.getWD();
|
318
|
+
const wdNodeModules = path__default.default.resolve(wd, "node_modules");
|
319
|
+
if (!fs.existsSync(wdNodeModules)) {
|
320
|
+
fs.mkdirSync(wdNodeModules);
|
321
|
+
}
|
322
|
+
const resolveByJiekTemp = (...paths) => path__default.default.resolve(wdNodeModules, ".jiek", ...paths);
|
323
|
+
const jiekTemp = resolveByJiekTemp();
|
324
|
+
if (!fs.existsSync(jiekTemp)) {
|
325
|
+
fs.mkdirSync(jiekTemp);
|
326
|
+
}
|
327
|
+
let i = 0;
|
328
|
+
const buildPackage = async ([pkgCWD, manifest], {
|
329
|
+
resolveByJiekTemp: resolveByJiekTemp2
|
330
|
+
}) => {
|
331
|
+
if (manifest.name == null) {
|
332
|
+
throw new Error("package.json must have a name field");
|
333
|
+
}
|
334
|
+
const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
|
335
|
+
const configFile = resolveByJiekTemp2(
|
336
|
+
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
337
|
+
);
|
338
|
+
fs.writeFileSync(configFile, FILE_TEMPLATE(manifest));
|
339
|
+
const command2 = [ROLLUP_BIN, "--silent", "-c", configFile];
|
340
|
+
if (tsRegister.tsRegisterName != null) {
|
341
|
+
command2.unshift(`node -r ${tsRegister.tsRegisterName}`);
|
342
|
+
}
|
343
|
+
if (watch) {
|
344
|
+
command2.push("--watch");
|
345
|
+
}
|
346
|
+
command2.push(...passThroughOptions);
|
347
|
+
const child = execa.execaCommand(command2.join(" "), {
|
348
|
+
ipc: true,
|
349
|
+
cwd: pkgCWD,
|
350
|
+
windowsHide: true,
|
351
|
+
env: {
|
352
|
+
...env,
|
353
|
+
JIEK_NAME: manifest.name,
|
354
|
+
JIEK_ROOT: wd
|
355
|
+
}
|
356
|
+
});
|
357
|
+
const bars = {};
|
358
|
+
const times = {};
|
359
|
+
const locks = {};
|
360
|
+
let inputMaxLen = 10;
|
361
|
+
child.on("message", (e) => {
|
362
|
+
if (silent && [
|
363
|
+
"init",
|
364
|
+
"progress",
|
365
|
+
"watchChange"
|
366
|
+
].includes(e.type)) return;
|
367
|
+
switch (e.type) {
|
368
|
+
case "init": {
|
369
|
+
const { leafMap, targetsLength } = e.data;
|
370
|
+
const leafs = Array.from(leafMap.entries()).flatMap(
|
371
|
+
([input, pathAndConditions]) => pathAndConditions.map(([path2, ...conditions]) => ({
|
372
|
+
input,
|
373
|
+
path: path2,
|
374
|
+
conditions
|
375
|
+
}))
|
376
|
+
);
|
377
|
+
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`;
|
378
|
+
if (watch) {
|
379
|
+
initMessage += " and watching...";
|
380
|
+
}
|
381
|
+
console.log(initMessage);
|
382
|
+
leafs.forEach(({ input }) => {
|
383
|
+
inputMaxLen = Math.max(inputMaxLen, input.length);
|
384
|
+
});
|
385
|
+
leafs.forEach(({ input, path: path2 }) => {
|
386
|
+
const key = `${input}:${path2}`;
|
387
|
+
if (bars[key]) return;
|
388
|
+
bars[key] = multiBars.create(50, 0, {
|
389
|
+
pkgName: manifest.name,
|
390
|
+
input: input.padEnd(inputMaxLen + 5),
|
391
|
+
status: "waiting".padEnd(10)
|
392
|
+
}, {
|
393
|
+
barsize: 20,
|
394
|
+
linewrap: true
|
395
|
+
});
|
396
|
+
});
|
397
|
+
break;
|
398
|
+
}
|
399
|
+
case "progress": {
|
400
|
+
const {
|
401
|
+
path: path2,
|
402
|
+
tags,
|
403
|
+
input,
|
404
|
+
event,
|
405
|
+
message
|
406
|
+
} = e.data;
|
407
|
+
const bar = bars[`${input}:${path2}`];
|
408
|
+
if (!bar) return;
|
409
|
+
const time = times[`${input}:${path2}`];
|
410
|
+
bar.update(
|
411
|
+
{
|
412
|
+
start: 0,
|
413
|
+
resolve: 20,
|
414
|
+
end: 50
|
415
|
+
}[event ?? "start"] ?? 0,
|
416
|
+
{
|
417
|
+
input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
|
418
|
+
status: event?.padEnd(10),
|
419
|
+
message: `${tags?.join(", ")}: ${message}`
|
420
|
+
}
|
421
|
+
);
|
422
|
+
break;
|
423
|
+
}
|
424
|
+
case "watchChange": {
|
425
|
+
const {
|
426
|
+
path: path2,
|
427
|
+
input
|
428
|
+
} = e.data;
|
429
|
+
const key = `${input}:${path2}`;
|
430
|
+
const bar = bars[key];
|
431
|
+
if (!bar) return;
|
432
|
+
let time = times[key] ?? 1;
|
433
|
+
if (!locks[key]) {
|
434
|
+
time += 1;
|
435
|
+
times[key] = time;
|
436
|
+
setTimeout(() => {
|
437
|
+
locks[key] = false;
|
438
|
+
}, 100);
|
439
|
+
bar.update(0, {
|
440
|
+
input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
|
441
|
+
status: "watching".padEnd(10),
|
442
|
+
message: "watching..."
|
443
|
+
});
|
444
|
+
}
|
445
|
+
locks[key] = true;
|
446
|
+
break;
|
447
|
+
}
|
448
|
+
case "modulesAnalyze": {
|
449
|
+
const {
|
450
|
+
data: {
|
451
|
+
type: type2,
|
452
|
+
modules: pkgModules
|
453
|
+
}
|
454
|
+
} = e;
|
455
|
+
void refreshAnalyzer(
|
456
|
+
pkgCWD,
|
457
|
+
pkgModules.map((m) => ({
|
458
|
+
...m,
|
459
|
+
type: type2,
|
460
|
+
filename: `${manifest.name}/${m.filename}`,
|
461
|
+
label: `${manifest.name}/${m.label}`
|
462
|
+
}))
|
463
|
+
);
|
464
|
+
break;
|
465
|
+
}
|
466
|
+
case "debug": {
|
467
|
+
console.log(...Array.isArray(e.data) ? e.data : [e.data]);
|
468
|
+
break;
|
469
|
+
}
|
470
|
+
}
|
471
|
+
});
|
472
|
+
await new Promise((resolve, reject) => {
|
473
|
+
let errorStr = `rollup build failed
|
474
|
+
package name: ${manifest.name}
|
475
|
+
cwd: ${pkgCWD}
|
476
|
+
|
477
|
+
`;
|
478
|
+
child.stderr?.on("data", (data) => {
|
479
|
+
errorStr += data;
|
480
|
+
});
|
481
|
+
child.once("exit", (code) => code === 0 ? resolve() : reject(new Error(errorStr)));
|
482
|
+
verbose && child.stdout?.pipe(process__default.default.stdout);
|
483
|
+
});
|
484
|
+
};
|
485
|
+
const commandFilters = meta.IS_WORKSPACE ? commandFiltersOrEntries : void 0;
|
486
|
+
const filters = [
|
487
|
+
.../* @__PURE__ */ new Set([
|
488
|
+
...commander.program.getOptionValue("filter")?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? [],
|
489
|
+
...commandFilters?.split(",").map((s) => s.trim()).filter((s) => s.length > 0) ?? []
|
490
|
+
])
|
491
|
+
];
|
492
|
+
try {
|
493
|
+
const packages = (filters.length > 0 ? await filterSupport.filterPackagesGraph(filters) : [await filterSupport.getSelectedProjectsGraph()]).flatMap(({ value }) => Object.entries(value ?? {}));
|
494
|
+
await Promise.allSettled(
|
495
|
+
packages.map(async ([cwd, manifest]) => buildPackage([cwd, manifest], { resolveByJiekTemp }))
|
496
|
+
);
|
497
|
+
} finally {
|
498
|
+
multiBars.stop();
|
499
|
+
!silent && console.log("Build complete");
|
500
|
+
}
|
501
|
+
});
|
502
|
+
|
503
|
+
if (process__default.default.env.JIEK_BIN__FILENAME === "build.cjs") {
|
504
|
+
parseArgv__default.default();
|
505
|
+
}
|