jiek 2.2.7-alpha.3 → 2.2.7-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jiek-production-tag +0 -0
- package/dist/.internal/.chunks/{getWD.ZF0avqDB.cjs → filterSupport.4rM7f6jB.cjs} +38 -29
- package/dist/.internal/.chunks/{getWD.D6wq8Qc2.js → filterSupport.BXWpLBpT.js} +37 -28
- package/dist/.internal/.chunks/index.BHuJRlvZ.js +9059 -0
- package/dist/.internal/.chunks/index.Daihq2aI.cjs +9071 -0
- package/dist/.internal/.chunks/loadConfig.CFfzkm_p.js +110 -0
- package/dist/.internal/.chunks/loadConfig.OOKddvHF.cjs +117 -0
- package/dist/.internal/bin/common.cjs +757 -0
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/.internal/bin/common.js +750 -0
- package/dist/.internal/bridge.cjs +20 -2
- package/dist/.internal/bridge.js +19 -1
- package/dist/.internal/utils/filterSupport.cjs +1 -3
- package/dist/.internal/utils/filterSupport.js +1 -3
- package/dist/.internal/utils/loadConfig.cjs +8 -94
- package/dist/.internal/utils/loadConfig.js +7 -92
- package/dist/bin/build.cjs +2 -507
- package/dist/bin/index.cjs +5 -1
- package/package.json +2 -3
- package/src/bin/build.cts +2 -8
- package/src/bin/common.ts +3 -0
- package/src/bin/index.cts +2 -1
- package/src/commands/publish.ts +5 -0
- package/dist/.internal/.chunks/jiek_create-require.CWFWNQHj.cjs +0 -5
- package/dist/.internal/.chunks/jiek_create-require.CxSGbkTB.js +0 -5
- package/dist/.internal/commands/build/analyzer.cjs +0 -201
- package/dist/.internal/commands/build/analyzer.d.cts +0 -30
- package/dist/.internal/commands/build/analyzer.d.ts +0 -30
- package/dist/.internal/commands/build/analyzer.js +0 -195
- package/dist/.internal/commands/descriptions.cjs +0 -21
- package/dist/.internal/commands/descriptions.d.cts +0 -5
- package/dist/.internal/commands/descriptions.d.ts +0 -5
- package/dist/.internal/commands/descriptions.js +0 -17
- package/dist/.internal/commands/meta.cjs +0 -16
- package/dist/.internal/commands/meta.d.cts +0 -3
- package/dist/.internal/commands/meta.d.ts +0 -3
- package/dist/.internal/commands/meta.js +0 -15
- package/dist/.internal/commands/utils/optionParser.cjs +0 -8
- package/dist/.internal/commands/utils/optionParser.d.cts +0 -3
- package/dist/.internal/commands/utils/optionParser.d.ts +0 -3
- package/dist/.internal/commands/utils/optionParser.js +0 -6
- package/dist/.internal/server.cjs +0 -33
- package/dist/.internal/server.d.cts +0 -8
- package/dist/.internal/server.d.ts +0 -8
- package/dist/.internal/server.js +0 -27
- package/dist/.internal/utils/checkDependency.cjs +0 -39
- package/dist/.internal/utils/checkDependency.d.cts +0 -3
- package/dist/.internal/utils/checkDependency.d.ts +0 -3
- package/dist/.internal/utils/checkDependency.js +0 -34
- package/dist/.internal/utils/getRoot.cjs +0 -17
- package/dist/.internal/utils/getRoot.d.cts +0 -3
- package/dist/.internal/utils/getRoot.d.ts +0 -3
- package/dist/.internal/utils/getRoot.js +0 -11
- package/dist/.internal/utils/getWD.cjs +0 -15
- package/dist/.internal/utils/getWD.d.cts +0 -6
- package/dist/.internal/utils/getWD.d.ts +0 -6
- package/dist/.internal/utils/getWD.js +0 -10
- package/dist/.internal/utils/tsRegister.cjs +0 -25
- package/dist/.internal/utils/tsRegister.d.cts +0 -3
- package/dist/.internal/utils/tsRegister.d.ts +0 -3
- package/dist/.internal/utils/tsRegister.js +0 -26
@@ -1,201 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var optionParser = require('../utils/optionParser.cjs');
|
4
|
-
var checkDependency = require('../../utils/checkDependency.cjs');
|
5
|
-
var fs = require('node:fs');
|
6
|
-
var path = require('node:path');
|
7
|
-
require('../../.chunks/jiek_create-require.CWFWNQHj.cjs');
|
8
|
-
require('node:child_process');
|
9
|
-
require('node:process');
|
10
|
-
require('@inquirer/prompts');
|
11
|
-
require('../../.chunks/getWD.ZF0avqDB.cjs');
|
12
|
-
require('@jiek/utils/getWorkspaceDir');
|
13
|
-
require('commander');
|
14
|
-
require('js-yaml');
|
15
|
-
require('../../utils/getRoot.cjs');
|
16
|
-
|
17
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
18
|
-
|
19
|
-
var path__default = /*#__PURE__*/_interopDefault(path);
|
20
|
-
|
21
|
-
function Main() {
|
22
|
-
const { useState, useMemo, useEffect, useCallback } = React;
|
23
|
-
const [path, setPath] = useState(() => location.pathname.replace(/^\/ana\/?/, ""));
|
24
|
-
const [pkgName, entry] = useMemo(() => {
|
25
|
-
const pkgName2 = /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(path)?.[1];
|
26
|
-
return [
|
27
|
-
pkgName2,
|
28
|
-
pkgName2 != null ? path.replace(`${pkgName2}/`, "") : void 0
|
29
|
-
];
|
30
|
-
}, [path]);
|
31
|
-
const push = useCallback((newPath) => {
|
32
|
-
setPath(newPath);
|
33
|
-
document.title = `${document.title.replace(/ - \/.*/, "")} - /${newPath}`;
|
34
|
-
history.pushState(null, "", `/ana/${newPath}`);
|
35
|
-
}, []);
|
36
|
-
const filterModules = useCallback((startWith) => {
|
37
|
-
const modules = analyzeModule.filter((m) => m.filename.startsWith(startWith));
|
38
|
-
dispatchEvent(new CustomEvent("send:filter", { detail: { analyzeModule: modules } }));
|
39
|
-
}, []);
|
40
|
-
useEffect(() => {
|
41
|
-
if (path !== "") {
|
42
|
-
document.title = `${document.title.replace(/ - \/.*/, "")} - /${path}`;
|
43
|
-
} else {
|
44
|
-
document.title = document.title.replace(/ - \/.*/, "");
|
45
|
-
}
|
46
|
-
filterModules(path);
|
47
|
-
}, [path, filterModules]);
|
48
|
-
useEffect(() => {
|
49
|
-
const offGraphClick = listen("graph:click", ({ detail }) => {
|
50
|
-
if (!detail) return;
|
51
|
-
let root = detail.node;
|
52
|
-
while (root.parent) {
|
53
|
-
root = root.parent;
|
54
|
-
}
|
55
|
-
if (root.filename === path) return;
|
56
|
-
push(root.filename);
|
57
|
-
});
|
58
|
-
return () => {
|
59
|
-
offGraphClick();
|
60
|
-
};
|
61
|
-
}, [push]);
|
62
|
-
function listen(type, listener) {
|
63
|
-
window.addEventListener(type, listener);
|
64
|
-
return () => {
|
65
|
-
window.removeEventListener(type, listener);
|
66
|
-
};
|
67
|
-
}
|
68
|
-
return /* @__PURE__ */ React.createElement(
|
69
|
-
"div",
|
70
|
-
{
|
71
|
-
style: {
|
72
|
-
padding: "12px 55px"
|
73
|
-
}
|
74
|
-
},
|
75
|
-
"/",
|
76
|
-
/* @__PURE__ */ React.createElement(
|
77
|
-
"select",
|
78
|
-
{
|
79
|
-
style: {
|
80
|
-
appearance: "none",
|
81
|
-
border: "none",
|
82
|
-
background: "none"
|
83
|
-
},
|
84
|
-
value: pkgName,
|
85
|
-
onChange: (e) => push(e.target.value)
|
86
|
-
},
|
87
|
-
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
88
|
-
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))
|
89
|
-
),
|
90
|
-
pkgName != null && /* @__PURE__ */ React.createElement(React.Fragment, null, "/", /* @__PURE__ */ React.createElement(
|
91
|
-
"select",
|
92
|
-
{
|
93
|
-
style: {
|
94
|
-
appearance: "none",
|
95
|
-
border: "none",
|
96
|
-
background: "none"
|
97
|
-
},
|
98
|
-
value: entry,
|
99
|
-
onChange: (e) => push(`${pkgName}/${e.target.value}`)
|
100
|
-
},
|
101
|
-
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
102
|
-
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))
|
103
|
-
))
|
104
|
-
);
|
105
|
-
}
|
106
|
-
|
107
|
-
function render() {
|
108
|
-
CUSTOM_SIDE_BAR = true;
|
109
|
-
window.addEventListener("client:ready", () => window.dispatchEvent(
|
110
|
-
new CustomEvent("send:ui", {
|
111
|
-
detail: { type: "Main", Component: __REPLACE_INJECT__ }
|
112
|
-
})
|
113
|
-
));
|
114
|
-
}
|
115
|
-
const CLIENT_CUSTOM_RENDER_SCRIPT = [
|
116
|
-
Main.toString(),
|
117
|
-
render.toString().replace("__REPLACE_INJECT__", Main.name),
|
118
|
-
`(${render.name})()`
|
119
|
-
].join("\n");
|
120
|
-
|
121
|
-
const registerAnalyzerCommandOptions = (command) => command.option("--ana", "Enable the bundle analyzer.", optionParser.parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option(
|
122
|
-
"--ana.mode <MODE>",
|
123
|
-
'The mode of the bundle analyzer, support "static", "json" and "server".',
|
124
|
-
"server"
|
125
|
-
).option("--ana.open", "Open the bundle analyzer in the browser.", optionParser.parseBoolean).option(
|
126
|
-
"--ana.size <SIZE>",
|
127
|
-
'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
|
128
|
-
"parsed"
|
129
|
-
);
|
130
|
-
const useAnalyzer = async (options, server) => {
|
131
|
-
const modules = [];
|
132
|
-
let bundleAnalyzerModule;
|
133
|
-
const analyzer = options.ana ? {
|
134
|
-
dir: options["ana.dir"],
|
135
|
-
mode: options["ana.mode"],
|
136
|
-
open: options["ana.open"],
|
137
|
-
size: options["ana.size"]
|
138
|
-
} : void 0;
|
139
|
-
if (options.ana && ![
|
140
|
-
"stat",
|
141
|
-
"parsed",
|
142
|
-
"gzip"
|
143
|
-
].includes(analyzer?.size ?? "")) {
|
144
|
-
throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
|
145
|
-
}
|
146
|
-
if (analyzer) {
|
147
|
-
await checkDependency.checkDependency("vite-bundle-analyzer");
|
148
|
-
bundleAnalyzerModule = await import('vite-bundle-analyzer');
|
149
|
-
}
|
150
|
-
const refreshAnalyzer = async (cwd, applyModules) => {
|
151
|
-
if (!(analyzer && server && bundleAnalyzerModule)) return;
|
152
|
-
if (analyzer.mode === "json") {
|
153
|
-
const anaDir = path__default.default.resolve(cwd, analyzer.dir);
|
154
|
-
if (!fs.existsSync(anaDir)) {
|
155
|
-
fs.mkdirSync(anaDir, { recursive: true });
|
156
|
-
}
|
157
|
-
const gitIgnorePath = path__default.default.resolve(anaDir, ".gitignore");
|
158
|
-
if (!fs.existsSync(gitIgnorePath)) {
|
159
|
-
fs.writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
|
160
|
-
}
|
161
|
-
const npmIgnorePath = path__default.default.resolve(anaDir, ".npmignore");
|
162
|
-
if (!fs.existsSync(npmIgnorePath)) {
|
163
|
-
fs.writeFileSync(npmIgnorePath, "*\n");
|
164
|
-
}
|
165
|
-
if (!fs.statSync(anaDir).isDirectory()) {
|
166
|
-
throw new Error(`The directory '${anaDir}' is not a directory.`);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
const { renderView, injectHTMLTag } = bundleAnalyzerModule;
|
170
|
-
applyModules.forEach((m) => {
|
171
|
-
const index = modules.findIndex(({ filename }) => filename === m.filename);
|
172
|
-
if (index === -1) {
|
173
|
-
modules.push(m);
|
174
|
-
} else {
|
175
|
-
modules[index] = m;
|
176
|
-
}
|
177
|
-
});
|
178
|
-
let html = await renderView(modules, {
|
179
|
-
title: `Jiek Analyzer`,
|
180
|
-
mode: analyzer.size
|
181
|
-
});
|
182
|
-
html = injectHTMLTag({
|
183
|
-
html,
|
184
|
-
injectTo: "body",
|
185
|
-
descriptors: [
|
186
|
-
{ kind: "script", text: CLIENT_CUSTOM_RENDER_SCRIPT }
|
187
|
-
]
|
188
|
-
});
|
189
|
-
void server.renderTo("/ana", html);
|
190
|
-
};
|
191
|
-
return {
|
192
|
-
modules,
|
193
|
-
refreshAnalyzer,
|
194
|
-
ANALYZER_ENV: {
|
195
|
-
JIEK_ANALYZER: analyzer ? JSON.stringify(analyzer) : void 0
|
196
|
-
}
|
197
|
-
};
|
198
|
-
};
|
199
|
-
|
200
|
-
exports.registerAnalyzerCommandOptions = registerAnalyzerCommandOptions;
|
201
|
-
exports.useAnalyzer = useAnalyzer;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as vite_bundle_analyzer from 'vite-bundle-analyzer';
|
2
|
-
import { Command } from 'commander';
|
3
|
-
import { createServer } from '../../server.cjs';
|
4
|
-
|
5
|
-
interface AnalyzerBuildOptions {
|
6
|
-
ana?: boolean;
|
7
|
-
/**
|
8
|
-
* @default '.jk-analyses'
|
9
|
-
*/
|
10
|
-
'ana.dir': string;
|
11
|
-
/**
|
12
|
-
* @default 'server'
|
13
|
-
*/
|
14
|
-
'ana.mode': string;
|
15
|
-
'ana.open'?: boolean;
|
16
|
-
/**
|
17
|
-
* @default 'parsed'
|
18
|
-
*/
|
19
|
-
'ana.size': string;
|
20
|
-
}
|
21
|
-
declare const registerAnalyzerCommandOptions: (command: Command) => Command;
|
22
|
-
declare const useAnalyzer: (options: AnalyzerBuildOptions, server?: ReturnType<typeof createServer>) => Promise<{
|
23
|
-
modules: vite_bundle_analyzer.Module[];
|
24
|
-
refreshAnalyzer: (cwd: string, applyModules: vite_bundle_analyzer.Module[]) => Promise<void>;
|
25
|
-
ANALYZER_ENV: {
|
26
|
-
JIEK_ANALYZER: string | undefined;
|
27
|
-
};
|
28
|
-
}>;
|
29
|
-
|
30
|
-
export { type AnalyzerBuildOptions, registerAnalyzerCommandOptions, useAnalyzer };
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import * as vite_bundle_analyzer from 'vite-bundle-analyzer';
|
2
|
-
import { Command } from 'commander';
|
3
|
-
import { createServer } from '../../server.js';
|
4
|
-
|
5
|
-
interface AnalyzerBuildOptions {
|
6
|
-
ana?: boolean;
|
7
|
-
/**
|
8
|
-
* @default '.jk-analyses'
|
9
|
-
*/
|
10
|
-
'ana.dir': string;
|
11
|
-
/**
|
12
|
-
* @default 'server'
|
13
|
-
*/
|
14
|
-
'ana.mode': string;
|
15
|
-
'ana.open'?: boolean;
|
16
|
-
/**
|
17
|
-
* @default 'parsed'
|
18
|
-
*/
|
19
|
-
'ana.size': string;
|
20
|
-
}
|
21
|
-
declare const registerAnalyzerCommandOptions: (command: Command) => Command;
|
22
|
-
declare const useAnalyzer: (options: AnalyzerBuildOptions, server?: ReturnType<typeof createServer>) => Promise<{
|
23
|
-
modules: vite_bundle_analyzer.Module[];
|
24
|
-
refreshAnalyzer: (cwd: string, applyModules: vite_bundle_analyzer.Module[]) => Promise<void>;
|
25
|
-
ANALYZER_ENV: {
|
26
|
-
JIEK_ANALYZER: string | undefined;
|
27
|
-
};
|
28
|
-
}>;
|
29
|
-
|
30
|
-
export { type AnalyzerBuildOptions, registerAnalyzerCommandOptions, useAnalyzer };
|
@@ -1,195 +0,0 @@
|
|
1
|
-
import { parseBoolean } from '../utils/optionParser.js';
|
2
|
-
import { checkDependency } from '../../utils/checkDependency.js';
|
3
|
-
import { existsSync, mkdirSync, writeFileSync, statSync } from 'node:fs';
|
4
|
-
import path from 'node:path';
|
5
|
-
import '../../.chunks/jiek_create-require.CxSGbkTB.js';
|
6
|
-
import 'node:module';
|
7
|
-
import 'node:child_process';
|
8
|
-
import 'node:process';
|
9
|
-
import '@inquirer/prompts';
|
10
|
-
import '../../.chunks/getWD.D6wq8Qc2.js';
|
11
|
-
import '@jiek/utils/getWorkspaceDir';
|
12
|
-
import 'commander';
|
13
|
-
import 'js-yaml';
|
14
|
-
import '../../utils/getRoot.js';
|
15
|
-
|
16
|
-
function Main() {
|
17
|
-
const { useState, useMemo, useEffect, useCallback } = React;
|
18
|
-
const [path, setPath] = useState(() => location.pathname.replace(/^\/ana\/?/, ""));
|
19
|
-
const [pkgName, entry] = useMemo(() => {
|
20
|
-
const pkgName2 = /^(@[^/]+\/[^/]+|[^/]+)\/?/.exec(path)?.[1];
|
21
|
-
return [
|
22
|
-
pkgName2,
|
23
|
-
pkgName2 != null ? path.replace(`${pkgName2}/`, "") : void 0
|
24
|
-
];
|
25
|
-
}, [path]);
|
26
|
-
const push = useCallback((newPath) => {
|
27
|
-
setPath(newPath);
|
28
|
-
document.title = `${document.title.replace(/ - \/.*/, "")} - /${newPath}`;
|
29
|
-
history.pushState(null, "", `/ana/${newPath}`);
|
30
|
-
}, []);
|
31
|
-
const filterModules = useCallback((startWith) => {
|
32
|
-
const modules = analyzeModule.filter((m) => m.filename.startsWith(startWith));
|
33
|
-
dispatchEvent(new CustomEvent("send:filter", { detail: { analyzeModule: modules } }));
|
34
|
-
}, []);
|
35
|
-
useEffect(() => {
|
36
|
-
if (path !== "") {
|
37
|
-
document.title = `${document.title.replace(/ - \/.*/, "")} - /${path}`;
|
38
|
-
} else {
|
39
|
-
document.title = document.title.replace(/ - \/.*/, "");
|
40
|
-
}
|
41
|
-
filterModules(path);
|
42
|
-
}, [path, filterModules]);
|
43
|
-
useEffect(() => {
|
44
|
-
const offGraphClick = listen("graph:click", ({ detail }) => {
|
45
|
-
if (!detail) return;
|
46
|
-
let root = detail.node;
|
47
|
-
while (root.parent) {
|
48
|
-
root = root.parent;
|
49
|
-
}
|
50
|
-
if (root.filename === path) return;
|
51
|
-
push(root.filename);
|
52
|
-
});
|
53
|
-
return () => {
|
54
|
-
offGraphClick();
|
55
|
-
};
|
56
|
-
}, [push]);
|
57
|
-
function listen(type, listener) {
|
58
|
-
window.addEventListener(type, listener);
|
59
|
-
return () => {
|
60
|
-
window.removeEventListener(type, listener);
|
61
|
-
};
|
62
|
-
}
|
63
|
-
return /* @__PURE__ */ React.createElement(
|
64
|
-
"div",
|
65
|
-
{
|
66
|
-
style: {
|
67
|
-
padding: "12px 55px"
|
68
|
-
}
|
69
|
-
},
|
70
|
-
"/",
|
71
|
-
/* @__PURE__ */ React.createElement(
|
72
|
-
"select",
|
73
|
-
{
|
74
|
-
style: {
|
75
|
-
appearance: "none",
|
76
|
-
border: "none",
|
77
|
-
background: "none"
|
78
|
-
},
|
79
|
-
value: pkgName,
|
80
|
-
onChange: (e) => push(e.target.value)
|
81
|
-
},
|
82
|
-
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
83
|
-
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))
|
84
|
-
),
|
85
|
-
pkgName != null && /* @__PURE__ */ React.createElement(React.Fragment, null, "/", /* @__PURE__ */ React.createElement(
|
86
|
-
"select",
|
87
|
-
{
|
88
|
-
style: {
|
89
|
-
appearance: "none",
|
90
|
-
border: "none",
|
91
|
-
background: "none"
|
92
|
-
},
|
93
|
-
value: entry,
|
94
|
-
onChange: (e) => push(`${pkgName}/${e.target.value}`)
|
95
|
-
},
|
96
|
-
/* @__PURE__ */ React.createElement("option", { value: "" }, "All"),
|
97
|
-
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))
|
98
|
-
))
|
99
|
-
);
|
100
|
-
}
|
101
|
-
|
102
|
-
function render() {
|
103
|
-
CUSTOM_SIDE_BAR = true;
|
104
|
-
window.addEventListener("client:ready", () => window.dispatchEvent(
|
105
|
-
new CustomEvent("send:ui", {
|
106
|
-
detail: { type: "Main", Component: __REPLACE_INJECT__ }
|
107
|
-
})
|
108
|
-
));
|
109
|
-
}
|
110
|
-
const CLIENT_CUSTOM_RENDER_SCRIPT = [
|
111
|
-
Main.toString(),
|
112
|
-
render.toString().replace("__REPLACE_INJECT__", Main.name),
|
113
|
-
`(${render.name})()`
|
114
|
-
].join("\n");
|
115
|
-
|
116
|
-
const registerAnalyzerCommandOptions = (command) => command.option("--ana", "Enable the bundle analyzer.", parseBoolean).option("--ana.dir <DIR>", "The directory of the bundle analyzer.", ".jk-analyses").option(
|
117
|
-
"--ana.mode <MODE>",
|
118
|
-
'The mode of the bundle analyzer, support "static", "json" and "server".',
|
119
|
-
"server"
|
120
|
-
).option("--ana.open", "Open the bundle analyzer in the browser.", parseBoolean).option(
|
121
|
-
"--ana.size <SIZE>",
|
122
|
-
'The default size of the bundle analyzer, support "stat", "parsed" and "gzip".',
|
123
|
-
"parsed"
|
124
|
-
);
|
125
|
-
const useAnalyzer = async (options, server) => {
|
126
|
-
const modules = [];
|
127
|
-
let bundleAnalyzerModule;
|
128
|
-
const analyzer = options.ana ? {
|
129
|
-
dir: options["ana.dir"],
|
130
|
-
mode: options["ana.mode"],
|
131
|
-
open: options["ana.open"],
|
132
|
-
size: options["ana.size"]
|
133
|
-
} : void 0;
|
134
|
-
if (options.ana && ![
|
135
|
-
"stat",
|
136
|
-
"parsed",
|
137
|
-
"gzip"
|
138
|
-
].includes(analyzer?.size ?? "")) {
|
139
|
-
throw new Error('The value of `ana.size` must be "stat", "parsed" or "gzip"');
|
140
|
-
}
|
141
|
-
if (analyzer) {
|
142
|
-
await checkDependency("vite-bundle-analyzer");
|
143
|
-
bundleAnalyzerModule = await import('vite-bundle-analyzer');
|
144
|
-
}
|
145
|
-
const refreshAnalyzer = async (cwd, applyModules) => {
|
146
|
-
if (!(analyzer && server && bundleAnalyzerModule)) return;
|
147
|
-
if (analyzer.mode === "json") {
|
148
|
-
const anaDir = path.resolve(cwd, analyzer.dir);
|
149
|
-
if (!existsSync(anaDir)) {
|
150
|
-
mkdirSync(anaDir, { recursive: true });
|
151
|
-
}
|
152
|
-
const gitIgnorePath = path.resolve(anaDir, ".gitignore");
|
153
|
-
if (!existsSync(gitIgnorePath)) {
|
154
|
-
writeFileSync(gitIgnorePath, "*\n!.gitignore\n");
|
155
|
-
}
|
156
|
-
const npmIgnorePath = path.resolve(anaDir, ".npmignore");
|
157
|
-
if (!existsSync(npmIgnorePath)) {
|
158
|
-
writeFileSync(npmIgnorePath, "*\n");
|
159
|
-
}
|
160
|
-
if (!statSync(anaDir).isDirectory()) {
|
161
|
-
throw new Error(`The directory '${anaDir}' is not a directory.`);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
const { renderView, injectHTMLTag } = bundleAnalyzerModule;
|
165
|
-
applyModules.forEach((m) => {
|
166
|
-
const index = modules.findIndex(({ filename }) => filename === m.filename);
|
167
|
-
if (index === -1) {
|
168
|
-
modules.push(m);
|
169
|
-
} else {
|
170
|
-
modules[index] = m;
|
171
|
-
}
|
172
|
-
});
|
173
|
-
let html = await renderView(modules, {
|
174
|
-
title: `Jiek Analyzer`,
|
175
|
-
mode: analyzer.size
|
176
|
-
});
|
177
|
-
html = injectHTMLTag({
|
178
|
-
html,
|
179
|
-
injectTo: "body",
|
180
|
-
descriptors: [
|
181
|
-
{ kind: "script", text: CLIENT_CUSTOM_RENDER_SCRIPT }
|
182
|
-
]
|
183
|
-
});
|
184
|
-
void server.renderTo("/ana", html);
|
185
|
-
};
|
186
|
-
return {
|
187
|
-
modules,
|
188
|
-
refreshAnalyzer,
|
189
|
-
ANALYZER_ENV: {
|
190
|
-
JIEK_ANALYZER: analyzer ? JSON.stringify(analyzer) : void 0
|
191
|
-
}
|
192
|
-
};
|
193
|
-
};
|
194
|
-
|
195
|
-
export { registerAnalyzerCommandOptions, useAnalyzer };
|
@@ -1,21 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const entriesDescription = `
|
4
|
-
Specify the build entry-points of the package.json's 'exports' field.
|
5
|
-
Support glob pattern and array.
|
6
|
-
.e.g. '.', './*', './sub/*', './a,./b'.
|
7
|
-
`.trim();
|
8
|
-
const filterDescription = `
|
9
|
-
Filter the packages from the workspace.
|
10
|
-
Support fuzzy match and array.
|
11
|
-
.e.g. 'core,utils'.
|
12
|
-
`.trim();
|
13
|
-
const outdirDescription = `
|
14
|
-
The output directory of the build, which relative to the target subpackage root directory.
|
15
|
-
Support with variables: 'PKG_NAME',
|
16
|
-
.e.g. 'dist/{{PKG_NAME}}'.
|
17
|
-
`.trim();
|
18
|
-
|
19
|
-
exports.entriesDescription = entriesDescription;
|
20
|
-
exports.filterDescription = filterDescription;
|
21
|
-
exports.outdirDescription = outdirDescription;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
const entriesDescription = `
|
2
|
-
Specify the build entry-points of the package.json's 'exports' field.
|
3
|
-
Support glob pattern and array.
|
4
|
-
.e.g. '.', './*', './sub/*', './a,./b'.
|
5
|
-
`.trim();
|
6
|
-
const filterDescription = `
|
7
|
-
Filter the packages from the workspace.
|
8
|
-
Support fuzzy match and array.
|
9
|
-
.e.g. 'core,utils'.
|
10
|
-
`.trim();
|
11
|
-
const outdirDescription = `
|
12
|
-
The output directory of the build, which relative to the target subpackage root directory.
|
13
|
-
Support with variables: 'PKG_NAME',
|
14
|
-
.e.g. 'dist/{{PKG_NAME}}'.
|
15
|
-
`.trim();
|
16
|
-
|
17
|
-
export { entriesDescription, filterDescription, outdirDescription };
|
@@ -1,16 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var filterSupport = require('../.chunks/getWD.ZF0avqDB.cjs');
|
4
|
-
require('@jiek/utils/getWorkspaceDir');
|
5
|
-
require('../.chunks/jiek_create-require.CWFWNQHj.cjs');
|
6
|
-
require('node:fs');
|
7
|
-
require('node:path');
|
8
|
-
require('node:process');
|
9
|
-
require('commander');
|
10
|
-
require('js-yaml');
|
11
|
-
require('../utils/getRoot.cjs');
|
12
|
-
|
13
|
-
const { notWorkspace } = filterSupport.getWD();
|
14
|
-
const IS_WORKSPACE = !notWorkspace;
|
15
|
-
|
16
|
-
exports.IS_WORKSPACE = IS_WORKSPACE;
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { g as getWD } from '../.chunks/getWD.D6wq8Qc2.js';
|
2
|
-
import '@jiek/utils/getWorkspaceDir';
|
3
|
-
import '../.chunks/jiek_create-require.CxSGbkTB.js';
|
4
|
-
import 'node:module';
|
5
|
-
import 'node:fs';
|
6
|
-
import 'node:path';
|
7
|
-
import 'node:process';
|
8
|
-
import 'commander';
|
9
|
-
import 'js-yaml';
|
10
|
-
import '../utils/getRoot.js';
|
11
|
-
|
12
|
-
const { notWorkspace } = getWD();
|
13
|
-
const IS_WORKSPACE = !notWorkspace;
|
14
|
-
|
15
|
-
export { IS_WORKSPACE };
|
@@ -1,33 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var Koa = require('koa');
|
4
|
-
|
5
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
6
|
-
|
7
|
-
var Koa__default = /*#__PURE__*/_interopDefault(Koa);
|
8
|
-
|
9
|
-
const createServer = (port, host) => {
|
10
|
-
const app = new Koa__default.default();
|
11
|
-
app.listen(port, host);
|
12
|
-
const streams = /* @__PURE__ */ new Map();
|
13
|
-
app.use(async (ctx) => {
|
14
|
-
let stream = streams.get(ctx.path);
|
15
|
-
if (stream == null) {
|
16
|
-
const maybeKey = streams.keys().find((p) => ctx.path.startsWith(p));
|
17
|
-
stream = maybeKey != null ? streams.get(maybeKey) : void 0;
|
18
|
-
}
|
19
|
-
if (stream != null) {
|
20
|
-
ctx.body = stream;
|
21
|
-
}
|
22
|
-
});
|
23
|
-
return {
|
24
|
-
port,
|
25
|
-
host,
|
26
|
-
rootUrl: `http://${host}:${port}`,
|
27
|
-
renderTo: async (path, stream) => {
|
28
|
-
streams.set(path, stream);
|
29
|
-
}
|
30
|
-
};
|
31
|
-
};
|
32
|
-
|
33
|
-
exports.createServer = createServer;
|
package/dist/.internal/server.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
import Koa from 'koa';
|
2
|
-
|
3
|
-
const createServer = (port, host) => {
|
4
|
-
const app = new Koa();
|
5
|
-
app.listen(port, host);
|
6
|
-
const streams = /* @__PURE__ */ new Map();
|
7
|
-
app.use(async (ctx) => {
|
8
|
-
let stream = streams.get(ctx.path);
|
9
|
-
if (stream == null) {
|
10
|
-
const maybeKey = streams.keys().find((p) => ctx.path.startsWith(p));
|
11
|
-
stream = maybeKey != null ? streams.get(maybeKey) : void 0;
|
12
|
-
}
|
13
|
-
if (stream != null) {
|
14
|
-
ctx.body = stream;
|
15
|
-
}
|
16
|
-
});
|
17
|
-
return {
|
18
|
-
port,
|
19
|
-
host,
|
20
|
-
rootUrl: `http://${host}:${port}`,
|
21
|
-
renderTo: async (path, stream) => {
|
22
|
-
streams.set(path, stream);
|
23
|
-
}
|
24
|
-
};
|
25
|
-
};
|
26
|
-
|
27
|
-
export { createServer };
|