jiek 2.2.5 → 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 -731
- package/dist/{cli.cjs → .internal/index-DlHFuTjM.js} +1 -753
- 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 +101 -31
- 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,195 @@
|
|
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 '../../../jiek_create-require-CxSGbkTB.js';
|
6
|
+
import 'node:module';
|
7
|
+
import 'node:child_process';
|
8
|
+
import 'node:process';
|
9
|
+
import '@inquirer/prompts';
|
10
|
+
import '../../../getWD-Cmxzjf-f.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 };
|
@@ -0,0 +1,21 @@
|
|
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;
|
@@ -0,0 +1,17 @@
|
|
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 };
|
@@ -0,0 +1,16 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var filterSupport = require('../../getWD-BRJ3PK1S.js');
|
4
|
+
require('@jiek/utils/getWorkspaceDir');
|
5
|
+
require('../../jiek_create-require-CWFWNQHj.js');
|
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;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { g as getWD } from '../../getWD-Cmxzjf-f.js';
|
2
|
+
import '@jiek/utils/getWorkspaceDir';
|
3
|
+
import '../../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 };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const BUILDER_TYPES = ["esbuild", "swc"];
|
4
|
+
const BUILDER_TYPE_PACKAGE_NAME_MAP = {
|
5
|
+
esbuild: "rollup-plugin-esbuild",
|
6
|
+
swc: "rollup-plugin-swc3"
|
7
|
+
};
|
8
|
+
|
9
|
+
exports.BUILDER_TYPES = BUILDER_TYPES;
|
10
|
+
exports.BUILDER_TYPE_PACKAGE_NAME_MAP = BUILDER_TYPE_PACKAGE_NAME_MAP;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as _rollup_plugin_terser from '@rollup/plugin-terser';
|
2
2
|
import * as rollup_plugin_swc3 from 'rollup-plugin-swc3';
|
3
3
|
import * as rollup_plugin_esbuild from 'rollup-plugin-esbuild';
|
4
|
-
import {
|
4
|
+
import { OutputOptions, InputPluginOption } from 'rollup';
|
5
5
|
|
6
6
|
type Mapping2ROO<K extends keyof OutputOptions> = OutputOptions[K] | {
|
7
7
|
js?: OutputOptions[K];
|
@@ -18,6 +18,10 @@ interface ConfigGenerateContext {
|
|
18
18
|
}
|
19
19
|
type OutputControl = boolean | ((context: ConfigGenerateContext) => boolean);
|
20
20
|
declare const BUILDER_TYPES: readonly ["esbuild", "swc"];
|
21
|
+
declare const BUILDER_TYPE_PACKAGE_NAME_MAP: {
|
22
|
+
esbuild: string;
|
23
|
+
swc: string;
|
24
|
+
};
|
21
25
|
interface TemplateOptions {
|
22
26
|
/**
|
23
27
|
* When the user configures type: module, the generated output from entry points that don't
|
@@ -45,9 +49,9 @@ interface TemplateOptions {
|
|
45
49
|
* When use esbuild type builder, it will inject `supported.import-attributes` option.
|
46
50
|
* When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
|
47
51
|
*
|
48
|
-
* And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
|
52
|
+
* And it will auto set the rollup output `externalImportAttributes` and `importAttributesKey` options.
|
49
53
|
*
|
50
|
-
* @default
|
54
|
+
* @default false
|
51
55
|
*/
|
52
56
|
keepImportAttributes?: boolean | 'assert';
|
53
57
|
};
|
@@ -112,15 +116,4 @@ interface TemplateOptions {
|
|
112
116
|
injects?: Record<string, string | [string, string]>;
|
113
117
|
}
|
114
118
|
|
115
|
-
|
116
|
-
interface Config {
|
117
|
-
build?: TemplateOptions & {
|
118
|
-
/**
|
119
|
-
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
120
|
-
*
|
121
|
-
* @default false
|
122
|
-
*/
|
123
|
-
silent?: boolean;
|
124
|
-
};
|
125
|
-
}
|
126
|
-
}
|
119
|
+
export { BUILDER_TYPES, BUILDER_TYPE_PACKAGE_NAME_MAP, type ConfigGenerateContext, type Mapping2ROO, type OutputControl, type TemplateOptions };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as _rollup_plugin_terser from '@rollup/plugin-terser';
|
2
2
|
import * as rollup_plugin_swc3 from 'rollup-plugin-swc3';
|
3
3
|
import * as rollup_plugin_esbuild from 'rollup-plugin-esbuild';
|
4
|
-
import {
|
4
|
+
import { OutputOptions, InputPluginOption } from 'rollup';
|
5
5
|
|
6
6
|
type Mapping2ROO<K extends keyof OutputOptions> = OutputOptions[K] | {
|
7
7
|
js?: OutputOptions[K];
|
@@ -18,6 +18,10 @@ interface ConfigGenerateContext {
|
|
18
18
|
}
|
19
19
|
type OutputControl = boolean | ((context: ConfigGenerateContext) => boolean);
|
20
20
|
declare const BUILDER_TYPES: readonly ["esbuild", "swc"];
|
21
|
+
declare const BUILDER_TYPE_PACKAGE_NAME_MAP: {
|
22
|
+
esbuild: string;
|
23
|
+
swc: string;
|
24
|
+
};
|
21
25
|
interface TemplateOptions {
|
22
26
|
/**
|
23
27
|
* When the user configures type: module, the generated output from entry points that don't
|
@@ -45,9 +49,9 @@ interface TemplateOptions {
|
|
45
49
|
* When use esbuild type builder, it will inject `supported.import-attributes` option.
|
46
50
|
* When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
|
47
51
|
*
|
48
|
-
* And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
|
52
|
+
* And it will auto set the rollup output `externalImportAttributes` and `importAttributesKey` options.
|
49
53
|
*
|
50
|
-
* @default
|
54
|
+
* @default false
|
51
55
|
*/
|
52
56
|
keepImportAttributes?: boolean | 'assert';
|
53
57
|
};
|
@@ -112,15 +116,4 @@ interface TemplateOptions {
|
|
112
116
|
injects?: Record<string, string | [string, string]>;
|
113
117
|
}
|
114
118
|
|
115
|
-
|
116
|
-
interface Config {
|
117
|
-
build?: TemplateOptions & {
|
118
|
-
/**
|
119
|
-
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
120
|
-
*
|
121
|
-
* @default false
|
122
|
-
*/
|
123
|
-
silent?: boolean;
|
124
|
-
};
|
125
|
-
}
|
126
|
-
}
|
119
|
+
export { BUILDER_TYPES, BUILDER_TYPE_PACKAGE_NAME_MAP, type ConfigGenerateContext, type Mapping2ROO, type OutputControl, type TemplateOptions };
|
@@ -0,0 +1,51 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var process = require('node:process');
|
4
|
+
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
6
|
+
|
7
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
8
|
+
|
9
|
+
const {
|
10
|
+
JIEK_ANALYZER
|
11
|
+
} = process__default.default.env;
|
12
|
+
const ANALYZER = JIEK_ANALYZER != null && JSON.parse(JIEK_ANALYZER);
|
13
|
+
function bundleAnalyzer(modulesResolved) {
|
14
|
+
if (!ANALYZER) {
|
15
|
+
return [];
|
16
|
+
}
|
17
|
+
const defaultSizes = {
|
18
|
+
parsed: "parsed",
|
19
|
+
stat: "stat",
|
20
|
+
gzip: "gzip"
|
21
|
+
}[ANALYZER.size ?? "stat"] ?? "parsed";
|
22
|
+
let ana;
|
23
|
+
async function initAna() {
|
24
|
+
const { adapter, analyzer } = await import('vite-bundle-analyzer');
|
25
|
+
ana = ana ?? adapter(analyzer({
|
26
|
+
defaultSizes,
|
27
|
+
analyzerMode: modulesResolved
|
28
|
+
}));
|
29
|
+
}
|
30
|
+
return [
|
31
|
+
(async () => {
|
32
|
+
await initAna();
|
33
|
+
return {
|
34
|
+
name: "jiek:bundle-analyzer",
|
35
|
+
async closeBundle(...args) {
|
36
|
+
if (typeof ana.closeBundle !== "function") return;
|
37
|
+
return ana.closeBundle?.call(this, ...args);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
})(),
|
41
|
+
(async () => {
|
42
|
+
await initAna();
|
43
|
+
return {
|
44
|
+
...ana,
|
45
|
+
name: "jiek:bundle-analyzer-output"
|
46
|
+
};
|
47
|
+
})()
|
48
|
+
];
|
49
|
+
}
|
50
|
+
|
51
|
+
exports.bundleAnalyzer = bundleAnalyzer;
|
@@ -0,0 +1,92 @@
|
|
1
|
+
import * as rollup from 'rollup';
|
2
|
+
import { AnalyzerPluginInternalAPI } from 'vite-bundle-analyzer';
|
3
|
+
|
4
|
+
type Module = ReturnType<AnalyzerPluginInternalAPI['processModule']>[number];
|
5
|
+
declare function bundleAnalyzer(modulesResolved: (modules: Module[]) => void): never[] | readonly [Promise<{
|
6
|
+
name: string;
|
7
|
+
closeBundle(this: rollup.PluginContext): Promise<void>;
|
8
|
+
}>, Promise<{
|
9
|
+
name: string;
|
10
|
+
api?: any;
|
11
|
+
cacheKey?: string;
|
12
|
+
version?: string;
|
13
|
+
augmentChunkHash?: rollup.ObjectHook<(this: rollup.PluginContext, chunk: rollup.RenderedChunk) => string | void, {}> | undefined;
|
14
|
+
generateBundle?: rollup.ObjectHook<(this: rollup.PluginContext, options: rollup.NormalizedOutputOptions, bundle: rollup.OutputBundle, isWrite: boolean) => void | Promise<void>, {}> | undefined;
|
15
|
+
outputOptions?: rollup.ObjectHook<(this: rollup.PluginContext, options: rollup.OutputOptions) => rollup.OutputOptions | rollup.NullValue, {}> | undefined;
|
16
|
+
renderChunk?: rollup.ObjectHook<(this: rollup.PluginContext, code: string, chunk: rollup.RenderedChunk, options: rollup.NormalizedOutputOptions, meta: {
|
17
|
+
chunks: Record<string, rollup.RenderedChunk>;
|
18
|
+
}) => string | rollup.NullValue | {
|
19
|
+
code: string;
|
20
|
+
map?: rollup.SourceMapInput;
|
21
|
+
} | Promise<string | rollup.NullValue | {
|
22
|
+
code: string;
|
23
|
+
map?: rollup.SourceMapInput;
|
24
|
+
}>, {}> | undefined;
|
25
|
+
renderDynamicImport?: rollup.ObjectHook<(this: rollup.PluginContext, options: {
|
26
|
+
customResolution: string | null;
|
27
|
+
format: rollup.InternalModuleFormat;
|
28
|
+
moduleId: string;
|
29
|
+
targetModuleId: string | null;
|
30
|
+
}) => {
|
31
|
+
left: string;
|
32
|
+
right: string;
|
33
|
+
} | rollup.NullValue, {}> | undefined;
|
34
|
+
renderError?: rollup.ObjectHook<(this: rollup.PluginContext, error?: Error | undefined) => void | Promise<void>, {
|
35
|
+
sequential?: boolean;
|
36
|
+
}> | undefined;
|
37
|
+
renderStart?: rollup.ObjectHook<(this: rollup.PluginContext, outputOptions: rollup.NormalizedOutputOptions, inputOptions: rollup.NormalizedInputOptions) => void | Promise<void>, {
|
38
|
+
sequential?: boolean;
|
39
|
+
}> | undefined;
|
40
|
+
resolveFileUrl?: rollup.ObjectHook<rollup.ResolveFileUrlHook, {}> | undefined;
|
41
|
+
resolveImportMeta?: rollup.ObjectHook<rollup.ResolveImportMetaHook, {}> | undefined;
|
42
|
+
writeBundle?: rollup.ObjectHook<(this: rollup.PluginContext, options: rollup.NormalizedOutputOptions, bundle: rollup.OutputBundle) => void | Promise<void>, {
|
43
|
+
sequential?: boolean;
|
44
|
+
}> | undefined;
|
45
|
+
banner?: rollup.ObjectHook<rollup.AddonHook, {}> | undefined;
|
46
|
+
footer?: rollup.ObjectHook<rollup.AddonHook, {}> | undefined;
|
47
|
+
intro?: rollup.ObjectHook<rollup.AddonHook, {}> | undefined;
|
48
|
+
outro?: rollup.ObjectHook<rollup.AddonHook, {}> | undefined;
|
49
|
+
buildEnd?: rollup.ObjectHook<(this: rollup.PluginContext, error?: Error | undefined) => void | Promise<void>, {
|
50
|
+
sequential?: boolean;
|
51
|
+
}> | undefined;
|
52
|
+
buildStart?: rollup.ObjectHook<(this: rollup.PluginContext, options: rollup.NormalizedInputOptions) => void | Promise<void>, {
|
53
|
+
sequential?: boolean;
|
54
|
+
}> | undefined;
|
55
|
+
closeBundle?: rollup.ObjectHook<(this: rollup.PluginContext) => void | Promise<void>, {
|
56
|
+
sequential?: boolean;
|
57
|
+
}> | undefined;
|
58
|
+
closeWatcher?: rollup.ObjectHook<(this: rollup.PluginContext) => void | Promise<void>, {
|
59
|
+
sequential?: boolean;
|
60
|
+
}> | undefined;
|
61
|
+
load?: rollup.ObjectHook<(this: rollup.PluginContext, id: string) => rollup.LoadResult | Promise<rollup.LoadResult>, {}> | undefined;
|
62
|
+
moduleParsed?: rollup.ObjectHook<(this: rollup.PluginContext, info: rollup.ModuleInfo) => void | Promise<void>, {
|
63
|
+
sequential?: boolean;
|
64
|
+
}> | undefined;
|
65
|
+
onLog?: rollup.ObjectHook<(this: rollup.MinimalPluginContext, level: rollup.LogLevel, log: rollup.RollupLog) => boolean | rollup.NullValue, {}> | undefined;
|
66
|
+
options?: rollup.ObjectHook<(this: rollup.MinimalPluginContext, options: rollup.InputOptions) => rollup.NullValue | rollup.InputOptions | Promise<rollup.NullValue | rollup.InputOptions>, {}> | undefined;
|
67
|
+
resolveDynamicImport?: rollup.ObjectHook<(this: rollup.PluginContext, specifier: string | rollup.AstNode, importer: string, options: {
|
68
|
+
attributes: Record<string, string>;
|
69
|
+
}) => rollup.ResolveIdResult | Promise<rollup.ResolveIdResult>, {}> | undefined;
|
70
|
+
resolveId?: rollup.ObjectHook<(this: rollup.PluginContext, source: string, importer: string | undefined, options: {
|
71
|
+
attributes: Record<string, string>;
|
72
|
+
custom?: rollup.CustomPluginOptions;
|
73
|
+
isEntry: boolean;
|
74
|
+
}) => rollup.ResolveIdResult | Promise<rollup.ResolveIdResult>, {}> | undefined;
|
75
|
+
shouldTransformCachedModule?: rollup.ObjectHook<(this: rollup.PluginContext, options: {
|
76
|
+
ast: rollup.ProgramNode;
|
77
|
+
code: string;
|
78
|
+
id: string;
|
79
|
+
meta: rollup.CustomPluginOptions;
|
80
|
+
moduleSideEffects: boolean | "no-treeshake";
|
81
|
+
resolvedSources: rollup.ResolvedIdMap;
|
82
|
+
syntheticNamedExports: boolean | string;
|
83
|
+
}) => boolean | rollup.NullValue | Promise<boolean | rollup.NullValue>, {}> | undefined;
|
84
|
+
transform?: rollup.ObjectHook<(this: rollup.TransformPluginContext, code: string, id: string) => rollup.TransformResult | Promise<rollup.TransformResult>, {}> | undefined;
|
85
|
+
watchChange?: rollup.ObjectHook<(this: rollup.PluginContext, id: string, change: {
|
86
|
+
event: rollup.ChangeEvent;
|
87
|
+
}) => void | Promise<void>, {
|
88
|
+
sequential?: boolean;
|
89
|
+
}> | undefined;
|
90
|
+
}>];
|
91
|
+
|
92
|
+
export { type Module, bundleAnalyzer };
|