@unpackjs/core 2.1.0 → 2.3.0
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/compiled/css-loader/index.js +49 -49
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +37 -37
- package/compiled/sass-loader/index.js +8 -8
- package/dist/bundler-config/cache.cjs +113 -0
- package/dist/bundler-config/cache.d.ts +7 -0
- package/dist/bundler-config/cache.d.ts.map +1 -0
- package/dist/bundler-config/cache.js +71 -0
- package/dist/bundler-config/chunkSplit.d.ts.map +1 -1
- package/dist/bundler-config/chunkSplit.js +8 -8
- package/dist/bundler-config/css.cjs +15 -16
- package/dist/bundler-config/css.d.ts.map +1 -1
- package/dist/bundler-config/css.js +44 -45
- package/dist/bundler-config/experimentCss.cjs +14 -12
- package/dist/bundler-config/experimentCss.d.ts.map +1 -1
- package/dist/bundler-config/experimentCss.js +39 -37
- package/dist/bundler-config/{helper.cjs → helpers.cjs} +2 -2
- package/dist/bundler-config/{helper.d.ts → helpers.d.ts} +1 -1
- package/dist/bundler-config/helpers.d.ts.map +1 -0
- package/dist/bundler-config/helpers.js +39 -0
- package/dist/bundler-config/index.cjs +63 -25
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +103 -65
- package/dist/bundler-config/jsMinify.cjs +9 -11
- package/dist/bundler-config/jsMinify.d.ts +2 -10
- package/dist/bundler-config/jsMinify.d.ts.map +1 -1
- package/dist/bundler-config/jsMinify.js +14 -16
- package/dist/bundler-config/oxlint/.oxlintrc.json +29 -0
- package/dist/bundler-config/oxlint/plugin.cjs +143 -0
- package/dist/bundler-config/oxlint/plugin.d.ts +10 -0
- package/dist/bundler-config/oxlint/plugin.d.ts.map +1 -0
- package/dist/bundler-config/oxlint/plugin.js +104 -0
- package/dist/{plugin-progress/helper.cjs → bundler-config/progress/helpers.cjs} +24 -11
- package/dist/{plugin-progress/helper.d.ts → bundler-config/progress/helpers.d.ts} +1 -1
- package/dist/bundler-config/progress/helpers.d.ts.map +1 -0
- package/dist/bundler-config/progress/helpers.js +81 -0
- package/dist/{plugin-progress → bundler-config/progress}/rspack.cjs +11 -11
- package/dist/{plugin-progress → bundler-config/progress}/rspack.d.ts +2 -2
- package/dist/bundler-config/progress/rspack.d.ts.map +1 -0
- package/dist/bundler-config/progress/rspack.js +37 -0
- package/dist/{plugin-progress → bundler-config/progress}/webpack.cjs +14 -12
- package/dist/bundler-config/progress/webpack.d.ts +9 -0
- package/dist/bundler-config/progress/webpack.d.ts.map +1 -0
- package/dist/bundler-config/progress/webpack.js +44 -0
- package/dist/colors.cjs +3 -4
- package/dist/colors.d.ts +1 -2
- package/dist/colors.d.ts.map +1 -1
- package/dist/colors.js +4 -5
- package/dist/config.cjs +11 -3
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -21
- package/dist/constants.cjs +21 -17
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -10
- package/dist/createUnpack.cjs +25 -33
- package/dist/createUnpack.d.ts +9 -4
- package/dist/createUnpack.d.ts.map +1 -1
- package/dist/createUnpack.js +36 -34
- package/dist/fs.cjs +91 -0
- package/dist/fs.d.ts +12 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +34 -0
- package/dist/global.js +1 -1
- package/dist/index.cjs +71 -59
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -47
- package/dist/lightningcss/loader.cjs +0 -2
- package/dist/lightningcss/loader.d.ts.map +1 -1
- package/dist/lightningcss/loader.js +5 -7
- package/dist/lightningcss/minimizer.cjs +14 -17
- package/dist/lightningcss/minimizer.d.ts +2 -2
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +16 -19
- package/dist/loadEnv.cjs +122 -0
- package/dist/loadEnv.d.ts +64 -0
- package/dist/loadEnv.d.ts.map +1 -0
- package/dist/loadEnv.js +80 -0
- package/dist/loadingAnimation.cjs +76 -0
- package/dist/loadingAnimation.d.ts +9 -0
- package/dist/loadingAnimation.d.ts.map +1 -0
- package/dist/loadingAnimation.js +44 -0
- package/dist/logger.cjs +6 -7
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +14 -14
- package/dist/openBrowser.d.ts.map +1 -1
- package/dist/openBrowser.js +8 -8
- package/dist/plugin.js +1 -1
- package/dist/prebundleDeps.cjs +31 -10
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +74 -52
- package/dist/progressBar.cjs +5 -12
- package/dist/progressBar.d.ts +2 -0
- package/dist/progressBar.d.ts.map +1 -1
- package/dist/progressBar.js +8 -5
- package/dist/reporter.cjs +15 -11
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +28 -23
- package/dist/run/build.cjs +4 -4
- package/dist/run/build.d.ts +1 -1
- package/dist/run/build.d.ts.map +1 -1
- package/dist/run/build.js +11 -11
- package/dist/run/dev.cjs +23 -16
- package/dist/run/dev.d.ts +1 -1
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +41 -33
- package/dist/run/index.js +1 -1
- package/dist/typed-css-modules/loader.cjs +2 -2
- package/dist/typed-css-modules/loader.d.ts.map +1 -1
- package/dist/typed-css-modules/loader.js +15 -15
- package/dist/typed-css-modules/plugin.cjs +1 -1
- package/dist/typed-css-modules/plugin.js +14 -14
- package/dist/typed-css-modules/utils.d.ts.map +1 -1
- package/dist/typed-css-modules/utils.js +7 -7
- package/dist/types/chunkSplit.js +1 -1
- package/dist/types/config.d.ts +32 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/dist/types/index.cjs +15 -15
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/lightningcss.d.ts +2 -2
- package/dist/types/lightningcss.d.ts.map +1 -1
- package/dist/types/lightningcss.js +1 -1
- package/dist/types/logger.js +1 -1
- package/dist/types/oxc.cjs +18 -0
- package/dist/types/oxc.d.ts +10 -0
- package/dist/types/oxc.d.ts.map +1 -0
- package/dist/types/oxc.js +2 -0
- package/dist/types/plugin.d.ts +2 -2
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/plugin.js +1 -1
- package/dist/utils.cjs +28 -38
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +19 -25
- package/dist/watchFiles.cjs +1 -1
- package/dist/watchFiles.d.ts +1 -1
- package/dist/watchFiles.d.ts.map +1 -1
- package/dist/watchFiles.js +6 -6
- package/package.json +6 -5
- package/dist/bundler-config/helper.d.ts.map +0 -1
- package/dist/bundler-config/helper.js +0 -39
- package/dist/plugin-progress/helper.d.ts.map +0 -1
- package/dist/plugin-progress/helper.js +0 -67
- package/dist/plugin-progress/rspack.d.ts.map +0 -1
- package/dist/plugin-progress/rspack.js +0 -37
- package/dist/plugin-progress/webpack.d.ts +0 -8
- package/dist/plugin-progress/webpack.d.ts.map +0 -1
- package/dist/plugin-progress/webpack.js +0 -42
package/dist/prebundleDeps.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import node_path from "node:path";
|
|
5
|
+
import { rspack } from "@rspack/core";
|
|
6
|
+
import cors from "cors";
|
|
7
|
+
import express from "express";
|
|
8
|
+
import html_webpack_plugin from "html-webpack-plugin";
|
|
9
|
+
import { globSync } from "tinyglobby";
|
|
10
|
+
import { colors } from "./colors.js";
|
|
11
|
+
import { TEMP_DIR } from "./constants.js";
|
|
12
|
+
import { removeDir } from "./fs.js";
|
|
13
|
+
import { restartCleaners } from "./global.js";
|
|
14
|
+
import { logger } from "./logger.js";
|
|
15
|
+
import { getCompiledPkgPath, getPort, getUserDepPath, isPlainObject, isString, logUpdate } from "./utils.js";
|
|
15
16
|
const CACHE_DIR = 'umd';
|
|
17
|
+
const FAILED_DEPS_CACHE_FILE = 'failed-deps.json';
|
|
18
|
+
const getFailedDepsCache = (failedDepsCachePath)=>{
|
|
19
|
+
if (node_fs.existsSync(failedDepsCachePath)) return JSON.parse(node_fs.readFileSync(failedDepsCachePath, 'utf-8'));
|
|
20
|
+
return {};
|
|
21
|
+
};
|
|
22
|
+
const saveFailedDepsCache = (failedDepsCachePath, cache)=>{
|
|
23
|
+
const cacheDir = node_path.dirname(failedDepsCachePath);
|
|
24
|
+
if (!node_fs.existsSync(cacheDir)) node_fs.mkdirSync(cacheDir, {
|
|
25
|
+
recursive: true
|
|
26
|
+
});
|
|
27
|
+
node_fs.writeFileSync(failedDepsCachePath, JSON.stringify(cache, null, 2), 'utf-8');
|
|
28
|
+
};
|
|
16
29
|
const getExternalLibraryName = (pkgName)=>{
|
|
17
30
|
const externalAlias = {
|
|
18
31
|
react: 'React',
|
|
@@ -26,23 +39,23 @@ const getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`;
|
|
|
26
39
|
const getExistExternals = (externals)=>{
|
|
27
40
|
const existExternals = new Set();
|
|
28
41
|
if (Array.isArray(externals)) externals.forEach((item)=>{
|
|
29
|
-
if (
|
|
42
|
+
if (isPlainObject(item)) Object.keys(item).forEach((key)=>existExternals.add(key));
|
|
30
43
|
});
|
|
31
|
-
else if (
|
|
44
|
+
else if (isPlainObject(externals)) Object.keys(externals).forEach((key)=>existExternals.add(key));
|
|
32
45
|
return Array.from(existExternals);
|
|
33
46
|
};
|
|
34
47
|
const getPkgEntry = (packageJson)=>{
|
|
35
48
|
if (packageJson.module) return packageJson.module;
|
|
36
49
|
if (packageJson.exports) {
|
|
37
|
-
if (
|
|
50
|
+
if (isString(packageJson.exports)) return packageJson.exports;
|
|
38
51
|
const defaultExport = packageJson.exports['.'];
|
|
39
52
|
if (defaultExport) {
|
|
40
|
-
if (
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
53
|
+
if (isString(defaultExport)) return defaultExport;
|
|
54
|
+
if (isString(defaultExport.import)) return defaultExport.import;
|
|
55
|
+
if (isString(defaultExport.browser)) return defaultExport.browser;
|
|
56
|
+
if (isString(defaultExport.default)) return defaultExport.default;
|
|
44
57
|
}
|
|
45
|
-
if (
|
|
58
|
+
if (isString(packageJson.exports.default)) return packageJson.exports.default;
|
|
46
59
|
}
|
|
47
60
|
if (packageJson.main) return packageJson.main;
|
|
48
61
|
};
|
|
@@ -53,16 +66,18 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
53
66
|
bundled: 0
|
|
54
67
|
};
|
|
55
68
|
const failedDeps = [];
|
|
69
|
+
const { root } = unpackConfig;
|
|
70
|
+
const failedDepsCachePath = node_path.resolve(root, TEMP_DIR, FAILED_DEPS_CACHE_FILE);
|
|
71
|
+
const failedCache = getFailedDepsCache(failedDepsCachePath);
|
|
56
72
|
const updateProgress = ()=>{
|
|
57
|
-
|
|
73
|
+
logUpdate(`${colors.magenta("\xbb")} optimizing dependencies (${count.bundled}/${count.total})`);
|
|
58
74
|
if (count.total === count.bundled + failedDeps.length) console.log();
|
|
59
75
|
};
|
|
60
|
-
const { root } = unpackConfig;
|
|
61
76
|
const bundleDep = ({ name, entry, version })=>new Promise((resolve)=>{
|
|
62
|
-
const pkgDir =
|
|
63
|
-
const outDir =
|
|
77
|
+
const pkgDir = node_path.resolve(root, TEMP_DIR, CACHE_DIR, name);
|
|
78
|
+
const outDir = node_path.resolve(pkgDir, version);
|
|
64
79
|
const getResult = ()=>{
|
|
65
|
-
const assets =
|
|
80
|
+
const assets = globSync('**/index.{js,css}', {
|
|
66
81
|
cwd: outDir,
|
|
67
82
|
absolute: true
|
|
68
83
|
});
|
|
@@ -71,8 +86,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
71
86
|
assets
|
|
72
87
|
};
|
|
73
88
|
};
|
|
74
|
-
if (
|
|
75
|
-
(0, __WEBPACK_EXTERNAL_MODULE__utils_js_d88b7fe1__.removeDir)(pkgDir);
|
|
89
|
+
if (node_fs.existsSync(outDir)) return void resolve(getResult());
|
|
76
90
|
count.total++;
|
|
77
91
|
updateProgress();
|
|
78
92
|
const getSwcOptions = ({ tsx })=>({
|
|
@@ -90,7 +104,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
90
104
|
}
|
|
91
105
|
}
|
|
92
106
|
});
|
|
93
|
-
const compiler =
|
|
107
|
+
const compiler = rspack({
|
|
94
108
|
entry: {
|
|
95
109
|
index: entry
|
|
96
110
|
},
|
|
@@ -137,12 +151,12 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
137
151
|
type: 'css/auto',
|
|
138
152
|
use: [
|
|
139
153
|
{
|
|
140
|
-
loader:
|
|
154
|
+
loader: getCompiledPkgPath('less-loader'),
|
|
141
155
|
options: {
|
|
142
156
|
lessOptions: {
|
|
143
157
|
javascriptEnabled: true
|
|
144
158
|
},
|
|
145
|
-
implementation:
|
|
159
|
+
implementation: getUserDepPath(root, 'less')
|
|
146
160
|
}
|
|
147
161
|
}
|
|
148
162
|
]
|
|
@@ -152,10 +166,10 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
152
166
|
type: 'css/auto',
|
|
153
167
|
use: [
|
|
154
168
|
{
|
|
155
|
-
loader:
|
|
169
|
+
loader: getCompiledPkgPath('sass-loader'),
|
|
156
170
|
options: {
|
|
157
171
|
api: 'modern-compiler',
|
|
158
|
-
implementation:
|
|
172
|
+
implementation: getUserDepPath(root, [
|
|
159
173
|
'sass-embedded',
|
|
160
174
|
'sass'
|
|
161
175
|
])
|
|
@@ -183,7 +197,8 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
183
197
|
if (null == stats ? void 0 : stats.hasErrors()) {
|
|
184
198
|
isFailed = true;
|
|
185
199
|
failedDeps.push(name);
|
|
186
|
-
|
|
200
|
+
failedCache[name] = version;
|
|
201
|
+
removeDir(outDir);
|
|
187
202
|
} else count.bundled++;
|
|
188
203
|
updateProgress();
|
|
189
204
|
compiler.close(()=>{
|
|
@@ -191,9 +206,9 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
191
206
|
});
|
|
192
207
|
});
|
|
193
208
|
});
|
|
194
|
-
const userOptions =
|
|
209
|
+
const userOptions = isPlainObject(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) ? unpackConfig.dev.prebundle : {};
|
|
195
210
|
const ignoreCssDeps = userOptions.ignoreCss || [];
|
|
196
|
-
const packageJson = JSON.parse(
|
|
211
|
+
const packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'package.json'), 'utf-8'));
|
|
197
212
|
const existExternals = getExistExternals(unpackConfig.externals);
|
|
198
213
|
const excludeDeps = [
|
|
199
214
|
...existExternals || [],
|
|
@@ -202,25 +217,31 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
202
217
|
const shouldIncludeDeps = Object.keys(packageJson.dependencies).filter((pkgName)=>!excludeDeps.includes(pkgName));
|
|
203
218
|
const noEntryDeps = [];
|
|
204
219
|
const needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
205
|
-
const packageJson = JSON.parse(
|
|
220
|
+
const packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8'));
|
|
221
|
+
const version = packageJson.version;
|
|
222
|
+
if (failedCache[pkgName] === version) return;
|
|
206
223
|
const entry = getPkgEntry(packageJson);
|
|
207
|
-
if (!entry)
|
|
224
|
+
if (!entry) {
|
|
225
|
+
noEntryDeps.push(pkgName);
|
|
226
|
+
failedCache[pkgName] = version;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
208
229
|
return {
|
|
209
230
|
name: pkgName,
|
|
210
|
-
entry:
|
|
211
|
-
version
|
|
231
|
+
entry: node_path.resolve(root, 'node_modules', pkgName, entry),
|
|
232
|
+
version
|
|
212
233
|
};
|
|
213
234
|
}).filter(Boolean);
|
|
214
|
-
if (noEntryDeps[0]) __WEBPACK_EXTERNAL_MODULE__logger_js_c2be5186__.logger.warn(`could not find entry for "${__WEBPACK_EXTERNAL_MODULE__colors_js_b738ede3__["default"].bold(noEntryDeps.join(', '))}"`);
|
|
215
235
|
const bundledDeps = await Promise.all(needBundleDeps.map((depInfo)=>bundleDep(depInfo)));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
app
|
|
220
|
-
app.use(
|
|
221
|
-
|
|
236
|
+
saveFailedDepsCache(failedDepsCachePath, failedCache);
|
|
237
|
+
if (failedDeps[0]) logger.warn(`something went wrong while optimizing "${colors.bold(failedDeps.join(', '))}"`);
|
|
238
|
+
const cachePath = node_path.resolve(root, TEMP_DIR, CACHE_DIR);
|
|
239
|
+
const app = express();
|
|
240
|
+
app.use(cors());
|
|
241
|
+
app.use(`/${CACHE_DIR}`, express["static"](cachePath));
|
|
242
|
+
const port = await getPort();
|
|
222
243
|
const staticServer = app.listen(port, ()=>{});
|
|
223
|
-
|
|
244
|
+
restartCleaners.push(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
224
245
|
const externals = {};
|
|
225
246
|
const jsAssets = [];
|
|
226
247
|
const cssAssets = [];
|
|
@@ -228,7 +249,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
228
249
|
bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
229
250
|
externals[dep.name] = getExternalValue(dep.name);
|
|
230
251
|
dep.assets.forEach((absPath)=>{
|
|
231
|
-
const relativePath =
|
|
252
|
+
const relativePath = node_path.relative(cachePath, absPath);
|
|
232
253
|
const preDeps = [
|
|
233
254
|
'react',
|
|
234
255
|
'react-dom',
|
|
@@ -236,7 +257,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
236
257
|
'react-router-dom'
|
|
237
258
|
];
|
|
238
259
|
const serverPath = `//localhost:${port}/${CACHE_DIR}/${relativePath}`;
|
|
239
|
-
switch(
|
|
260
|
+
switch(node_path.extname(relativePath)){
|
|
240
261
|
case '.js':
|
|
241
262
|
if (preDeps.includes(dep.name)) preJsAssets.push({
|
|
242
263
|
path: serverPath,
|
|
@@ -259,7 +280,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
259
280
|
...externals,
|
|
260
281
|
...unpackConfig.externals
|
|
261
282
|
};
|
|
262
|
-
const HtmlPlugin = 'rspack' === unpackConfig.bundler ?
|
|
283
|
+
const HtmlPlugin = 'rspack' === unpackConfig.bundler ? rspack.HtmlRspackPlugin : html_webpack_plugin;
|
|
263
284
|
unpackConfig.plugins.push({
|
|
264
285
|
name: 'unpack:prebundle',
|
|
265
286
|
bundlerConfig: (config)=>{
|
|
@@ -268,7 +289,8 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
268
289
|
apply: (compiler)=>{
|
|
269
290
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
270
291
|
HtmlPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>{
|
|
271
|
-
|
|
292
|
+
const sortedPreJsAssets = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path);
|
|
293
|
+
args.assets.js.unshift(...sortedPreJsAssets, ...jsAssets);
|
|
272
294
|
args.assets.css.unshift(...cssAssets);
|
|
273
295
|
return args;
|
|
274
296
|
});
|
package/dist/progressBar.cjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
3
|
(()=>{
|
|
13
4
|
__webpack_require__.d = (exports1, definition)=>{
|
|
14
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -36,7 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
27
|
ProgressBar: ()=>ProgressBar
|
|
37
28
|
});
|
|
38
29
|
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
39
|
-
|
|
30
|
+
const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
|
|
40
31
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
41
32
|
function _define_property(obj, key, value) {
|
|
42
33
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -51,16 +42,18 @@ function _define_property(obj, key, value) {
|
|
|
51
42
|
class ProgressBar {
|
|
52
43
|
update({ current: originalCurrent, message = '' }) {
|
|
53
44
|
const { columns: terminalWidth } = process.stdout;
|
|
54
|
-
const messageWidth = terminalWidth - this.prefix.length - 8;
|
|
55
45
|
let current = originalCurrent;
|
|
56
46
|
if (originalCurrent >= 0.98) current = 1;
|
|
57
|
-
|
|
47
|
+
const loadingChar = this.loadingAnimation.getCurrentChar();
|
|
48
|
+
const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
|
|
49
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${external_colors_cjs_namespaceObject.colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
|
|
58
50
|
}
|
|
59
51
|
done() {
|
|
60
52
|
console.log();
|
|
61
53
|
}
|
|
62
54
|
constructor(){
|
|
63
55
|
_define_property(this, "prefix", 'transforming');
|
|
56
|
+
_define_property(this, "loadingAnimation", new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation());
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
exports.ProgressBar = __webpack_exports__.ProgressBar;
|
package/dist/progressBar.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../src/progressBar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../src/progressBar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,qBAAa,WAAW;IACtB,MAAM,SAAiB;IACvB,gBAAgB,mBAAyB;IAEzC,MAAM,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAY,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAcxF,IAAI;CAGL"}
|
package/dist/progressBar.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { colors } from "./colors.js";
|
|
4
|
+
import { LoadingAnimation } from "./loadingAnimation.js";
|
|
5
|
+
import { logUpdate } from "./utils.js";
|
|
5
6
|
function _define_property(obj, key, value) {
|
|
6
7
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
8
|
value: value,
|
|
@@ -15,16 +16,18 @@ function _define_property(obj, key, value) {
|
|
|
15
16
|
class ProgressBar {
|
|
16
17
|
update({ current: originalCurrent, message = '' }) {
|
|
17
18
|
const { columns: terminalWidth } = process.stdout;
|
|
18
|
-
const messageWidth = terminalWidth - this.prefix.length - 8;
|
|
19
19
|
let current = originalCurrent;
|
|
20
20
|
if (originalCurrent >= 0.98) current = 1;
|
|
21
|
-
|
|
21
|
+
const loadingChar = this.loadingAnimation.getCurrentChar();
|
|
22
|
+
const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
|
|
23
|
+
logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
|
|
22
24
|
}
|
|
23
25
|
done() {
|
|
24
26
|
console.log();
|
|
25
27
|
}
|
|
26
28
|
constructor(){
|
|
27
29
|
_define_property(this, "prefix", 'transforming');
|
|
30
|
+
_define_property(this, "loadingAnimation", new LoadingAnimation());
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
export { ProgressBar };
|
package/dist/reporter.cjs
CHANGED
|
@@ -43,7 +43,7 @@ const external_node_util_namespaceObject = require("node:util");
|
|
|
43
43
|
const external_node_zlib_namespaceObject = require("node:zlib");
|
|
44
44
|
var external_node_zlib_default = /*#__PURE__*/ __webpack_require__.n(external_node_zlib_namespaceObject);
|
|
45
45
|
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
46
|
-
|
|
46
|
+
const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
|
|
47
47
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
48
48
|
const chunkSizeLimit = 500;
|
|
49
49
|
const gzip = (0, external_node_util_namespaceObject.promisify)(external_node_zlib_default().gzip);
|
|
@@ -84,7 +84,8 @@ async function printFileSize({ root, stats }) {
|
|
|
84
84
|
return acc;
|
|
85
85
|
}, {});
|
|
86
86
|
let compressedCount = 0;
|
|
87
|
-
|
|
87
|
+
const loadingAnimation = new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation();
|
|
88
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
|
|
88
89
|
const distPath = stats.compilation.outputOptions.path;
|
|
89
90
|
const distFolder = external_node_path_default().relative(root, distPath);
|
|
90
91
|
const origin = stats.toJson({
|
|
@@ -107,8 +108,11 @@ async function printFileSize({ root, stats }) {
|
|
|
107
108
|
totalSize += size;
|
|
108
109
|
totalCompressedSize += compressedSize;
|
|
109
110
|
compressedCount++;
|
|
110
|
-
(0, external_utils_cjs_namespaceObject.logUpdate)(
|
|
111
|
-
if (compressedCount === origin.assets.length)
|
|
111
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
|
|
112
|
+
if (compressedCount === origin.assets.length) {
|
|
113
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`\u{2713} computed gzip size (${compressedCount})`);
|
|
114
|
+
console.log();
|
|
115
|
+
}
|
|
112
116
|
const chunk = {
|
|
113
117
|
name: external_node_path_default().basename(asset.name),
|
|
114
118
|
path: `${distFolder}/${asset.name}`,
|
|
@@ -139,16 +143,16 @@ async function printFileSize({ root, stats }) {
|
|
|
139
143
|
const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
|
|
140
144
|
const sizeColor = isLarge ? 'yellow' : 'dim';
|
|
141
145
|
const relativeOutDir = external_node_path_default().dirname(chunk.path) + '/';
|
|
142
|
-
let log =
|
|
143
|
-
log +=
|
|
144
|
-
log +=
|
|
145
|
-
if (chunk.compressedSize) log +=
|
|
146
|
+
let log = external_colors_cjs_namespaceObject.colors.dim(relativeOutDir);
|
|
147
|
+
log += external_colors_cjs_namespaceObject.colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
|
|
148
|
+
log += external_colors_cjs_namespaceObject.colors[sizeColor](displaySize(chunk.size).padStart(sizePad));
|
|
149
|
+
if (chunk.compressedSize) log += external_colors_cjs_namespaceObject.colors.dim(` \u{2502} gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
|
|
146
150
|
console.log(log);
|
|
147
151
|
});
|
|
148
152
|
});
|
|
149
|
-
let log =
|
|
150
|
-
log +=
|
|
151
|
-
log +=
|
|
153
|
+
let log = external_colors_cjs_namespaceObject.colors.blue('Total'.padEnd(longest + 2));
|
|
154
|
+
log += external_colors_cjs_namespaceObject.colors.blue(displaySize(totalSize));
|
|
155
|
+
log += external_colors_cjs_namespaceObject.colors.dim(` \u{2502} gzip: ${displaySize(totalCompressedSize)}`);
|
|
152
156
|
console.log(log);
|
|
153
157
|
}
|
|
154
158
|
exports.printFileSize = __webpack_exports__.printFileSize;
|
package/dist/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AAKpD,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,YAAY,GAAG,WAAW,CAAA;CAClC,CAAA;AA2BD,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,iBAiG3D"}
|
package/dist/reporter.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import node_path from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import node_zlib from "node:zlib";
|
|
7
|
+
import { colors } from "./colors.js";
|
|
8
|
+
import { LoadingAnimation } from "./loadingAnimation.js";
|
|
9
|
+
import { logUpdate } from "./utils.js";
|
|
9
10
|
const chunkSizeLimit = 500;
|
|
10
|
-
const gzip =
|
|
11
|
+
const gzip = promisify(node_zlib.gzip);
|
|
11
12
|
const numberFormatter = new Intl.NumberFormat('en', {
|
|
12
13
|
maximumFractionDigits: 2,
|
|
13
14
|
minimumFractionDigits: 2
|
|
@@ -45,9 +46,10 @@ async function printFileSize({ root, stats }) {
|
|
|
45
46
|
return acc;
|
|
46
47
|
}, {});
|
|
47
48
|
let compressedCount = 0;
|
|
48
|
-
|
|
49
|
+
const loadingAnimation = new LoadingAnimation();
|
|
50
|
+
logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
|
|
49
51
|
const distPath = stats.compilation.outputOptions.path;
|
|
50
|
-
const distFolder =
|
|
52
|
+
const distFolder = node_path.relative(root, distPath);
|
|
51
53
|
const origin = stats.toJson({
|
|
52
54
|
all: false,
|
|
53
55
|
assets: true,
|
|
@@ -62,22 +64,25 @@ async function printFileSize({ root, stats }) {
|
|
|
62
64
|
let totalSize = 0;
|
|
63
65
|
let totalCompressedSize = 0;
|
|
64
66
|
await Promise.all(origin.assets.map(async (asset)=>{
|
|
65
|
-
const content = await
|
|
67
|
+
const content = await node_fs.promises.readFile(node_path.join(distPath, asset.name));
|
|
66
68
|
const size = content.length;
|
|
67
69
|
const compressedSize = await getCompressedSize(content);
|
|
68
70
|
totalSize += size;
|
|
69
71
|
totalCompressedSize += compressedSize;
|
|
70
72
|
compressedCount++;
|
|
71
|
-
(
|
|
72
|
-
if (compressedCount === origin.assets.length)
|
|
73
|
+
logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
|
|
74
|
+
if (compressedCount === origin.assets.length) {
|
|
75
|
+
logUpdate(`\u{2713} computed gzip size (${compressedCount})`);
|
|
76
|
+
console.log();
|
|
77
|
+
}
|
|
73
78
|
const chunk = {
|
|
74
|
-
name:
|
|
79
|
+
name: node_path.basename(asset.name),
|
|
75
80
|
path: `${distFolder}/${asset.name}`,
|
|
76
81
|
size,
|
|
77
82
|
compressedSize
|
|
78
83
|
};
|
|
79
84
|
if (chunk.path.length > longest) longest = chunk.path.length;
|
|
80
|
-
const ext =
|
|
85
|
+
const ext = node_path.extname(asset.name);
|
|
81
86
|
switch(ext){
|
|
82
87
|
case '.html':
|
|
83
88
|
chunkGroupMap.HTML.chunks.push(chunk);
|
|
@@ -99,17 +104,17 @@ async function printFileSize({ root, stats }) {
|
|
|
99
104
|
group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
|
|
100
105
|
const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
|
|
101
106
|
const sizeColor = isLarge ? 'yellow' : 'dim';
|
|
102
|
-
const relativeOutDir =
|
|
103
|
-
let log =
|
|
104
|
-
log +=
|
|
105
|
-
log +=
|
|
106
|
-
if (chunk.compressedSize) log +=
|
|
107
|
+
const relativeOutDir = node_path.dirname(chunk.path) + '/';
|
|
108
|
+
let log = colors.dim(relativeOutDir);
|
|
109
|
+
log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
|
|
110
|
+
log += colors[sizeColor](displaySize(chunk.size).padStart(sizePad));
|
|
111
|
+
if (chunk.compressedSize) log += colors.dim(` \u{2502} gzip: ${displaySize(chunk.compressedSize).padStart(compressPad)}`);
|
|
107
112
|
console.log(log);
|
|
108
113
|
});
|
|
109
114
|
});
|
|
110
|
-
let log =
|
|
111
|
-
log +=
|
|
112
|
-
log +=
|
|
115
|
+
let log = colors.blue('Total'.padEnd(longest + 2));
|
|
116
|
+
log += colors.blue(displaySize(totalSize));
|
|
117
|
+
log += colors.dim(` \u{2502} gzip: ${displaySize(totalCompressedSize)}`);
|
|
113
118
|
console.log(log);
|
|
114
119
|
}
|
|
115
120
|
export { printFileSize };
|
package/dist/run/build.cjs
CHANGED
|
@@ -33,14 +33,14 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
36
|
+
unpackBuild: ()=>unpackBuild
|
|
37
37
|
});
|
|
38
38
|
const core_namespaceObject = require("@rspack/core");
|
|
39
39
|
const external_utils_cjs_namespaceObject = require("../utils.cjs");
|
|
40
40
|
const external_webpack_namespaceObject = require("webpack");
|
|
41
41
|
var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
|
|
42
42
|
const index_cjs_namespaceObject = require("../bundler-config/index.cjs");
|
|
43
|
-
async function
|
|
43
|
+
async function unpackBuild(unpackConfig) {
|
|
44
44
|
const bundler = 'rspack' === unpackConfig.bundler ? core_namespaceObject.rspack : external_webpack_default();
|
|
45
45
|
const config = await (0, index_cjs_namespaceObject.getBundlerConfig)(unpackConfig);
|
|
46
46
|
const compiler = bundler(config);
|
|
@@ -59,9 +59,9 @@ async function bundlerBuild(unpackConfig) {
|
|
|
59
59
|
if ((0, external_utils_cjs_namespaceObject.isWatch)()) compiler.watch({}, handler);
|
|
60
60
|
else compiler.run(handler);
|
|
61
61
|
}
|
|
62
|
-
exports.
|
|
62
|
+
exports.unpackBuild = __webpack_exports__.unpackBuild;
|
|
63
63
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
64
|
-
"
|
|
64
|
+
"unpackBuild"
|
|
65
65
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
66
66
|
Object.defineProperty(exports, '__esModule', {
|
|
67
67
|
value: true
|
package/dist/run/build.d.ts
CHANGED
package/dist/run/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/run/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKnD,wBAAsB,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/run/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKnD,wBAAsB,WAAW,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B3E"}
|
package/dist/run/build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
async function
|
|
8
|
-
const bundler = 'rspack' === unpackConfig.bundler ?
|
|
9
|
-
const config = await
|
|
3
|
+
import { rspack } from "@rspack/core";
|
|
4
|
+
import { isWatch } from "../utils.js";
|
|
5
|
+
import webpack from "webpack";
|
|
6
|
+
import { getBundlerConfig } from "../bundler-config/index.js";
|
|
7
|
+
async function unpackBuild(unpackConfig) {
|
|
8
|
+
const bundler = 'rspack' === unpackConfig.bundler ? rspack : webpack;
|
|
9
|
+
const config = await getBundlerConfig(unpackConfig);
|
|
10
10
|
const compiler = bundler(config);
|
|
11
11
|
const handler = (err, stats)=>{
|
|
12
12
|
if (err) {
|
|
@@ -18,9 +18,9 @@ async function bundlerBuild(unpackConfig) {
|
|
|
18
18
|
colors: true,
|
|
19
19
|
preset: 'errors-only'
|
|
20
20
|
}));
|
|
21
|
-
if (!
|
|
21
|
+
if (!isWatch()) compiler.close(()=>{});
|
|
22
22
|
};
|
|
23
|
-
if (
|
|
23
|
+
if (isWatch()) compiler.watch({}, handler);
|
|
24
24
|
else compiler.run(handler);
|
|
25
25
|
}
|
|
26
|
-
export {
|
|
26
|
+
export { unpackBuild };
|