@unpackjs/core 2.2.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 +16 -8
- package/dist/bundler-config/cache.d.ts +2 -1
- package/dist/bundler-config/cache.d.ts.map +1 -1
- package/dist/bundler-config/cache.js +23 -15
- package/dist/bundler-config/chunkSplit.d.ts.map +1 -1
- package/dist/bundler-config/chunkSplit.js +3 -3
- package/dist/bundler-config/css.cjs +13 -15
- package/dist/bundler-config/css.js +19 -21
- package/dist/bundler-config/experimentCss.cjs +12 -11
- package/dist/bundler-config/experimentCss.js +15 -14
- package/dist/bundler-config/helpers.d.ts.map +1 -1
- package/dist/bundler-config/helpers.js +6 -6
- package/dist/bundler-config/index.cjs +40 -13
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +56 -29
- package/dist/bundler-config/jsMinify.cjs +8 -10
- package/dist/bundler-config/jsMinify.d.ts +1 -1
- package/dist/bundler-config/jsMinify.d.ts.map +1 -1
- package/dist/bundler-config/jsMinify.js +11 -13
- package/dist/bundler-config/oxlint/.oxlintrc.json +0 -1
- package/dist/bundler-config/oxlint/plugin.cjs +1 -1
- package/dist/bundler-config/oxlint/plugin.js +5 -5
- package/dist/bundler-config/progress/helpers.cjs +16 -2
- package/dist/bundler-config/progress/helpers.d.ts.map +1 -1
- package/dist/bundler-config/progress/helpers.js +18 -4
- package/dist/bundler-config/progress/rspack.cjs +1 -1
- package/dist/bundler-config/progress/rspack.js +2 -2
- package/dist/bundler-config/progress/webpack.cjs +2 -2
- package/dist/bundler-config/progress/webpack.js +5 -5
- package/dist/colors.js +3 -3
- package/dist/config.cjs +6 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -6
- package/dist/constants.cjs +16 -12
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -9
- package/dist/createUnpack.cjs +25 -23
- package/dist/createUnpack.d.ts +9 -4
- package/dist/createUnpack.d.ts.map +1 -1
- package/dist/createUnpack.js +27 -25
- package/dist/fs.cjs +10 -1
- package/dist/fs.d.ts +1 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +13 -7
- package/dist/global.js +1 -1
- package/dist/index.cjs +63 -50
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/lightningcss/loader.js +1 -1
- package/dist/lightningcss/minimizer.cjs +7 -8
- package/dist/lightningcss/minimizer.d.ts +2 -2
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +8 -9
- 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 +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +5 -5
- package/dist/openBrowser.d.ts.map +1 -1
- package/dist/openBrowser.js +3 -3
- package/dist/plugin.js +1 -1
- package/dist/prebundleDeps.cjs +27 -6
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +46 -25
- package/dist/progressBar.cjs +5 -2
- package/dist/progressBar.d.ts +2 -0
- package/dist/progressBar.d.ts.map +1 -1
- package/dist/progressBar.js +6 -3
- package/dist/reporter.cjs +4 -2
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +14 -12
- 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 +5 -5
- package/dist/run/dev.cjs +21 -13
- package/dist/run/dev.d.ts +1 -1
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +25 -17
- 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 +10 -10
- package/dist/typed-css-modules/plugin.js +5 -5
- package/dist/typed-css-modules/utils.d.ts.map +1 -1
- package/dist/typed-css-modules/utils.js +1 -1
- package/dist/types/chunkSplit.js +1 -1
- package/dist/types/config.d.ts +30 -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.js +1 -1
- 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 +3 -12
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -20
- 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 +4 -4
- package/package.json +5 -4
|
@@ -68,6 +68,7 @@ var __webpack_exports__ = {};
|
|
|
68
68
|
var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
|
|
69
69
|
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
70
70
|
const minimizer_cjs_namespaceObject = require("../lightningcss/minimizer.cjs");
|
|
71
|
+
const external_loadEnv_cjs_namespaceObject = require("../loadEnv.cjs");
|
|
71
72
|
const external_plugin_cjs_namespaceObject = require("../plugin.cjs");
|
|
72
73
|
const external_webpack_namespaceObject = require("webpack");
|
|
73
74
|
var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
|
|
@@ -84,7 +85,7 @@ var __webpack_exports__ = {};
|
|
|
84
85
|
const BundleAnalyzerPlugin = __webpack_require__("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
85
86
|
const CopyWebpackPlugin = __webpack_require__("copy-webpack-plugin");
|
|
86
87
|
async function getBundlerConfig(unpackConfig) {
|
|
87
|
-
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _minifyOptions_oxc, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build6,
|
|
88
|
+
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _minifyOptions_oxc, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build6, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build7, _unpackConfig_experiments;
|
|
88
89
|
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
89
90
|
const HtmlPlugin = isRspack ? core_namespaceObject.rspack.HtmlRspackPlugin : external_html_webpack_plugin_default();
|
|
90
91
|
const definePlugin = (define)=>isRspack ? new core_namespaceObject.rspack.DefinePlugin(define) : new (external_webpack_default()).DefinePlugin(define);
|
|
@@ -108,6 +109,10 @@ var __webpack_exports__ = {};
|
|
|
108
109
|
const oxcMinifyCompress = (0, external_utils_cjs_namespaceObject.isPlainObject)(null == (_minifyOptions_oxc = minifyOptions.oxc) ? void 0 : _minifyOptions_oxc.compress) ? minifyOptions.oxc.compress : {};
|
|
109
110
|
const ProgressPlugin = isRspack ? rspack_cjs_namespaceObject.ProgressRspackPlugin : webpack_cjs_namespaceObject.ProgressWebpackPlugin;
|
|
110
111
|
const wasmFilename = 'js/[hash].module.wasm';
|
|
112
|
+
const { publicVars, filePaths: envFilePaths } = (0, external_loadEnv_cjs_namespaceObject.loadEnv)({
|
|
113
|
+
prefixes: unpackConfig.envPrefix,
|
|
114
|
+
cwd: unpackConfig.root
|
|
115
|
+
});
|
|
111
116
|
let config = {
|
|
112
117
|
context: unpackConfig.root,
|
|
113
118
|
mode: (0, external_utils_cjs_namespaceObject.isDev)() ? 'development' : 'production',
|
|
@@ -123,21 +128,22 @@ var __webpack_exports__ = {};
|
|
|
123
128
|
crossOriginLoading: 'anonymous',
|
|
124
129
|
pathinfo: false,
|
|
125
130
|
publicPath: null == (_unpackConfig_build4 = unpackConfig.build) ? void 0 : _unpackConfig_build4.publicPath,
|
|
126
|
-
webassemblyModuleFilename: wasmFilename
|
|
131
|
+
webassemblyModuleFilename: wasmFilename,
|
|
132
|
+
assetModuleFilename: 'assets/[name].[contenthash:8][ext]'
|
|
127
133
|
},
|
|
128
134
|
infrastructureLogging: {
|
|
129
|
-
level: '
|
|
135
|
+
level: 'error'
|
|
130
136
|
},
|
|
131
137
|
devtool: null == (_unpackConfig_build5 = unpackConfig.build) ? void 0 : _unpackConfig_build5.sourceMap,
|
|
132
138
|
module: {
|
|
133
139
|
rules: [
|
|
134
140
|
{
|
|
135
|
-
test: /\.(png|
|
|
136
|
-
type: 'asset
|
|
141
|
+
test: /\.(png|jpg|jpeg|gif)$/i,
|
|
142
|
+
type: 'asset'
|
|
137
143
|
},
|
|
138
144
|
{
|
|
139
145
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
140
|
-
type: 'asset
|
|
146
|
+
type: 'asset'
|
|
141
147
|
},
|
|
142
148
|
{
|
|
143
149
|
test: /\.wasm$/,
|
|
@@ -150,7 +156,13 @@ var __webpack_exports__ = {};
|
|
|
150
156
|
]
|
|
151
157
|
},
|
|
152
158
|
plugins: [
|
|
153
|
-
|
|
159
|
+
definePlugin({
|
|
160
|
+
'import.meta.env.MODE': JSON.stringify((0, external_utils_cjs_namespaceObject.getNodeEnv)()),
|
|
161
|
+
'import.meta.env.DEV': (0, external_utils_cjs_namespaceObject.isDev)(),
|
|
162
|
+
'import.meta.env.PROD': (0, external_utils_cjs_namespaceObject.isProd)(),
|
|
163
|
+
...publicVars,
|
|
164
|
+
...unpackConfig.define
|
|
165
|
+
}),
|
|
154
166
|
!unpackConfig.mpa && new HtmlPlugin({
|
|
155
167
|
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
156
168
|
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? isRspack ? void 0 : false : external_constants_cjs_namespaceObject.TEMPLATE_CONTENT),
|
|
@@ -175,7 +187,7 @@ var __webpack_exports__ = {};
|
|
|
175
187
|
(null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.copy) && new CopyPlugin({
|
|
176
188
|
patterns: unpackConfig.build.copy
|
|
177
189
|
}),
|
|
178
|
-
|
|
190
|
+
unpackConfig.typeCheck && (0, external_utils_cjs_namespaceObject.isDev)() && isTs && new TsCheckerRspackPlugin({
|
|
179
191
|
typescript: {
|
|
180
192
|
mode: 'readonly',
|
|
181
193
|
memoryLimit: 8192,
|
|
@@ -196,12 +208,13 @@ var __webpack_exports__ = {};
|
|
|
196
208
|
if (message.includes('Found')) console.log(message.split(' in ')[0]);
|
|
197
209
|
},
|
|
198
210
|
error (message) {
|
|
211
|
+
if (message.includes('RpcExitError') || message.includes('out of memory')) return;
|
|
199
212
|
console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
200
213
|
}
|
|
201
214
|
}
|
|
202
215
|
}),
|
|
203
216
|
new ProgressPlugin(),
|
|
204
|
-
new plugin_cjs_namespaceObject.OxlintPlugin()
|
|
217
|
+
unpackConfig.lint && new plugin_cjs_namespaceObject.OxlintPlugin()
|
|
205
218
|
].filter(Boolean),
|
|
206
219
|
externals: unpackConfig.externals,
|
|
207
220
|
resolve: {
|
|
@@ -210,12 +223,24 @@ var __webpack_exports__ = {};
|
|
|
210
223
|
...isTs ? getAliasFromTsconfig() : {},
|
|
211
224
|
...null == (_unpackConfig_resolve = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve.alias
|
|
212
225
|
},
|
|
226
|
+
extensionAlias: {
|
|
227
|
+
'.js': [
|
|
228
|
+
'.js',
|
|
229
|
+
'.ts',
|
|
230
|
+
'.tsx'
|
|
231
|
+
],
|
|
232
|
+
'.jsx': [
|
|
233
|
+
'.jsx',
|
|
234
|
+
'.tsx'
|
|
235
|
+
]
|
|
236
|
+
},
|
|
213
237
|
extensions: [
|
|
214
238
|
'.tsx',
|
|
215
239
|
'.ts',
|
|
216
240
|
'.jsx',
|
|
217
241
|
'.js',
|
|
218
242
|
'.wasm',
|
|
243
|
+
'.json',
|
|
219
244
|
...(null == (_unpackConfig_resolve1 = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve1.extensions) || []
|
|
220
245
|
]
|
|
221
246
|
},
|
|
@@ -226,17 +251,17 @@ var __webpack_exports__ = {};
|
|
|
226
251
|
},
|
|
227
252
|
optimization: {
|
|
228
253
|
moduleIds: (0, external_utils_cjs_namespaceObject.isDev)() ? 'named' : 'deterministic',
|
|
229
|
-
minimize: Boolean(null == (
|
|
254
|
+
minimize: Boolean(null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.minify),
|
|
230
255
|
minimizer: [
|
|
231
256
|
new external_jsMinify_cjs_namespaceObject.JsMinifyPlugin({
|
|
232
257
|
...minifyOptions.oxc,
|
|
233
258
|
compress: {
|
|
234
|
-
target:
|
|
259
|
+
target: external_constants_cjs_namespaceObject.DEFAULT_ES_TARGET,
|
|
235
260
|
...oxcMinifyCompress
|
|
236
261
|
}
|
|
237
262
|
}),
|
|
238
263
|
new minimizer_cjs_namespaceObject.LightningcssMinifyPlugin({
|
|
239
|
-
targets: external_constants_cjs_namespaceObject.
|
|
264
|
+
targets: external_constants_cjs_namespaceObject.DEFAULT_LIGHTNINGCSS_TARGET,
|
|
240
265
|
...minifyOptions.lightningcss
|
|
241
266
|
})
|
|
242
267
|
]
|
|
@@ -258,9 +283,11 @@ var __webpack_exports__ = {};
|
|
|
258
283
|
});
|
|
259
284
|
config = await (0, external_cache_cjs_namespaceObject.applyCacheConfig)({
|
|
260
285
|
config,
|
|
261
|
-
unpackConfig
|
|
286
|
+
unpackConfig,
|
|
287
|
+
envFilePaths
|
|
262
288
|
});
|
|
263
289
|
for (const plugin of (0, external_plugin_cjs_namespaceObject.getNormalizedPluginsByHook)('bundlerConfig', unpackConfig.plugins))config = await plugin.bundlerConfig(config, {
|
|
290
|
+
...unpackConfig._context,
|
|
264
291
|
unpackConfig,
|
|
265
292
|
mergeConfig: external_utils_cjs_namespaceObject.mergeConfig
|
|
266
293
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqCzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAwNhG"}
|
|
@@ -3,16 +3,17 @@ const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.ur
|
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js_fd7b218e__ from "../../compiled/webpack-bundle-analyzer/index.js";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_copy_webpack_plugin_34f78a42__ from "copy-webpack-plugin";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin_59177e58__ from "ts-checker-rspack-plugin";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import node_fs from "node:fs";
|
|
7
|
+
import node_path from "node:path";
|
|
8
8
|
import { rspack } from "@rspack/core";
|
|
9
|
-
import
|
|
10
|
-
import { isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
9
|
+
import html_webpack_plugin from "html-webpack-plugin";
|
|
10
|
+
import { getNodeEnv, isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
|
|
11
|
+
import json5 from "json5";
|
|
12
|
+
import { DEFAULT_ES_TARGET, DEFAULT_LIGHTNINGCSS_TARGET, NODE_MODULES_REGEX, TEMPLATE_CONTENT } from "../constants.js";
|
|
13
13
|
import { LightningcssMinifyPlugin } from "../lightningcss/minimizer.js";
|
|
14
|
+
import { loadEnv } from "../loadEnv.js";
|
|
14
15
|
import { getNormalizedPluginsByHook } from "../plugin.js";
|
|
15
|
-
import
|
|
16
|
+
import webpack from "webpack";
|
|
16
17
|
import { applyCacheConfig } from "./cache.js";
|
|
17
18
|
import { applyChunkSplitConfig } from "./chunkSplit.js";
|
|
18
19
|
import { applyCssConfig } from "./css.js";
|
|
@@ -47,23 +48,23 @@ const { TsCheckerRspackPlugin } = __webpack_require__("ts-checker-rspack-plugin"
|
|
|
47
48
|
const BundleAnalyzerPlugin = __webpack_require__("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
48
49
|
const CopyWebpackPlugin = __webpack_require__("copy-webpack-plugin");
|
|
49
50
|
async function getBundlerConfig(unpackConfig) {
|
|
50
|
-
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _minifyOptions_oxc, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build6,
|
|
51
|
+
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _minifyOptions_oxc, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build6, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build7, _unpackConfig_experiments;
|
|
51
52
|
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
52
|
-
const HtmlPlugin = isRspack ? rspack.HtmlRspackPlugin :
|
|
53
|
-
const definePlugin = (define)=>isRspack ? new rspack.DefinePlugin(define) : new
|
|
53
|
+
const HtmlPlugin = isRspack ? rspack.HtmlRspackPlugin : html_webpack_plugin;
|
|
54
|
+
const definePlugin = (define)=>isRspack ? new rspack.DefinePlugin(define) : new webpack.DefinePlugin(define);
|
|
54
55
|
const JS_FILENAME = getOutputFilename({
|
|
55
56
|
type: 'js',
|
|
56
57
|
hash: null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.filenameHash
|
|
57
58
|
});
|
|
58
|
-
const IgnorePlugin = isRspack ? rspack.IgnorePlugin :
|
|
59
|
+
const IgnorePlugin = isRspack ? rspack.IgnorePlugin : webpack.IgnorePlugin;
|
|
59
60
|
const CopyPlugin = isRspack ? rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
60
|
-
const tsconfigPath =
|
|
61
|
-
const isTs =
|
|
61
|
+
const tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json');
|
|
62
|
+
const isTs = node_fs.existsSync(tsconfigPath);
|
|
62
63
|
const getAliasFromTsconfig = ()=>{
|
|
63
64
|
var _json5_parse_compilerOptions, _json5_parse;
|
|
64
|
-
const paths = null == (_json5_parse =
|
|
65
|
+
const paths = null == (_json5_parse = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'))) ? void 0 : null == (_json5_parse_compilerOptions = _json5_parse.compilerOptions) ? void 0 : _json5_parse_compilerOptions.paths;
|
|
65
66
|
return paths ? Object.keys(paths).reduce((acc, key)=>{
|
|
66
|
-
acc[key.replace(/\/\*$/, '')] =
|
|
67
|
+
acc[key.replace(/\/\*$/, '')] = node_path.resolve(unpackConfig.root, paths[key][0].replace(/\/\*$/, ''));
|
|
67
68
|
return acc;
|
|
68
69
|
}, {}) : {};
|
|
69
70
|
};
|
|
@@ -71,6 +72,10 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
71
72
|
const oxcMinifyCompress = isPlainObject(null == (_minifyOptions_oxc = minifyOptions.oxc) ? void 0 : _minifyOptions_oxc.compress) ? minifyOptions.oxc.compress : {};
|
|
72
73
|
const ProgressPlugin = isRspack ? ProgressRspackPlugin : ProgressWebpackPlugin;
|
|
73
74
|
const wasmFilename = 'js/[hash].module.wasm';
|
|
75
|
+
const { publicVars, filePaths: envFilePaths } = loadEnv({
|
|
76
|
+
prefixes: unpackConfig.envPrefix,
|
|
77
|
+
cwd: unpackConfig.root
|
|
78
|
+
});
|
|
74
79
|
let config = {
|
|
75
80
|
context: unpackConfig.root,
|
|
76
81
|
mode: isDev() ? 'development' : 'production',
|
|
@@ -80,27 +85,28 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
80
85
|
stats: 'errors-only',
|
|
81
86
|
output: {
|
|
82
87
|
clean: true,
|
|
83
|
-
path:
|
|
88
|
+
path: node_path.resolve(unpackConfig.root, null == (_unpackConfig_build3 = unpackConfig.build) ? void 0 : _unpackConfig_build3.outDir),
|
|
84
89
|
filename: JS_FILENAME,
|
|
85
90
|
chunkFilename: JS_FILENAME,
|
|
86
91
|
crossOriginLoading: 'anonymous',
|
|
87
92
|
pathinfo: false,
|
|
88
93
|
publicPath: null == (_unpackConfig_build4 = unpackConfig.build) ? void 0 : _unpackConfig_build4.publicPath,
|
|
89
|
-
webassemblyModuleFilename: wasmFilename
|
|
94
|
+
webassemblyModuleFilename: wasmFilename,
|
|
95
|
+
assetModuleFilename: 'assets/[name].[contenthash:8][ext]'
|
|
90
96
|
},
|
|
91
97
|
infrastructureLogging: {
|
|
92
|
-
level: '
|
|
98
|
+
level: 'error'
|
|
93
99
|
},
|
|
94
100
|
devtool: null == (_unpackConfig_build5 = unpackConfig.build) ? void 0 : _unpackConfig_build5.sourceMap,
|
|
95
101
|
module: {
|
|
96
102
|
rules: [
|
|
97
103
|
{
|
|
98
|
-
test: /\.(png|
|
|
99
|
-
type: 'asset
|
|
104
|
+
test: /\.(png|jpg|jpeg|gif)$/i,
|
|
105
|
+
type: 'asset'
|
|
100
106
|
},
|
|
101
107
|
{
|
|
102
108
|
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
103
|
-
type: 'asset
|
|
109
|
+
type: 'asset'
|
|
104
110
|
},
|
|
105
111
|
{
|
|
106
112
|
test: /\.wasm$/,
|
|
@@ -113,7 +119,13 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
113
119
|
]
|
|
114
120
|
},
|
|
115
121
|
plugins: [
|
|
116
|
-
|
|
122
|
+
definePlugin({
|
|
123
|
+
'import.meta.env.MODE': JSON.stringify(getNodeEnv()),
|
|
124
|
+
'import.meta.env.DEV': isDev(),
|
|
125
|
+
'import.meta.env.PROD': isProd(),
|
|
126
|
+
...publicVars,
|
|
127
|
+
...unpackConfig.define
|
|
128
|
+
}),
|
|
117
129
|
!unpackConfig.mpa && new HtmlPlugin({
|
|
118
130
|
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
119
131
|
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? isRspack ? void 0 : false : TEMPLATE_CONTENT),
|
|
@@ -138,7 +150,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
138
150
|
(null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.copy) && new CopyPlugin({
|
|
139
151
|
patterns: unpackConfig.build.copy
|
|
140
152
|
}),
|
|
141
|
-
|
|
153
|
+
unpackConfig.typeCheck && isDev() && isTs && new TsCheckerRspackPlugin({
|
|
142
154
|
typescript: {
|
|
143
155
|
mode: 'readonly',
|
|
144
156
|
memoryLimit: 8192,
|
|
@@ -159,26 +171,39 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
159
171
|
if (message.includes('Found')) console.log(message.split(' in ')[0]);
|
|
160
172
|
},
|
|
161
173
|
error (message) {
|
|
174
|
+
if (message.includes('RpcExitError') || message.includes('out of memory')) return;
|
|
162
175
|
console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
163
176
|
}
|
|
164
177
|
}
|
|
165
178
|
}),
|
|
166
179
|
new ProgressPlugin(),
|
|
167
|
-
new OxlintPlugin()
|
|
180
|
+
unpackConfig.lint && new OxlintPlugin()
|
|
168
181
|
].filter(Boolean),
|
|
169
182
|
externals: unpackConfig.externals,
|
|
170
183
|
resolve: {
|
|
171
184
|
alias: {
|
|
172
|
-
'@':
|
|
185
|
+
'@': node_path.resolve(unpackConfig.root, 'src'),
|
|
173
186
|
...isTs ? getAliasFromTsconfig() : {},
|
|
174
187
|
...null == (_unpackConfig_resolve = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve.alias
|
|
175
188
|
},
|
|
189
|
+
extensionAlias: {
|
|
190
|
+
'.js': [
|
|
191
|
+
'.js',
|
|
192
|
+
'.ts',
|
|
193
|
+
'.tsx'
|
|
194
|
+
],
|
|
195
|
+
'.jsx': [
|
|
196
|
+
'.jsx',
|
|
197
|
+
'.tsx'
|
|
198
|
+
]
|
|
199
|
+
},
|
|
176
200
|
extensions: [
|
|
177
201
|
'.tsx',
|
|
178
202
|
'.ts',
|
|
179
203
|
'.jsx',
|
|
180
204
|
'.js',
|
|
181
205
|
'.wasm',
|
|
206
|
+
'.json',
|
|
182
207
|
...(null == (_unpackConfig_resolve1 = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve1.extensions) || []
|
|
183
208
|
]
|
|
184
209
|
},
|
|
@@ -189,17 +214,17 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
189
214
|
},
|
|
190
215
|
optimization: {
|
|
191
216
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
192
|
-
minimize: Boolean(null == (
|
|
217
|
+
minimize: Boolean(null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.minify),
|
|
193
218
|
minimizer: [
|
|
194
219
|
new JsMinifyPlugin({
|
|
195
220
|
...minifyOptions.oxc,
|
|
196
221
|
compress: {
|
|
197
|
-
target:
|
|
222
|
+
target: DEFAULT_ES_TARGET,
|
|
198
223
|
...oxcMinifyCompress
|
|
199
224
|
}
|
|
200
225
|
}),
|
|
201
226
|
new LightningcssMinifyPlugin({
|
|
202
|
-
targets:
|
|
227
|
+
targets: DEFAULT_LIGHTNINGCSS_TARGET,
|
|
203
228
|
...minifyOptions.lightningcss
|
|
204
229
|
})
|
|
205
230
|
]
|
|
@@ -221,9 +246,11 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
221
246
|
});
|
|
222
247
|
config = await applyCacheConfig({
|
|
223
248
|
config,
|
|
224
|
-
unpackConfig
|
|
249
|
+
unpackConfig,
|
|
250
|
+
envFilePaths
|
|
225
251
|
});
|
|
226
252
|
for (const plugin of getNormalizedPluginsByHook('bundlerConfig', unpackConfig.plugins))config = await plugin.bundlerConfig(config, {
|
|
253
|
+
...unpackConfig._context,
|
|
227
254
|
unpackConfig,
|
|
228
255
|
mergeConfig: mergeConfig
|
|
229
256
|
});
|
|
@@ -53,11 +53,10 @@ const isJsFile = /\.[cm]?js(\?.*)?$/i;
|
|
|
53
53
|
const PLUGIN_NAME = 'JsMinifyPlugin';
|
|
54
54
|
class JsMinifyPlugin {
|
|
55
55
|
apply(compiler) {
|
|
56
|
-
const { implementation, ...minifyOptions } = this.options;
|
|
57
56
|
const meta = JSON.stringify({
|
|
58
57
|
name: PLUGIN_NAME,
|
|
59
|
-
version: "2.
|
|
60
|
-
options: minifyOptions
|
|
58
|
+
version: "2.3.0",
|
|
59
|
+
options: this.minifyOptions
|
|
61
60
|
});
|
|
62
61
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
63
62
|
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash)=>hash.update(meta));
|
|
@@ -73,17 +72,16 @@ class JsMinifyPlugin {
|
|
|
73
72
|
}
|
|
74
73
|
transformAssets(compilation) {
|
|
75
74
|
const { options: { devtool } } = compilation.compiler;
|
|
76
|
-
const sourceMap =
|
|
75
|
+
const sourceMap = 'string' == typeof devtool && devtool.includes('source-map');
|
|
77
76
|
const assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && isJsFile.test(asset.name));
|
|
78
|
-
const { implementation, ...minifyOptions } = this.options;
|
|
79
77
|
assets.map((asset)=>{
|
|
80
78
|
const { source, map } = asset.source.sourceAndMap();
|
|
81
79
|
const { name } = asset;
|
|
82
80
|
const output = this.minify(name, Buffer.isBuffer(source) ? source.toString() : source, {
|
|
83
81
|
sourcemap: sourceMap,
|
|
84
|
-
...minifyOptions
|
|
82
|
+
...this.minifyOptions
|
|
85
83
|
});
|
|
86
|
-
let newMap;
|
|
84
|
+
let newMap = null;
|
|
87
85
|
if (output.map) {
|
|
88
86
|
newMap = 'string' == typeof output.map ? JSON.parse(output.map) : output.map;
|
|
89
87
|
newMap.sources = [
|
|
@@ -99,11 +97,11 @@ class JsMinifyPlugin {
|
|
|
99
97
|
});
|
|
100
98
|
}
|
|
101
99
|
constructor(options = {}){
|
|
102
|
-
_define_property(this, "options", {});
|
|
103
100
|
_define_property(this, "minify", void 0);
|
|
104
|
-
|
|
101
|
+
_define_property(this, "minifyOptions", void 0);
|
|
102
|
+
const { implementation, ...minifyOptions } = options;
|
|
105
103
|
this.minify = (null == implementation ? void 0 : implementation.minify) ?? external_oxc_minify_namespaceObject.minify;
|
|
106
|
-
this.
|
|
104
|
+
this.minifyOptions = minifyOptions;
|
|
107
105
|
}
|
|
108
106
|
}
|
|
109
107
|
exports.JsMinifyPlugin = __webpack_exports__.JsMinifyPlugin;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { OxcMinifyPluginOptions } from '../types/oxc';
|
|
2
2
|
import webpack from 'webpack';
|
|
3
3
|
export declare class JsMinifyPlugin {
|
|
4
|
-
private readonly options;
|
|
5
4
|
private readonly minify;
|
|
5
|
+
private readonly minifyOptions;
|
|
6
6
|
constructor(options?: OxcMinifyPluginOptions);
|
|
7
7
|
apply(compiler: webpack.Compiler): void;
|
|
8
8
|
private transformAssets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsMinify.d.ts","sourceRoot":"","sources":["../../src/bundler-config/jsMinify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,OAAO,MAAM,SAAS,CAAA;AAM7B,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"jsMinify.d.ts","sourceRoot":"","sources":["../../src/bundler-config/jsMinify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,OAAO,MAAM,SAAS,CAAA;AAM7B,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;gBAEjC,OAAO,GAAE,sBAA2B;IAMhD,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ;IA0BhC,OAAO,CAAC,eAAe;CA8BxB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { minify } from "oxc-minify";
|
|
4
|
-
import
|
|
4
|
+
import webpack from "webpack";
|
|
5
5
|
function _define_property(obj, key, value) {
|
|
6
6
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
7
|
value: value,
|
|
@@ -12,16 +12,15 @@ function _define_property(obj, key, value) {
|
|
|
12
12
|
else obj[key] = value;
|
|
13
13
|
return obj;
|
|
14
14
|
}
|
|
15
|
-
const { RawSource, SourceMapSource } =
|
|
15
|
+
const { RawSource, SourceMapSource } = webpack.sources;
|
|
16
16
|
const isJsFile = /\.[cm]?js(\?.*)?$/i;
|
|
17
17
|
const PLUGIN_NAME = 'JsMinifyPlugin';
|
|
18
18
|
class JsMinifyPlugin {
|
|
19
19
|
apply(compiler) {
|
|
20
|
-
const { implementation, ...minifyOptions } = this.options;
|
|
21
20
|
const meta = JSON.stringify({
|
|
22
21
|
name: PLUGIN_NAME,
|
|
23
|
-
version: "2.
|
|
24
|
-
options: minifyOptions
|
|
22
|
+
version: "2.3.0",
|
|
23
|
+
options: this.minifyOptions
|
|
25
24
|
});
|
|
26
25
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
27
26
|
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash)=>hash.update(meta));
|
|
@@ -37,17 +36,16 @@ class JsMinifyPlugin {
|
|
|
37
36
|
}
|
|
38
37
|
transformAssets(compilation) {
|
|
39
38
|
const { options: { devtool } } = compilation.compiler;
|
|
40
|
-
const sourceMap =
|
|
39
|
+
const sourceMap = 'string' == typeof devtool && devtool.includes('source-map');
|
|
41
40
|
const assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && isJsFile.test(asset.name));
|
|
42
|
-
const { implementation, ...minifyOptions } = this.options;
|
|
43
41
|
assets.map((asset)=>{
|
|
44
42
|
const { source, map } = asset.source.sourceAndMap();
|
|
45
43
|
const { name } = asset;
|
|
46
44
|
const output = this.minify(name, Buffer.isBuffer(source) ? source.toString() : source, {
|
|
47
45
|
sourcemap: sourceMap,
|
|
48
|
-
...minifyOptions
|
|
46
|
+
...this.minifyOptions
|
|
49
47
|
});
|
|
50
|
-
let newMap;
|
|
48
|
+
let newMap = null;
|
|
51
49
|
if (output.map) {
|
|
52
50
|
newMap = 'string' == typeof output.map ? JSON.parse(output.map) : output.map;
|
|
53
51
|
newMap.sources = [
|
|
@@ -63,11 +61,11 @@ class JsMinifyPlugin {
|
|
|
63
61
|
});
|
|
64
62
|
}
|
|
65
63
|
constructor(options = {}){
|
|
66
|
-
_define_property(this, "options", {});
|
|
67
64
|
_define_property(this, "minify", void 0);
|
|
68
|
-
|
|
65
|
+
_define_property(this, "minifyOptions", void 0);
|
|
66
|
+
const { implementation, ...minifyOptions } = options;
|
|
69
67
|
this.minify = (null == implementation ? void 0 : implementation.minify) ?? minify;
|
|
70
|
-
this.
|
|
68
|
+
this.minifyOptions = minifyOptions;
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
export { JsMinifyPlugin };
|
|
@@ -131,7 +131,7 @@ class OxlintPlugin {
|
|
|
131
131
|
}
|
|
132
132
|
constructor(){
|
|
133
133
|
_define_property(this, "timeoutId", null);
|
|
134
|
-
_define_property(this, "debounceTime",
|
|
134
|
+
_define_property(this, "debounceTime", 200);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
exports.OxlintPlugin = __webpack_exports__.OxlintPlugin;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
4
4
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
|
-
import
|
|
6
|
+
import node_path from "node:path";
|
|
7
7
|
var plugin_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
8
8
|
function _define_property(obj, key, value) {
|
|
9
9
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -39,7 +39,7 @@ class OxlintPlugin {
|
|
|
39
39
|
if (status.includes('D')) return null;
|
|
40
40
|
if (status.startsWith('R') || status.startsWith('C')) filePath = filePath.split(' -> ')[1];
|
|
41
41
|
return filePath;
|
|
42
|
-
}).filter(Boolean).map((file)=>
|
|
42
|
+
}).filter(Boolean).map((file)=>node_path.resolve(process.cwd(), file));
|
|
43
43
|
resolve(files);
|
|
44
44
|
} else resolve([]);
|
|
45
45
|
});
|
|
@@ -79,7 +79,7 @@ class OxlintPlugin {
|
|
|
79
79
|
compiler.hooks.watchRun.tap('OxlintPlugin', ()=>{
|
|
80
80
|
if (this.timeoutId) clearTimeout(this.timeoutId);
|
|
81
81
|
this.timeoutId = setTimeout(()=>{
|
|
82
|
-
const configPath =
|
|
82
|
+
const configPath = node_path.resolve(plugin_dirname, '.oxlintrc.json');
|
|
83
83
|
this.getGitChangedFiles().then((changedFiles)=>{
|
|
84
84
|
if (changedFiles.length > 0) {
|
|
85
85
|
const args = [
|
|
@@ -98,7 +98,7 @@ class OxlintPlugin {
|
|
|
98
98
|
}
|
|
99
99
|
constructor(){
|
|
100
100
|
_define_property(this, "timeoutId", null);
|
|
101
|
-
_define_property(this, "debounceTime",
|
|
101
|
+
_define_property(this, "debounceTime", 200);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
export { OxlintPlugin };
|
|
@@ -89,14 +89,28 @@ async function compileDone(compiler, stats) {
|
|
|
89
89
|
root,
|
|
90
90
|
stats
|
|
91
91
|
});
|
|
92
|
-
|
|
92
|
+
external_logger_cjs_namespaceObject.logger.ready(external_colors_cjs_namespaceObject.colors.green(`built in ${(0, external_utils_cjs_namespaceObject.prettyTime)(compileTime)}`));
|
|
93
93
|
} else {
|
|
94
94
|
if ((0, external_utils_cjs_namespaceObject.isDebug)()) {
|
|
95
95
|
const modules = stats.compilation.modules;
|
|
96
|
+
const nodeModulesStats = new Map();
|
|
97
|
+
const nodeModulesPath = external_node_path_default().resolve(root, 'node_modules');
|
|
96
98
|
modules.forEach((module)=>{
|
|
97
99
|
const { resource } = module;
|
|
98
|
-
if (null == resource ? void 0 : resource.includes(
|
|
100
|
+
if (null == resource ? void 0 : resource.includes(nodeModulesPath)) {
|
|
101
|
+
const relativePath = external_node_path_default().relative(nodeModulesPath, resource);
|
|
102
|
+
const pathParts = relativePath.split(external_node_path_namespaceObject.sep);
|
|
103
|
+
let packageName;
|
|
104
|
+
packageName = pathParts[0].startsWith('@') ? `${pathParts[0]}/${pathParts[1]}` : pathParts[0];
|
|
105
|
+
if (packageName) nodeModulesStats.set(packageName, (nodeModulesStats.get(packageName) || 0) + 1);
|
|
106
|
+
}
|
|
99
107
|
});
|
|
108
|
+
if (nodeModulesStats.size > 0) {
|
|
109
|
+
const sortedStats = Array.from(nodeModulesStats.entries()).sort((a, b)=>a[1] - b[1]);
|
|
110
|
+
sortedStats.forEach(([packageName, count])=>{
|
|
111
|
+
external_logger_cjs_namespaceObject.logger.debug(`${external_colors_cjs_namespaceObject.colors.cyan(packageName)}: ${external_colors_cjs_namespaceObject.colors.yellow(count)} modules`);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
100
114
|
}
|
|
101
115
|
external_logger_cjs_namespaceObject.logger.ready(`built in ${(0, external_utils_cjs_namespaceObject.prettyTime)(compileTime)}${(0, external_utils_cjs_namespaceObject.isDebug)() ? ` (${stats.compilation.modules.size} modules)` : ''}`);
|
|
102
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/bundler-config/progress/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AA4C3C,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,QAgBlE;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/bundler-config/progress/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAA;AA4C3C,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,QAgBlE;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,iBA+C/E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
3
|
+
import node_path, { sep } from "node:path";
|
|
4
4
|
import { colors } from "../../colors.js";
|
|
5
5
|
import { logger } from "../../logger.js";
|
|
6
6
|
import { printFileSize } from "../../reporter.js";
|
|
@@ -52,14 +52,28 @@ async function compileDone(compiler, stats) {
|
|
|
52
52
|
root,
|
|
53
53
|
stats
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
logger.ready(colors.green(`built in ${prettyTime(compileTime)}`));
|
|
56
56
|
} else {
|
|
57
57
|
if (isDebug()) {
|
|
58
58
|
const modules = stats.compilation.modules;
|
|
59
|
+
const nodeModulesStats = new Map();
|
|
60
|
+
const nodeModulesPath = node_path.resolve(root, 'node_modules');
|
|
59
61
|
modules.forEach((module)=>{
|
|
60
62
|
const { resource } = module;
|
|
61
|
-
if (null == resource ? void 0 : resource.includes(
|
|
63
|
+
if (null == resource ? void 0 : resource.includes(nodeModulesPath)) {
|
|
64
|
+
const relativePath = node_path.relative(nodeModulesPath, resource);
|
|
65
|
+
const pathParts = relativePath.split(sep);
|
|
66
|
+
let packageName;
|
|
67
|
+
packageName = pathParts[0].startsWith('@') ? `${pathParts[0]}/${pathParts[1]}` : pathParts[0];
|
|
68
|
+
if (packageName) nodeModulesStats.set(packageName, (nodeModulesStats.get(packageName) || 0) + 1);
|
|
69
|
+
}
|
|
62
70
|
});
|
|
71
|
+
if (nodeModulesStats.size > 0) {
|
|
72
|
+
const sortedStats = Array.from(nodeModulesStats.entries()).sort((a, b)=>a[1] - b[1]);
|
|
73
|
+
sortedStats.forEach(([packageName, count])=>{
|
|
74
|
+
logger.debug(`${colors.cyan(packageName)}: ${colors.yellow(count)} modules`);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
63
77
|
}
|
|
64
78
|
logger.ready(`built in ${prettyTime(compileTime)}${isDebug() ? ` (${stats.compilation.modules.size} modules)` : ''}`);
|
|
65
79
|
}
|
|
@@ -47,7 +47,7 @@ class ProgressRspackPlugin extends core_namespaceObject.rspack.ProgressPlugin {
|
|
|
47
47
|
compiler.hooks.watchRun.tap(PLUGIN_NAME, ()=>{
|
|
48
48
|
(0, external_helpers_cjs_namespaceObject.printDevLog)(compiler, compiler.options.context);
|
|
49
49
|
});
|
|
50
|
-
compiler.hooks.
|
|
50
|
+
compiler.hooks.afterDone.tap(PLUGIN_NAME, async (stats)=>{
|
|
51
51
|
await (0, external_helpers_cjs_namespaceObject.compileDone)(compiler, stats);
|
|
52
52
|
});
|
|
53
53
|
}
|