jiek 2.2.1 → 2.2.2
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/dist/cli-only-build.cjs +239 -127
- package/dist/cli-only-build.js +249 -137
- package/dist/rollup/index.cjs +19 -3
- package/dist/rollup/index.js +19 -3
- package/package.json +9 -5
- package/src/commands/build/analyzer.ts +122 -0
- package/src/commands/build/client/analyzer.tsx +121 -0
- package/src/commands/build/client/index.ts +28 -0
- package/src/commands/build.ts +25 -153
- package/src/commands/utils/optionParser.ts +4 -0
- package/src/rollup/index.ts +18 -2
- package/src/server.ts +9 -1
- package/src/utils/checkDependency.ts +22 -0
- package/src/utils/ts.ts +3 -3
package/dist/cli-only-build.cjs
CHANGED
@@ -7,9 +7,9 @@ var commander = require('commander');
|
|
7
7
|
var jsYaml = require('js-yaml');
|
8
8
|
var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
|
9
9
|
var process$1 = require('node:process');
|
10
|
-
var prompts = require('@inquirer/prompts');
|
11
10
|
var cliProgress = require('cli-progress');
|
12
11
|
var execa = require('execa');
|
12
|
+
var prompts = require('@inquirer/prompts');
|
13
13
|
var Koa = require('koa');
|
14
14
|
|
15
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
@@ -120,7 +120,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
|
|
120
120
|
|
121
121
|
var name = "jiek";
|
122
122
|
var type = "module";
|
123
|
-
var version = "2.2.
|
123
|
+
var version = "2.2.1";
|
124
124
|
var description$1 = "A lightweight toolkit for compiling and managing libraries based on `package.json` metadata and suitable for `Monorepo`.";
|
125
125
|
var author = "YiJie <yijie4188@gmail.com>";
|
126
126
|
var homepage = "https://github.com/NWYLZW/jiek/tree/master/packages/jiek#readme";
|
@@ -151,7 +151,11 @@ var exports$1 = {
|
|
151
151
|
"./rollup": "./src/rollup/index.ts"
|
152
152
|
};
|
153
153
|
var imports = {
|
154
|
-
"#~/*":
|
154
|
+
"#~/*": [
|
155
|
+
"./src/*",
|
156
|
+
"./src/*/index.ts",
|
157
|
+
"./src/*/index.tsx"
|
158
|
+
]
|
155
159
|
};
|
156
160
|
var bin = {
|
157
161
|
jiek: "bin/jiek.js",
|
@@ -182,7 +186,7 @@ var peerDependencies = {
|
|
182
186
|
"rollup-plugin-postcss": "^4.0.2",
|
183
187
|
"rollup-plugin-swc3": "^0.12.1",
|
184
188
|
typescript: "^4.0.0||^5.0.0",
|
185
|
-
"vite-bundle-analyzer": "
|
189
|
+
"vite-bundle-analyzer": "0.16.0-beta.1"
|
186
190
|
};
|
187
191
|
var dependencies = {
|
188
192
|
"@inquirer/prompts": "^7.1.0",
|
@@ -213,6 +217,7 @@ var devDependencies = {
|
|
213
217
|
"@types/js-yaml": "^4.0.9",
|
214
218
|
"@types/koa": "^2.15.0",
|
215
219
|
"@types/micromatch": "^4.0.6",
|
220
|
+
"@types/react": "^18.3.14",
|
216
221
|
"esbuild-register": "^3.5.0",
|
217
222
|
micromatch: "^4.0.5",
|
218
223
|
"node-sass": "^9.0.0",
|
@@ -220,7 +225,7 @@ var devDependencies = {
|
|
220
225
|
"rollup-plugin-esbuild": "^6.1.0",
|
221
226
|
"rollup-plugin-postcss": "^4.0.2",
|
222
227
|
"rollup-plugin-swc3": "^0.12.1",
|
223
|
-
"vite-bundle-analyzer": "
|
228
|
+
"vite-bundle-analyzer": "0.16.0-beta.1"
|
224
229
|
};
|
225
230
|
var pkg = {
|
226
231
|
name: name,
|
@@ -266,6 +271,212 @@ if (type$1 !== "" && IS_WORKSPACE) {
|
|
266
271
|
commander.program.option("-f, --filter <filter>", filterDescription);
|
267
272
|
}
|
268
273
|
|
274
|
+
function Main() {
|
275
|
+
const { useState, useMemo, useEffect, useCallback } = React;
|
276
|
+
const [path, setPath] = useState(() => location.pathname.replace(/^\/ana\/?/, ""));
|
277
|
+
const [pkgName, entry] = useMemo(() => {
|
278
|
+
const pkgName2 = /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(path)?.[1];
|
279
|
+
return [
|
280
|
+
pkgName2,
|
281
|
+
pkgName2 != null ? path.replace(`${pkgName2}/`, "") : void 0
|
282
|
+
];
|
283
|
+
}, [path]);
|
284
|
+
const push = useCallback((newPath) => {
|
285
|
+
setPath(newPath);
|
286
|
+
document.title = `${document.title.replace(/ - \/.*/, "")} - /${newPath}`;
|
287
|
+
history.pushState(null, "", `/ana/${newPath}`);
|
288
|
+
}, []);
|
289
|
+
const filterModules = useCallback((startWith) => {
|
290
|
+
const modules = analyzeModule.filter((m) => m.filename.startsWith(startWith));
|
291
|
+
dispatchEvent(new CustomEvent("send:filter", { detail: { analyzeModule: modules } }));
|
292
|
+
}, []);
|
293
|
+
useEffect(() => {
|
294
|
+
if (path !== "") {
|
295
|
+
document.title = `${document.title.replace(/ - \/.*/, "")} - /${path}`;
|
296
|
+
} else {
|
297
|
+
document.title = document.title.replace(/ - \/.*/, "");
|
298
|
+
}
|
299
|
+
filterModules(path);
|
300
|
+
}, [path, filterModules]);
|
301
|
+
useEffect(() => {
|
302
|
+
const offGraphClick = listen("graph:click", ({ detail }) => {
|
303
|
+
if (!detail)
|
304
|
+
return;
|
305
|
+
let root = detail.node;
|
306
|
+
while (root.parent) {
|
307
|
+
root = root.parent;
|
308
|
+
}
|
309
|
+
if (root.filename === path)
|
310
|
+
return;
|
311
|
+
push(root.filename);
|
312
|
+
});
|
313
|
+
return () => {
|
314
|
+
offGraphClick();
|
315
|
+
};
|
316
|
+
}, [push]);
|
317
|
+
function listen(type, listener) {
|
318
|
+
window.addEventListener(type, listener);
|
319
|
+
return () => {
|
320
|
+
window.removeEventListener(type, listener);
|
321
|
+
};
|
322
|
+
}
|
323
|
+
return /* @__PURE__ */ React.createElement(
|
324
|
+
"div",
|
325
|
+
{
|
326
|
+
style: {
|
327
|
+
padding: "12px 55px"
|
328
|
+
}
|
329
|
+
},
|
330
|
+
"/",
|
331
|
+
/* @__PURE__ */ React.createElement(
|
332
|
+
"select",
|
333
|
+
{
|
334
|
+
style: {
|
335
|
+
appearance: "none",
|
336
|
+
border: "none",
|
337
|
+
background: "none"
|
338
|
+
},
|
339
|
+
value: pkgName,
|
340
|
+
onChange: (e) => push(e.target.value)
|
341
|
+
},
|
342
|
+
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
343
|
+
analyzeModule.map((m) => /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(m.filename)?.[1]).filter((v, i, a) => a.indexOf(v) === i).map((v) => /* @__PURE__ */ React.createElement("option", { key: v, value: v }, v))
|
344
|
+
),
|
345
|
+
pkgName != null && /* @__PURE__ */ React.createElement(React.Fragment, null, "/", /* @__PURE__ */ React.createElement(
|
346
|
+
"select",
|
347
|
+
{
|
348
|
+
style: {
|
349
|
+
appearance: "none",
|
350
|
+
border: "none",
|
351
|
+
background: "none"
|
352
|
+
},
|
353
|
+
value: entry,
|
354
|
+
onChange: (e) => push(`${pkgName}/${e.target.value}`)
|
355
|
+
},
|
356
|
+
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
357
|
+
analyzeModule.filter((m) => m.filename.startsWith(`${pkgName}/`)).map((m) => m.filename.replace(`${pkgName}/`, "")).filter((v, i, a) => a.indexOf(v) === i).map((v) => /* @__PURE__ */ React.createElement("option", { key: v, value: v }, v))
|
358
|
+
))
|
359
|
+
);
|
360
|
+
}
|
361
|
+
|
362
|
+
function render() {
|
363
|
+
CUSTOM_SIDE_BAR = true;
|
364
|
+
window.addEventListener("client:ready", () => setTimeout(() => {
|
365
|
+
window.dispatchEvent(
|
366
|
+
new CustomEvent("send:ui", {
|
367
|
+
detail: { type: "Main", Component: __REPLACE_INJECT__ }
|
368
|
+
})
|
369
|
+
);
|
370
|
+
}, 0));
|
371
|
+
}
|
372
|
+
const CLIENT_CUSTOM_RENDER_SCRIPT = [
|
373
|
+
Main.toString(),
|
374
|
+
render.toString().replace("__REPLACE_INJECT__", Main.name),
|
375
|
+
`(${render.name})()`
|
376
|
+
].join("\n");
|
377
|
+
|
378
|
+
function parseBoolean(v) {
|
379
|
+
if (v === void 0)
|
380
|
+
return true;
|
381
|
+
return Boolean(v);
|
382
|
+
}
|
383
|
+
|
384
|
+
async function checkDependency(dependency) {
|
385
|
+
try {
|
386
|
+
require.resolve(dependency);
|
387
|
+
} catch {
|
388
|
+
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
389
|
+
const { notWorkspace } = getWD();
|
390
|
+
const command = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
|
391
|
+
if (await prompts.confirm({ message: "Do you want to install it now?" })) {
|
392
|
+
await execa.execaCommand(command);
|
393
|
+
} else {
|
394
|
+
console.warn(`You can run the command '${command}' to install it manually.`);
|
395
|
+
process__default.default.exit(1);
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
const registerAnalyzerCommandOptions = (command) => command.option("--ana", "Enable the bundle analyzer.", parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option(
|
401
|
+
"--ana.mode <MODE>",
|
402
|
+
'The mode of the bundle analyzer, support "static", "json" and "server".',
|
403
|
+
"server"
|
404
|
+
).option("--ana.open", "Open the bundle analyzer in the browser.", parseBoolean).option(
|
405
|
+
"--ana.size <SIZE>",
|
406
|
+
'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
|
407
|
+
"parsed"
|
408
|
+
);
|
409
|
+
const useAnalyzer = async (options, server) => {
|
410
|
+
const modules = [];
|
411
|
+
let bundleAnalyzerModule;
|
412
|
+
const analyzer = options.ana ? {
|
413
|
+
dir: options["ana.dir"],
|
414
|
+
mode: options["ana.mode"],
|
415
|
+
open: options["ana.open"],
|
416
|
+
size: options["ana.size"]
|
417
|
+
} : void 0;
|
418
|
+
if (options.ana && ![
|
419
|
+
"stat",
|
420
|
+
"parsed",
|
421
|
+
"gzip"
|
422
|
+
].includes(analyzer?.size ?? "")) {
|
423
|
+
throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
|
424
|
+
}
|
425
|
+
if (analyzer) {
|
426
|
+
await checkDependency("vite-bundle-analyzer");
|
427
|
+
bundleAnalyzerModule = await import('vite-bundle-analyzer');
|
428
|
+
}
|
429
|
+
const refreshAnalyzer = async (cwd, applyModules) => {
|
430
|
+
if (!(analyzer && server && bundleAnalyzerModule))
|
431
|
+
return;
|
432
|
+
if (analyzer.mode === "json") {
|
433
|
+
const anaDir = path__default.default.resolve(cwd, analyzer.dir);
|
434
|
+
if (!fs.existsSync(anaDir)) {
|
435
|
+
fs.mkdirSync(anaDir, { recursive: true });
|
436
|
+
}
|
437
|
+
const gitIgnorePath = path__default.default.resolve(anaDir, ".gitignore");
|
438
|
+
if (!fs.existsSync(gitIgnorePath)) {
|
439
|
+
fs.writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
|
440
|
+
}
|
441
|
+
const npmIgnorePath = path__default.default.resolve(anaDir, ".npmignore");
|
442
|
+
if (!fs.existsSync(npmIgnorePath)) {
|
443
|
+
fs.writeFileSync(npmIgnorePath, "*\n");
|
444
|
+
}
|
445
|
+
if (!fs.statSync(anaDir).isDirectory()) {
|
446
|
+
throw new Error(`The directory '${anaDir}' is not a directory.`);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
const { renderView, injectHTMLTag } = bundleAnalyzerModule;
|
450
|
+
applyModules.forEach((m) => {
|
451
|
+
const index = modules.findIndex(({ filename }) => filename === m.filename);
|
452
|
+
if (index === -1) {
|
453
|
+
modules.push(m);
|
454
|
+
} else {
|
455
|
+
modules[index] = m;
|
456
|
+
}
|
457
|
+
});
|
458
|
+
let html = await renderView(modules, {
|
459
|
+
title: `Jiek Analyzer`,
|
460
|
+
mode: analyzer.size
|
461
|
+
});
|
462
|
+
html = injectHTMLTag({
|
463
|
+
html,
|
464
|
+
injectTo: "body",
|
465
|
+
descriptors: [
|
466
|
+
{ kind: "script", text: CLIENT_CUSTOM_RENDER_SCRIPT }
|
467
|
+
]
|
468
|
+
});
|
469
|
+
void server.renderTo("/ana", html);
|
470
|
+
};
|
471
|
+
return {
|
472
|
+
modules,
|
473
|
+
refreshAnalyzer,
|
474
|
+
ANALYZER_ENV: {
|
475
|
+
JIEK_ANALYZER: analyzer ? JSON.stringify(analyzer) : void 0
|
476
|
+
}
|
477
|
+
};
|
478
|
+
};
|
479
|
+
|
269
480
|
const BUILDER_TYPES = ["esbuild", "swc"];
|
270
481
|
const BUILDER_TYPE_PACKAGE_NAME_MAP = {
|
271
482
|
esbuild: "rollup-plugin-esbuild",
|
@@ -277,7 +488,11 @@ const createServer = (port, host) => {
|
|
277
488
|
app.listen(port, host);
|
278
489
|
const streams = /* @__PURE__ */ new Map();
|
279
490
|
app.use(async (ctx) => {
|
280
|
-
|
491
|
+
let stream = streams.get(ctx.path);
|
492
|
+
if (stream == null) {
|
493
|
+
const maybeKey = streams.keys().find((p) => ctx.path.startsWith(p));
|
494
|
+
stream = maybeKey != null ? streams.get(maybeKey) : void 0;
|
495
|
+
}
|
281
496
|
if (stream != null) {
|
282
497
|
ctx.body = stream;
|
283
498
|
}
|
@@ -405,21 +620,6 @@ Build the package according to the 'exports' field from the package.json.
|
|
405
620
|
If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
|
406
621
|
${isDefault ? "This command is the default command." : ""}
|
407
622
|
`.trim();
|
408
|
-
async function checkDependency(dependency) {
|
409
|
-
try {
|
410
|
-
require$1.resolve(dependency);
|
411
|
-
} catch {
|
412
|
-
console.error(`The package '${dependency}' is not installed, please install it first.`);
|
413
|
-
const { notWorkspace } = getWD();
|
414
|
-
const command2 = `pnpm install -${notWorkspace ? "" : "w"}D ${dependency}`;
|
415
|
-
if (await prompts.confirm({ message: "Do you want to install it now?" })) {
|
416
|
-
await execa.execaCommand(command2);
|
417
|
-
} else {
|
418
|
-
console.warn(`You can run the command '${command2}' to install it manually.`);
|
419
|
-
process__default.default.exit(1);
|
420
|
-
}
|
421
|
-
}
|
422
|
-
}
|
423
623
|
let DEFAULT_BUILDER_TYPE;
|
424
624
|
Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
425
625
|
try {
|
@@ -431,11 +631,6 @@ Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
|
431
631
|
if (!DEFAULT_BUILDER_TYPE) {
|
432
632
|
DEFAULT_BUILDER_TYPE = "esbuild";
|
433
633
|
}
|
434
|
-
function parseBoolean(v) {
|
435
|
-
if (v === void 0)
|
436
|
-
return true;
|
437
|
-
return Boolean(v);
|
438
|
-
}
|
439
634
|
const buildFilterDescription = `
|
440
635
|
${filterDescription}
|
441
636
|
If you pass the --filter option, it will merge into the filters of the command.
|
@@ -474,11 +669,7 @@ command = command.description(description).option("-t, --type <TYPE>", `The type
|
|
474
669
|
);
|
475
670
|
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);
|
476
671
|
command = command.option("-w, --watch", "Watch the file changes.", parseBoolean).option("-p, --port <PORT>", "The port of the server.", Number.parseInt, 8888);
|
477
|
-
command = command
|
478
|
-
"--ana.size <SIZE>",
|
479
|
-
'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
|
480
|
-
"parsed"
|
481
|
-
);
|
672
|
+
command = registerAnalyzerCommandOptions(command);
|
482
673
|
command = command.option("-s, --silent", "Don't display logs.", parseBoolean).option("-v, --verbose", "Display debug logs.", parseBoolean);
|
483
674
|
command.action(async (commandFiltersOrEntries, options) => {
|
484
675
|
let {
|
@@ -526,43 +717,14 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
526
717
|
},
|
527
718
|
[]
|
528
719
|
);
|
529
|
-
const
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
const
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
size: options["ana.size"]
|
538
|
-
} : void 0;
|
539
|
-
if (options.ana && ![
|
540
|
-
"stat",
|
541
|
-
"parsed",
|
542
|
-
"gzip"
|
543
|
-
].includes(analyzer?.size ?? "")) {
|
544
|
-
throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
|
545
|
-
}
|
546
|
-
const server = analyzer && createServer(options.port, "localhost");
|
547
|
-
if (analyzer) {
|
548
|
-
await checkDependency("vite-bundle-analyzer");
|
549
|
-
const { renderView } = await import('vite-bundle-analyzer');
|
550
|
-
render = renderView;
|
551
|
-
}
|
552
|
-
const anaPaths = /* @__PURE__ */ new Set();
|
553
|
-
const refreshAnalyzer = async (subPath = "", renderModules = modules) => {
|
554
|
-
if (!(analyzer && server && render))
|
555
|
-
return;
|
556
|
-
const p = `/ana${subPath}`;
|
557
|
-
anaPaths.add(p);
|
558
|
-
void server.renderTo(
|
559
|
-
p,
|
560
|
-
await render(renderModules, {
|
561
|
-
title: `Jiek Analyzer - ${subPath}`,
|
562
|
-
mode: analyzer.size
|
563
|
-
})
|
564
|
-
);
|
565
|
-
};
|
720
|
+
const shouldCreateServer = [
|
721
|
+
options.ana === true && options["ana.mode"] === "server"
|
722
|
+
].some(Boolean);
|
723
|
+
const server = shouldCreateServer ? createServer(options.port, "localhost") : void 0;
|
724
|
+
const {
|
725
|
+
ANALYZER_ENV,
|
726
|
+
refreshAnalyzer
|
727
|
+
} = await useAnalyzer(options, server);
|
566
728
|
const { build } = loadConfig();
|
567
729
|
silent = silent ?? build?.silent ?? false;
|
568
730
|
if (withoutMin && onlyMin) {
|
@@ -579,7 +741,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
579
741
|
entries = void 0;
|
580
742
|
}
|
581
743
|
const env = {
|
582
|
-
|
744
|
+
...ANALYZER_ENV,
|
583
745
|
JIEK_BUILDER: type,
|
584
746
|
JIEK_OUT_DIR: outdir,
|
585
747
|
JIEK_CLEAN: String(!noClean),
|
@@ -621,27 +783,10 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
621
783
|
const rollupBinaryPath = require$1.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
622
784
|
let i = 0;
|
623
785
|
await Promise.all(
|
624
|
-
Object.entries(value).map(async ([
|
786
|
+
Object.entries(value).map(async ([pkgCWD, manifest]) => {
|
625
787
|
if (manifest.name == null) {
|
626
788
|
throw new Error("package.json must have a name field");
|
627
789
|
}
|
628
|
-
if (analyzer) {
|
629
|
-
const anaDir = path__default.default.resolve(dir, analyzer.dir);
|
630
|
-
if (!fs.existsSync(anaDir)) {
|
631
|
-
fs.mkdirSync(anaDir, { recursive: true });
|
632
|
-
}
|
633
|
-
const gitIgnorePath = path__default.default.resolve(anaDir, ".gitignore");
|
634
|
-
if (!fs.existsSync(gitIgnorePath)) {
|
635
|
-
fs.writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
|
636
|
-
}
|
637
|
-
const npmIgnorePath = path__default.default.resolve(anaDir, ".npmignore");
|
638
|
-
if (!fs.existsSync(npmIgnorePath)) {
|
639
|
-
fs.writeFileSync(npmIgnorePath, "*\n");
|
640
|
-
}
|
641
|
-
if (!fs.statSync(anaDir).isDirectory()) {
|
642
|
-
throw new Error(`The directory '${anaDir}' is not a directory.`);
|
643
|
-
}
|
644
|
-
}
|
645
790
|
const escapeManifestName = manifest.name.replace(/^@/g, "").replace(/\//g, "+");
|
646
791
|
const configFile = resolveByJiekTemp(
|
647
792
|
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
@@ -657,7 +802,7 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
657
802
|
command2.push(...passThroughOptions);
|
658
803
|
const child = execa.execaCommand(command2.join(" "), {
|
659
804
|
ipc: true,
|
660
|
-
cwd:
|
805
|
+
cwd: pkgCWD,
|
661
806
|
env: {
|
662
807
|
...env,
|
663
808
|
JIEK_NAME: manifest.name,
|
@@ -763,41 +908,18 @@ command.action(async (commandFiltersOrEntries, options) => {
|
|
763
908
|
const {
|
764
909
|
data: {
|
765
910
|
type: type2,
|
766
|
-
path: path2,
|
767
911
|
modules: pkgModules
|
768
912
|
}
|
769
913
|
} = e;
|
770
|
-
|
771
|
-
|
914
|
+
void refreshAnalyzer(
|
915
|
+
pkgCWD,
|
916
|
+
pkgModules.map((m) => ({
|
772
917
|
...m,
|
918
|
+
type: type2,
|
773
919
|
filename: `${manifest.name}/${m.filename}`,
|
774
920
|
label: `${manifest.name}/${m.label}`
|
775
|
-
}
|
776
|
-
const pushOrReplace = (arr) => {
|
777
|
-
const index = arr.findIndex(({ filename }) => filename === newM.filename);
|
778
|
-
if (index === -1) {
|
779
|
-
arr.push(newM);
|
780
|
-
} else {
|
781
|
-
arr[index] = newM;
|
782
|
-
}
|
783
|
-
};
|
784
|
-
pushOrReplace(modules);
|
785
|
-
if (type2 === "esm") {
|
786
|
-
pushOrReplace(esmModules);
|
787
|
-
}
|
788
|
-
if (type2 === "cjs") {
|
789
|
-
pushOrReplace(cjsModules);
|
790
|
-
}
|
791
|
-
});
|
792
|
-
void refreshAnalyzer();
|
793
|
-
void refreshAnalyzer(
|
794
|
-
`/${type2}`,
|
795
|
-
{
|
796
|
-
cjs: cjsModules,
|
797
|
-
esm: esmModules
|
798
|
-
}[type2]
|
921
|
+
}))
|
799
922
|
);
|
800
|
-
void refreshAnalyzer(`/${type2}/${manifest.name}/${path2.slice(2)}`, pkgModules);
|
801
923
|
break;
|
802
924
|
}
|
803
925
|
case "debug": {
|
@@ -834,17 +956,7 @@ ${errorStr}`)));
|
|
834
956
|
}
|
835
957
|
} finally {
|
836
958
|
multiBars.stop();
|
837
|
-
|
838
|
-
if (analyzer) {
|
839
|
-
message += ` and the analyzer is running at http://localhost:${options.port}/ana in ${analyzer.mode} mode.
|
840
|
-
`;
|
841
|
-
message += analyzer.open ? " The browser will open automatically.\n" : "";
|
842
|
-
if (anaPaths.size > 0) {
|
843
|
-
message += `The analyzer has ${anaPaths.size} pages:
|
844
|
-
${Array.from(anaPaths).map((p) => `http://localhost:${options.port}${p}`).join("\n")}`;
|
845
|
-
}
|
846
|
-
}
|
847
|
-
!silent && console.log(message);
|
959
|
+
!silent && console.log("Build complete");
|
848
960
|
}
|
849
961
|
});
|
850
962
|
|