@unpackjs/core 2.1.0 → 2.2.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 +26 -26
- package/compiled/postcss-loader/index.js +11 -11
- package/dist/bundler-config/cache.cjs +105 -0
- package/dist/bundler-config/cache.d.ts +6 -0
- package/dist/bundler-config/cache.d.ts.map +1 -0
- package/dist/bundler-config/cache.js +63 -0
- package/dist/bundler-config/chunkSplit.js +7 -7
- package/dist/bundler-config/css.cjs +4 -3
- package/dist/bundler-config/css.d.ts.map +1 -1
- package/dist/bundler-config/css.js +33 -32
- package/dist/bundler-config/experimentCss.cjs +4 -3
- package/dist/bundler-config/experimentCss.d.ts.map +1 -1
- package/dist/bundler-config/experimentCss.js +29 -28
- 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 +28 -17
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +69 -58
- package/dist/bundler-config/jsMinify.cjs +3 -3
- package/dist/bundler-config/jsMinify.d.ts +1 -9
- package/dist/bundler-config/jsMinify.d.ts.map +1 -1
- package/dist/bundler-config/jsMinify.js +7 -7
- package/dist/bundler-config/oxlint/.oxlintrc.json +30 -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} +9 -10
- 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 +67 -0
- package/dist/{plugin-progress → bundler-config/progress}/rspack.cjs +10 -10
- 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 +13 -11
- 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 +3 -4
- package/dist/config.cjs +5 -2
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -19
- package/dist/constants.cjs +8 -8
- package/dist/constants.js +2 -2
- package/dist/createUnpack.cjs +2 -12
- package/dist/createUnpack.js +19 -19
- package/dist/fs.cjs +82 -0
- package/dist/fs.d.ts +11 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +28 -0
- package/dist/index.cjs +17 -18
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -42
- package/dist/lightningcss/loader.cjs +0 -2
- package/dist/lightningcss/loader.d.ts.map +1 -1
- package/dist/lightningcss/loader.js +4 -6
- package/dist/lightningcss/minimizer.cjs +7 -9
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +9 -11
- package/dist/logger.cjs +5 -6
- package/dist/logger.js +12 -12
- package/dist/openBrowser.js +7 -7
- package/dist/prebundleDeps.cjs +5 -5
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +49 -48
- package/dist/progressBar.cjs +1 -11
- package/dist/progressBar.js +3 -3
- package/dist/reporter.cjs +11 -9
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +25 -22
- package/dist/run/build.js +8 -8
- package/dist/run/dev.cjs +3 -4
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +23 -23
- package/dist/typed-css-modules/loader.js +12 -12
- package/dist/typed-css-modules/plugin.cjs +1 -1
- package/dist/typed-css-modules/plugin.js +13 -13
- package/dist/typed-css-modules/utils.js +6 -6
- package/dist/types/config.d.ts +2 -0
- package/dist/types/config.d.ts.map +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/utils.cjs +26 -27
- package/dist/utils.js +16 -16
- package/dist/watchFiles.js +4 -4
- package/package.json +4 -4
- 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
|
@@ -3,23 +3,25 @@ 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
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
6
|
+
import external_node_fs_default from "node:fs";
|
|
7
|
+
import external_node_path_default from "node:path";
|
|
8
|
+
import { rspack } from "@rspack/core";
|
|
9
|
+
import external_html_webpack_plugin_default from "html-webpack-plugin";
|
|
10
|
+
import { isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
|
|
11
|
+
import external_json5_default from "json5";
|
|
12
|
+
import { LIGHTNINGCSS_TARGET, NODE_MODULES_REGEX, TEMPLATE_CONTENT } from "../constants.js";
|
|
13
|
+
import { LightningcssMinifyPlugin } from "../lightningcss/minimizer.js";
|
|
14
|
+
import { getNormalizedPluginsByHook } from "../plugin.js";
|
|
15
|
+
import external_webpack_default from "webpack";
|
|
16
|
+
import { applyCacheConfig } from "./cache.js";
|
|
17
|
+
import { applyChunkSplitConfig } from "./chunkSplit.js";
|
|
18
|
+
import { applyCssConfig } from "./css.js";
|
|
19
|
+
import { applyExperimentCssConfig } from "./experimentCss.js";
|
|
20
|
+
import { getEntry, getOutputFilename } from "./helpers.js";
|
|
21
|
+
import { JsMinifyPlugin } from "./jsMinify.js";
|
|
22
|
+
import { OxlintPlugin } from "./oxlint/plugin.js";
|
|
23
|
+
import { ProgressRspackPlugin } from "./progress/rspack.js";
|
|
24
|
+
import { ProgressWebpackPlugin } from "./progress/webpack.js";
|
|
23
25
|
var __webpack_modules__ = {
|
|
24
26
|
"../../compiled/webpack-bundle-analyzer/index.js": function(module) {
|
|
25
27
|
module.exports = __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js_fd7b218e__;
|
|
@@ -45,39 +47,40 @@ const { TsCheckerRspackPlugin } = __webpack_require__("ts-checker-rspack-plugin"
|
|
|
45
47
|
const BundleAnalyzerPlugin = __webpack_require__("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
46
48
|
const CopyWebpackPlugin = __webpack_require__("copy-webpack-plugin");
|
|
47
49
|
async function getBundlerConfig(unpackConfig) {
|
|
48
|
-
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _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_build7, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build8,
|
|
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, _unpackConfig_build7, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build8, _unpackConfig_experiments;
|
|
49
51
|
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
50
|
-
const HtmlPlugin = isRspack ?
|
|
51
|
-
const definePlugin = (define)=>isRspack ? new
|
|
52
|
-
const JS_FILENAME =
|
|
52
|
+
const HtmlPlugin = isRspack ? rspack.HtmlRspackPlugin : external_html_webpack_plugin_default;
|
|
53
|
+
const definePlugin = (define)=>isRspack ? new rspack.DefinePlugin(define) : new external_webpack_default.DefinePlugin(define);
|
|
54
|
+
const JS_FILENAME = getOutputFilename({
|
|
53
55
|
type: 'js',
|
|
54
56
|
hash: null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.filenameHash
|
|
55
57
|
});
|
|
56
|
-
const IgnorePlugin = isRspack ?
|
|
57
|
-
const CopyPlugin = isRspack ?
|
|
58
|
-
const tsconfigPath =
|
|
59
|
-
const isTs =
|
|
58
|
+
const IgnorePlugin = isRspack ? rspack.IgnorePlugin : external_webpack_default.IgnorePlugin;
|
|
59
|
+
const CopyPlugin = isRspack ? rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
60
|
+
const tsconfigPath = external_node_path_default.resolve(unpackConfig.root, 'tsconfig.json');
|
|
61
|
+
const isTs = external_node_fs_default.existsSync(tsconfigPath);
|
|
60
62
|
const getAliasFromTsconfig = ()=>{
|
|
61
63
|
var _json5_parse_compilerOptions, _json5_parse;
|
|
62
|
-
const paths = null == (_json5_parse =
|
|
64
|
+
const paths = null == (_json5_parse = external_json5_default.parse(external_node_fs_default.readFileSync(tsconfigPath, 'utf-8'))) ? void 0 : null == (_json5_parse_compilerOptions = _json5_parse.compilerOptions) ? void 0 : _json5_parse_compilerOptions.paths;
|
|
63
65
|
return paths ? Object.keys(paths).reduce((acc, key)=>{
|
|
64
|
-
acc[key.replace(/\/\*$/, '')] =
|
|
66
|
+
acc[key.replace(/\/\*$/, '')] = external_node_path_default.resolve(unpackConfig.root, paths[key][0].replace(/\/\*$/, ''));
|
|
65
67
|
return acc;
|
|
66
68
|
}, {}) : {};
|
|
67
69
|
};
|
|
68
|
-
const minifyOptions =
|
|
69
|
-
const
|
|
70
|
+
const minifyOptions = isPlainObject(null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.minify) ? null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.minify : {};
|
|
71
|
+
const oxcMinifyCompress = isPlainObject(null == (_minifyOptions_oxc = minifyOptions.oxc) ? void 0 : _minifyOptions_oxc.compress) ? minifyOptions.oxc.compress : {};
|
|
72
|
+
const ProgressPlugin = isRspack ? ProgressRspackPlugin : ProgressWebpackPlugin;
|
|
70
73
|
const wasmFilename = 'js/[hash].module.wasm';
|
|
71
74
|
let config = {
|
|
72
75
|
context: unpackConfig.root,
|
|
73
|
-
mode:
|
|
76
|
+
mode: isDev() ? 'development' : 'production',
|
|
74
77
|
entry: unpackConfig.mpa ? {} : {
|
|
75
|
-
main: await
|
|
78
|
+
main: await getEntry(unpackConfig.root, unpackConfig.entry)
|
|
76
79
|
},
|
|
77
80
|
stats: 'errors-only',
|
|
78
81
|
output: {
|
|
79
82
|
clean: true,
|
|
80
|
-
path:
|
|
83
|
+
path: external_node_path_default.resolve(unpackConfig.root, null == (_unpackConfig_build3 = unpackConfig.build) ? void 0 : _unpackConfig_build3.outDir),
|
|
81
84
|
filename: JS_FILENAME,
|
|
82
85
|
chunkFilename: JS_FILENAME,
|
|
83
86
|
crossOriginLoading: 'anonymous',
|
|
@@ -113,10 +116,10 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
113
116
|
unpackConfig.define && definePlugin(unpackConfig.define),
|
|
114
117
|
!unpackConfig.mpa && new HtmlPlugin({
|
|
115
118
|
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
116
|
-
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 :
|
|
119
|
+
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),
|
|
117
120
|
templateParameters: {
|
|
118
121
|
mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
|
|
119
|
-
title:
|
|
122
|
+
title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
|
|
120
123
|
entryName: 'index'
|
|
121
124
|
}) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
|
|
122
125
|
headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
@@ -127,7 +130,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
127
130
|
'main'
|
|
128
131
|
]
|
|
129
132
|
}),
|
|
130
|
-
(null == (_unpackConfig_performance = unpackConfig.performance) ? void 0 : _unpackConfig_performance.bundleAnalyze) &&
|
|
133
|
+
(null == (_unpackConfig_performance = unpackConfig.performance) ? void 0 : _unpackConfig_performance.bundleAnalyze) && isProd() && new BundleAnalyzerPlugin(),
|
|
131
134
|
(null == (_unpackConfig_performance1 = unpackConfig.performance) ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new IgnorePlugin({
|
|
132
135
|
resourceRegExp: /^\.\/locale$/,
|
|
133
136
|
contextRegExp: /moment$/
|
|
@@ -135,7 +138,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
135
138
|
(null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.copy) && new CopyPlugin({
|
|
136
139
|
patterns: unpackConfig.build.copy
|
|
137
140
|
}),
|
|
138
|
-
(null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.typeCheck) &&
|
|
141
|
+
(null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.typeCheck) && isDev() && isTs && new TsCheckerRspackPlugin({
|
|
139
142
|
typescript: {
|
|
140
143
|
mode: 'readonly',
|
|
141
144
|
memoryLimit: 8192,
|
|
@@ -148,7 +151,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
148
151
|
},
|
|
149
152
|
issue: {
|
|
150
153
|
exclude: [
|
|
151
|
-
({ file = '' })=>
|
|
154
|
+
({ file = '' })=>NODE_MODULES_REGEX.test(file)
|
|
152
155
|
]
|
|
153
156
|
},
|
|
154
157
|
logger: {
|
|
@@ -160,12 +163,13 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
}),
|
|
163
|
-
new
|
|
166
|
+
new ProgressPlugin(),
|
|
167
|
+
new OxlintPlugin()
|
|
164
168
|
].filter(Boolean),
|
|
165
169
|
externals: unpackConfig.externals,
|
|
166
170
|
resolve: {
|
|
167
171
|
alias: {
|
|
168
|
-
'@':
|
|
172
|
+
'@': external_node_path_default.resolve(unpackConfig.root, 'src'),
|
|
169
173
|
...isTs ? getAliasFromTsconfig() : {},
|
|
170
174
|
...null == (_unpackConfig_resolve = unpackConfig.resolve) ? void 0 : _unpackConfig_resolve.alias
|
|
171
175
|
},
|
|
@@ -179,46 +183,53 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
179
183
|
]
|
|
180
184
|
},
|
|
181
185
|
experiments: {
|
|
182
|
-
lazyCompilation: (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation) &&
|
|
186
|
+
lazyCompilation: (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation) && isDevServer(),
|
|
183
187
|
css: false,
|
|
184
|
-
asyncWebAssembly: true
|
|
185
|
-
...isRspack && (0, __WEBPACK_EXTERNAL_MODULE__utils_js_db66b9f7__.isDev)() ? {
|
|
186
|
-
incremental: true
|
|
187
|
-
} : {}
|
|
188
|
+
asyncWebAssembly: true
|
|
188
189
|
},
|
|
189
190
|
optimization: {
|
|
190
|
-
moduleIds:
|
|
191
|
+
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
191
192
|
minimize: Boolean(null == (_unpackConfig_build8 = unpackConfig.build) ? void 0 : _unpackConfig_build8.minify),
|
|
192
193
|
minimizer: [
|
|
193
|
-
new
|
|
194
|
-
|
|
194
|
+
new JsMinifyPlugin({
|
|
195
|
+
...minifyOptions.oxc,
|
|
196
|
+
compress: {
|
|
197
|
+
target: 'es2015',
|
|
198
|
+
...oxcMinifyCompress
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
201
|
+
new LightningcssMinifyPlugin({
|
|
202
|
+
targets: LIGHTNINGCSS_TARGET,
|
|
203
|
+
...minifyOptions.lightningcss
|
|
204
|
+
})
|
|
195
205
|
]
|
|
196
206
|
},
|
|
197
|
-
cache: (null == (_unpackConfig_build9 = unpackConfig.build) ? void 0 : _unpackConfig_build9.cache) && 'webpack' === unpackConfig.bundler ? {
|
|
198
|
-
type: 'filesystem'
|
|
199
|
-
} : void 0,
|
|
200
207
|
watchOptions: {
|
|
201
208
|
ignored: /[\\/](?:\.git|node_modules)[\\/]/
|
|
202
209
|
}
|
|
203
210
|
};
|
|
204
|
-
config = (null == (_unpackConfig_experiments = unpackConfig.experiments) ? void 0 : _unpackConfig_experiments.css) ?
|
|
211
|
+
config = (null == (_unpackConfig_experiments = unpackConfig.experiments) ? void 0 : _unpackConfig_experiments.css) ? applyExperimentCssConfig({
|
|
212
|
+
config,
|
|
213
|
+
unpackConfig
|
|
214
|
+
}) : applyCssConfig({
|
|
205
215
|
config,
|
|
206
216
|
unpackConfig
|
|
207
|
-
})
|
|
217
|
+
});
|
|
218
|
+
config = applyChunkSplitConfig({
|
|
208
219
|
config,
|
|
209
220
|
unpackConfig
|
|
210
221
|
});
|
|
211
|
-
config =
|
|
222
|
+
config = await applyCacheConfig({
|
|
212
223
|
config,
|
|
213
224
|
unpackConfig
|
|
214
225
|
});
|
|
215
|
-
for (const plugin of
|
|
226
|
+
for (const plugin of getNormalizedPluginsByHook('bundlerConfig', unpackConfig.plugins))config = await plugin.bundlerConfig(config, {
|
|
216
227
|
unpackConfig,
|
|
217
|
-
mergeConfig:
|
|
228
|
+
mergeConfig: mergeConfig
|
|
218
229
|
});
|
|
219
|
-
if (unpackConfig.bundlerConfig) config =
|
|
220
|
-
mergeConfig:
|
|
221
|
-
}) :
|
|
230
|
+
if (unpackConfig.bundlerConfig) config = isFunction(unpackConfig.bundlerConfig) ? await unpackConfig.bundlerConfig(config, {
|
|
231
|
+
mergeConfig: mergeConfig
|
|
232
|
+
}) : mergeConfig(config, unpackConfig.bundlerConfig);
|
|
222
233
|
return config;
|
|
223
234
|
}
|
|
224
235
|
export { getBundlerConfig };
|
|
@@ -56,7 +56,7 @@ class JsMinifyPlugin {
|
|
|
56
56
|
const { implementation, ...minifyOptions } = this.options;
|
|
57
57
|
const meta = JSON.stringify({
|
|
58
58
|
name: PLUGIN_NAME,
|
|
59
|
-
version: "2.
|
|
59
|
+
version: "2.2.0",
|
|
60
60
|
options: minifyOptions
|
|
61
61
|
});
|
|
62
62
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
@@ -80,8 +80,8 @@ class JsMinifyPlugin {
|
|
|
80
80
|
const { source, map } = asset.source.sourceAndMap();
|
|
81
81
|
const { name } = asset;
|
|
82
82
|
const output = this.minify(name, Buffer.isBuffer(source) ? source.toString() : source, {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
sourcemap: sourceMap,
|
|
84
|
+
...minifyOptions
|
|
85
85
|
});
|
|
86
86
|
let newMap;
|
|
87
87
|
if (output.map) {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { OxcMinifyPluginOptions } from '../types/oxc';
|
|
2
2
|
import webpack from 'webpack';
|
|
3
|
-
type Implementation = {
|
|
4
|
-
minify: typeof minify;
|
|
5
|
-
};
|
|
6
|
-
export type OxcMinifyPluginOptions = MinifyOptions & {
|
|
7
|
-
/** Pass a custom oxc-minify implementation */
|
|
8
|
-
implementation?: Implementation;
|
|
9
|
-
};
|
|
10
3
|
export declare class JsMinifyPlugin {
|
|
11
4
|
private readonly options;
|
|
12
5
|
private readonly minify;
|
|
@@ -14,5 +7,4 @@ export declare class JsMinifyPlugin {
|
|
|
14
7
|
apply(compiler: webpack.Compiler): void;
|
|
15
8
|
private transformAssets;
|
|
16
9
|
}
|
|
17
|
-
export {};
|
|
18
10
|
//# sourceMappingURL=jsMinify.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsMinify.d.ts","sourceRoot":"","sources":["../../src/bundler-config/jsMinify.ts"],"names":[],"mappings":"
|
|
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,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,OAAO,GAAE,sBAA2B;IAMhD,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ;IA2BhC,OAAO,CAAC,eAAe;CA+BxB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import __rslib_shim_module__ from 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { minify } from "oxc-minify";
|
|
4
|
+
import external_webpack_default 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,7 +12,7 @@ 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 } = external_webpack_default.sources;
|
|
16
16
|
const isJsFile = /\.[cm]?js(\?.*)?$/i;
|
|
17
17
|
const PLUGIN_NAME = 'JsMinifyPlugin';
|
|
18
18
|
class JsMinifyPlugin {
|
|
@@ -20,7 +20,7 @@ class JsMinifyPlugin {
|
|
|
20
20
|
const { implementation, ...minifyOptions } = this.options;
|
|
21
21
|
const meta = JSON.stringify({
|
|
22
22
|
name: PLUGIN_NAME,
|
|
23
|
-
version: "2.
|
|
23
|
+
version: "2.2.0",
|
|
24
24
|
options: minifyOptions
|
|
25
25
|
});
|
|
26
26
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
@@ -44,8 +44,8 @@ class JsMinifyPlugin {
|
|
|
44
44
|
const { source, map } = asset.source.sourceAndMap();
|
|
45
45
|
const { name } = asset;
|
|
46
46
|
const output = this.minify(name, Buffer.isBuffer(source) ? source.toString() : source, {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
sourcemap: sourceMap,
|
|
48
|
+
...minifyOptions
|
|
49
49
|
});
|
|
50
50
|
let newMap;
|
|
51
51
|
if (output.map) {
|
|
@@ -66,7 +66,7 @@ class JsMinifyPlugin {
|
|
|
66
66
|
_define_property(this, "options", {});
|
|
67
67
|
_define_property(this, "minify", void 0);
|
|
68
68
|
const { implementation } = options;
|
|
69
|
-
this.minify = (null == implementation ? void 0 : implementation.minify) ??
|
|
69
|
+
this.minify = (null == implementation ? void 0 : implementation.minify) ?? minify;
|
|
70
70
|
this.options = options;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": ["typescript", "unicorn", "react", "oxc", "react-perf", "jsdoc"],
|
|
3
|
+
"env": {
|
|
4
|
+
"browser": true,
|
|
5
|
+
"node": true
|
|
6
|
+
},
|
|
7
|
+
"globals": {},
|
|
8
|
+
"settings": {},
|
|
9
|
+
"rules": {
|
|
10
|
+
"prefer-object-spread": "error",
|
|
11
|
+
"yoda": "error",
|
|
12
|
+
"no-duplicate-imports": "error",
|
|
13
|
+
"no-undef": "error",
|
|
14
|
+
"react/jsx-boolean-value": "error",
|
|
15
|
+
"react/rules-of-hooks": "error",
|
|
16
|
+
"react/exhaustive-deps": "off",
|
|
17
|
+
"react/self-closing-comp": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
"html": false
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"unicorn/no-nested-ternary": "error",
|
|
24
|
+
"unicorn/prefer-node-protocol": "error",
|
|
25
|
+
"unicorn/prefer-array-some": "error",
|
|
26
|
+
"unicorn/prefer-string-slice": "error",
|
|
27
|
+
"unicorn/no-console-spaces": "error",
|
|
28
|
+
"typescript/no-import-type-side-effects": "error"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
OxlintPlugin: ()=>OxlintPlugin
|
|
37
|
+
});
|
|
38
|
+
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
39
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
40
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
41
|
+
function _define_property(obj, key, value) {
|
|
42
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
43
|
+
value: value,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true
|
|
47
|
+
});
|
|
48
|
+
else obj[key] = value;
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
class OxlintPlugin {
|
|
52
|
+
getGitChangedFiles() {
|
|
53
|
+
return new Promise((resolve)=>{
|
|
54
|
+
var _child_stdout;
|
|
55
|
+
const child = (0, external_node_child_process_namespaceObject.spawn)('git', [
|
|
56
|
+
'status',
|
|
57
|
+
'--porcelain'
|
|
58
|
+
], {
|
|
59
|
+
cwd: process.cwd(),
|
|
60
|
+
stdio: 'pipe'
|
|
61
|
+
});
|
|
62
|
+
let output = '';
|
|
63
|
+
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
64
|
+
output += data.toString();
|
|
65
|
+
});
|
|
66
|
+
child.on('exit', (code)=>{
|
|
67
|
+
if (0 === code) {
|
|
68
|
+
const files = output.trim().split('\n').filter(Boolean).map((line)=>{
|
|
69
|
+
const idx = line.indexOf(' ');
|
|
70
|
+
const status = line.slice(0, idx);
|
|
71
|
+
let filePath = line.slice(idx + 1).trim();
|
|
72
|
+
if (status.includes('D')) return null;
|
|
73
|
+
if (status.startsWith('R') || status.startsWith('C')) filePath = filePath.split(' -> ')[1];
|
|
74
|
+
return filePath;
|
|
75
|
+
}).filter(Boolean).map((file)=>external_node_path_default().resolve(process.cwd(), file));
|
|
76
|
+
resolve(files);
|
|
77
|
+
} else resolve([]);
|
|
78
|
+
});
|
|
79
|
+
child.on('error', ()=>{
|
|
80
|
+
resolve([]);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
runOxlint(args) {
|
|
85
|
+
var _child_stdout, _child_stderr;
|
|
86
|
+
const cwd = process.cwd();
|
|
87
|
+
const child = (0, external_node_child_process_namespaceObject.spawn)('npx', [
|
|
88
|
+
'--yes',
|
|
89
|
+
...args
|
|
90
|
+
], {
|
|
91
|
+
cwd,
|
|
92
|
+
stdio: 'pipe',
|
|
93
|
+
shell: true,
|
|
94
|
+
env: {
|
|
95
|
+
...process.env,
|
|
96
|
+
FORCE_COLOR: '1'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
let output = '';
|
|
100
|
+
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
101
|
+
output += data.toString();
|
|
102
|
+
});
|
|
103
|
+
child.on('exit', (code)=>{
|
|
104
|
+
const hasErrors = !output.includes('Found 0 warnings and 0 errors');
|
|
105
|
+
if (hasErrors || 0 !== code) process.stdout.write(output);
|
|
106
|
+
});
|
|
107
|
+
null == (_child_stderr = child.stderr) || _child_stderr.on('data', (data)=>{
|
|
108
|
+
process.stderr.write(data);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
apply(compiler) {
|
|
112
|
+
compiler.hooks.watchRun.tap('OxlintPlugin', ()=>{
|
|
113
|
+
if (this.timeoutId) clearTimeout(this.timeoutId);
|
|
114
|
+
this.timeoutId = setTimeout(()=>{
|
|
115
|
+
const configPath = external_node_path_default().resolve(__dirname, '.oxlintrc.json');
|
|
116
|
+
this.getGitChangedFiles().then((changedFiles)=>{
|
|
117
|
+
if (changedFiles.length > 0) {
|
|
118
|
+
const args = [
|
|
119
|
+
'oxlint',
|
|
120
|
+
'-c',
|
|
121
|
+
configPath,
|
|
122
|
+
...changedFiles,
|
|
123
|
+
'--fix',
|
|
124
|
+
'--fix-suggestions'
|
|
125
|
+
];
|
|
126
|
+
this.runOxlint(args);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}, this.debounceTime);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
constructor(){
|
|
133
|
+
_define_property(this, "timeoutId", null);
|
|
134
|
+
_define_property(this, "debounceTime", 300);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.OxlintPlugin = __webpack_exports__.OxlintPlugin;
|
|
138
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
139
|
+
"OxlintPlugin"
|
|
140
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
141
|
+
Object.defineProperty(exports, '__esModule', {
|
|
142
|
+
value: true
|
|
143
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Compiler } from '@rspack/core';
|
|
2
|
+
declare class OxlintPlugin {
|
|
3
|
+
private timeoutId;
|
|
4
|
+
private readonly debounceTime;
|
|
5
|
+
private getGitChangedFiles;
|
|
6
|
+
private runOxlint;
|
|
7
|
+
apply(compiler: Compiler): void;
|
|
8
|
+
}
|
|
9
|
+
export { OxlintPlugin };
|
|
10
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/bundler-config/oxlint/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,cAAM,YAAY;IAChB,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAM;IAEnC,OAAO,CAAC,kBAAkB;IAmD1B,OAAO,CAAC,SAAS;IA+BjB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAyBhC;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
4
|
+
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import external_node_path_default from "node:path";
|
|
7
|
+
var plugin_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
8
|
+
function _define_property(obj, key, value) {
|
|
9
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
10
|
+
value: value,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true
|
|
14
|
+
});
|
|
15
|
+
else obj[key] = value;
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
class OxlintPlugin {
|
|
19
|
+
getGitChangedFiles() {
|
|
20
|
+
return new Promise((resolve)=>{
|
|
21
|
+
var _child_stdout;
|
|
22
|
+
const child = spawn('git', [
|
|
23
|
+
'status',
|
|
24
|
+
'--porcelain'
|
|
25
|
+
], {
|
|
26
|
+
cwd: process.cwd(),
|
|
27
|
+
stdio: 'pipe'
|
|
28
|
+
});
|
|
29
|
+
let output = '';
|
|
30
|
+
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
31
|
+
output += data.toString();
|
|
32
|
+
});
|
|
33
|
+
child.on('exit', (code)=>{
|
|
34
|
+
if (0 === code) {
|
|
35
|
+
const files = output.trim().split('\n').filter(Boolean).map((line)=>{
|
|
36
|
+
const idx = line.indexOf(' ');
|
|
37
|
+
const status = line.slice(0, idx);
|
|
38
|
+
let filePath = line.slice(idx + 1).trim();
|
|
39
|
+
if (status.includes('D')) return null;
|
|
40
|
+
if (status.startsWith('R') || status.startsWith('C')) filePath = filePath.split(' -> ')[1];
|
|
41
|
+
return filePath;
|
|
42
|
+
}).filter(Boolean).map((file)=>external_node_path_default.resolve(process.cwd(), file));
|
|
43
|
+
resolve(files);
|
|
44
|
+
} else resolve([]);
|
|
45
|
+
});
|
|
46
|
+
child.on('error', ()=>{
|
|
47
|
+
resolve([]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
runOxlint(args) {
|
|
52
|
+
var _child_stdout, _child_stderr;
|
|
53
|
+
const cwd = process.cwd();
|
|
54
|
+
const child = spawn('npx', [
|
|
55
|
+
'--yes',
|
|
56
|
+
...args
|
|
57
|
+
], {
|
|
58
|
+
cwd,
|
|
59
|
+
stdio: 'pipe',
|
|
60
|
+
shell: true,
|
|
61
|
+
env: {
|
|
62
|
+
...process.env,
|
|
63
|
+
FORCE_COLOR: '1'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
let output = '';
|
|
67
|
+
null == (_child_stdout = child.stdout) || _child_stdout.on('data', (data)=>{
|
|
68
|
+
output += data.toString();
|
|
69
|
+
});
|
|
70
|
+
child.on('exit', (code)=>{
|
|
71
|
+
const hasErrors = !output.includes('Found 0 warnings and 0 errors');
|
|
72
|
+
if (hasErrors || 0 !== code) process.stdout.write(output);
|
|
73
|
+
});
|
|
74
|
+
null == (_child_stderr = child.stderr) || _child_stderr.on('data', (data)=>{
|
|
75
|
+
process.stderr.write(data);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
apply(compiler) {
|
|
79
|
+
compiler.hooks.watchRun.tap('OxlintPlugin', ()=>{
|
|
80
|
+
if (this.timeoutId) clearTimeout(this.timeoutId);
|
|
81
|
+
this.timeoutId = setTimeout(()=>{
|
|
82
|
+
const configPath = external_node_path_default.resolve(plugin_dirname, '.oxlintrc.json');
|
|
83
|
+
this.getGitChangedFiles().then((changedFiles)=>{
|
|
84
|
+
if (changedFiles.length > 0) {
|
|
85
|
+
const args = [
|
|
86
|
+
'oxlint',
|
|
87
|
+
'-c',
|
|
88
|
+
configPath,
|
|
89
|
+
...changedFiles,
|
|
90
|
+
'--fix',
|
|
91
|
+
'--fix-suggestions'
|
|
92
|
+
];
|
|
93
|
+
this.runOxlint(args);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}, this.debounceTime);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
constructor(){
|
|
100
|
+
_define_property(this, "timeoutId", null);
|
|
101
|
+
_define_property(this, "debounceTime", 300);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export { OxlintPlugin };
|