@unpackjs/core 1.7.5 → 1.7.7
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 +180 -178
- package/compiled/less-loader/index.js +11 -11
- package/compiled/line-diff/index.js +4 -4
- package/compiled/line-diff/license +1 -1
- package/compiled/line-diff/package.json +1 -1
- package/compiled/portfinder/index.js +37 -37
- package/compiled/postcss-loader/index.js +261 -256
- package/compiled/sass-loader/index.js +24 -20
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/semver/index.js +188 -170
- package/compiled/semver/package.json +1 -1
- package/compiled/style-loader/index.js +13 -13
- package/compiled/webpack-bundle-analyzer/index.js +198 -198
- package/compiled/webpack-merge/index.js +29 -29
- package/dist/bundler-config/chunkSplit.cjs +169 -156
- package/dist/bundler-config/chunkSplit.js +125 -134
- package/dist/bundler-config/css.cjs +181 -158
- package/dist/bundler-config/css.js +139 -151
- package/dist/bundler-config/experimentCss.cjs +203 -159
- package/dist/bundler-config/experimentCss.js +162 -152
- package/dist/bundler-config/helper.cjs +82 -78
- package/dist/bundler-config/helper.js +36 -55
- package/dist/bundler-config/index.cjs +260 -209
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +209 -182
- package/dist/bundler-config/jsMinify.cjs +114 -95
- package/dist/bundler-config/jsMinify.js +70 -73
- package/dist/colors.cjs +83 -56
- package/dist/colors.js +38 -37
- package/dist/config.cjs +107 -93
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -70
- package/dist/constants.cjs +65 -62
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +22 -38
- package/dist/createUnpack.cjs +111 -104
- package/dist/createUnpack.js +67 -82
- package/dist/global.cjs +36 -0
- package/dist/global.d.ts +2 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +4 -0
- package/dist/index.cjs +174 -51
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -15
- package/dist/lightningcss/loader.cjs +56 -53
- package/dist/lightningcss/loader.d.ts.map +1 -1
- package/dist/lightningcss/loader.js +25 -34
- package/dist/lightningcss/minimizer.cjs +90 -109
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +59 -87
- package/dist/logger.cjs +104 -98
- package/dist/logger.js +59 -76
- package/dist/openBrowser.cjs +104 -81
- package/dist/openBrowser.js +56 -52
- package/dist/plugin-progress/rspack.cjs +104 -79
- package/dist/plugin-progress/rspack.js +59 -57
- package/dist/plugin-progress/webpack.cjs +111 -89
- package/dist/plugin-progress/webpack.js +65 -67
- package/dist/plugin.cjs +38 -29
- package/dist/plugin.js +8 -17
- package/dist/prebundleDeps.cjs +327 -337
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +278 -324
- package/dist/progressBar.cjs +82 -65
- package/dist/progressBar.js +38 -43
- package/dist/reporter.cjs +149 -124
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +102 -102
- package/dist/run/build.cjs +68 -67
- package/dist/run/build.js +24 -45
- package/dist/run/dev.cjs +96 -83
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +50 -61
- package/dist/run/index.cjs +74 -21
- package/dist/run/index.js +2 -9
- package/dist/typed-css-modules/loader.cjs +179 -188
- package/dist/typed-css-modules/loader.js +118 -151
- package/dist/typed-css-modules/plugin.cjs +113 -88
- package/dist/typed-css-modules/plugin.js +68 -66
- package/dist/typed-css-modules/utils.cjs +43 -42
- package/dist/typed-css-modules/utils.js +13 -30
- package/dist/types/chunkSplit.cjs +19 -15
- package/dist/types/chunkSplit.d.ts +2 -10
- package/dist/types/chunkSplit.d.ts.map +1 -1
- package/dist/types/chunkSplit.js +2 -9
- package/dist/types/config.cjs +19 -15
- package/dist/types/config.js +2 -9
- package/dist/types/index.cjs +101 -27
- package/dist/types/index.js +2 -9
- package/dist/types/lightningcss.cjs +19 -15
- package/dist/types/lightningcss.js +2 -9
- package/dist/types/logger.cjs +43 -34
- package/dist/types/logger.js +13 -22
- package/dist/types/plugin.cjs +19 -15
- package/dist/types/plugin.js +2 -9
- package/dist/utils.cjs +280 -304
- package/dist/utils.js +195 -241
- package/dist/watchFiles.cjs +73 -0
- package/dist/watchFiles.d.ts +3 -0
- package/dist/watchFiles.d.ts.map +1 -0
- package/dist/watchFiles.js +27 -0
- package/package.json +18 -21
- package/compiled/commander/index.d.ts +0 -1047
- package/compiled/commander/index.js +0 -2428
- package/compiled/commander/license +0 -22
- package/compiled/commander/package.json +0 -1
- package/dist/bundleRequire.cjs +0 -200
- package/dist/bundleRequire.d.ts +0 -5
- package/dist/bundleRequire.d.ts.map +0 -1
- package/dist/bundleRequire.js +0 -173
- package/dist/lightningcss/cache.cjs +0 -36
- package/dist/lightningcss/cache.d.ts +0 -2
- package/dist/lightningcss/cache.d.ts.map +0 -1
- package/dist/lightningcss/cache.js +0 -22
|
@@ -1,215 +1,266 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var bundler_config_exports = {};
|
|
29
|
-
__export(bundler_config_exports, {
|
|
30
|
-
getBundlerConfig: () => getBundlerConfig
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(bundler_config_exports);
|
|
33
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
34
|
-
var import_node_path = __toESM(require("node:path"));
|
|
35
|
-
var import_core = require("@rspack/core");
|
|
36
|
-
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
37
|
-
var import_utils = require("../utils.cjs");
|
|
38
|
-
var import_json5 = __toESM(require("json5"));
|
|
39
|
-
var import_constants = require("../constants.cjs");
|
|
40
|
-
var import_minimizer = require("../lightningcss/minimizer.cjs");
|
|
41
|
-
var import_logger = require("../logger.cjs");
|
|
42
|
-
var import_plugin = require("../plugin.cjs");
|
|
43
|
-
var import_rspack = require("../plugin-progress/rspack.cjs");
|
|
44
|
-
var import_webpack = require("../plugin-progress/webpack.cjs");
|
|
45
|
-
var import_webpack2 = __toESM(require("webpack"));
|
|
46
|
-
var import_chunkSplit = require("./chunkSplit.cjs");
|
|
47
|
-
var import_css = require("./css.cjs");
|
|
48
|
-
var import_experimentCss = require("./experimentCss.cjs");
|
|
49
|
-
var import_helper = require("./helper.cjs");
|
|
50
|
-
var import_jsMinify = require("./jsMinify.cjs");
|
|
51
|
-
const { TsCheckerRspackPlugin } = require("ts-checker-rspack-plugin");
|
|
52
|
-
const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
53
|
-
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
54
|
-
async function getBundlerConfig(unpackConfig) {
|
|
55
|
-
const isRspack = unpackConfig.bundler === "rspack";
|
|
56
|
-
const HtmlPlugin = isRspack ? import_core.rspack.HtmlRspackPlugin : import_html_webpack_plugin.default;
|
|
57
|
-
const definePlugin = (define) => isRspack ? new import_core.rspack.DefinePlugin(define) : new import_webpack2.default.DefinePlugin(define);
|
|
58
|
-
const JS_FILENAME = (0, import_helper.getOutputFilename)({ type: "js", hash: unpackConfig.build?.filenameHash });
|
|
59
|
-
const IgnorePlugin = isRspack ? import_core.rspack.IgnorePlugin : import_webpack2.default.IgnorePlugin;
|
|
60
|
-
const CopyPlugin = isRspack ? import_core.rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
61
|
-
const tsconfigPath = import_node_path.default.resolve(unpackConfig.root, "tsconfig.json");
|
|
62
|
-
const isTs = import_node_fs.default.existsSync(tsconfigPath);
|
|
63
|
-
const getAliasFromTsconfig = () => {
|
|
64
|
-
const paths = import_json5.default.parse(import_node_fs.default.readFileSync(tsconfigPath, "utf-8"))?.compilerOptions?.paths;
|
|
65
|
-
return paths ? Object.keys(paths).reduce((acc, key) => {
|
|
66
|
-
acc[key.replace(/\/\*$/, "")] = import_node_path.default.resolve(
|
|
67
|
-
unpackConfig.root,
|
|
68
|
-
paths[key][0].replace(/\/\*$/, "")
|
|
69
|
-
);
|
|
70
|
-
return acc;
|
|
71
|
-
}, {}) : {};
|
|
72
|
-
};
|
|
73
|
-
const minifyOptions = (0, import_utils.isPlainObject)(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {};
|
|
74
|
-
const PluginProgress = isRspack ? import_rspack.RspackPluginProgress : import_webpack.WebpackPluginProgress;
|
|
75
|
-
let config = {
|
|
76
|
-
context: unpackConfig.root,
|
|
77
|
-
mode: (0, import_utils.isDev)() ? "development" : "production",
|
|
78
|
-
entry: !unpackConfig.mpa ? {
|
|
79
|
-
main: await (0, import_helper.getEntry)(unpackConfig.root, unpackConfig.entry)
|
|
80
|
-
} : {},
|
|
81
|
-
stats: "errors-only",
|
|
82
|
-
output: {
|
|
83
|
-
clean: true,
|
|
84
|
-
path: import_node_path.default.resolve(unpackConfig.root, unpackConfig.build?.outDir),
|
|
85
|
-
filename: JS_FILENAME,
|
|
86
|
-
chunkFilename: JS_FILENAME,
|
|
87
|
-
crossOriginLoading: "anonymous",
|
|
88
|
-
pathinfo: false,
|
|
89
|
-
publicPath: unpackConfig.build?.publicPath
|
|
90
|
-
},
|
|
91
|
-
infrastructureLogging: {
|
|
92
|
-
level: "warn"
|
|
93
|
-
},
|
|
94
|
-
devtool: unpackConfig.build?.sourceMap,
|
|
95
|
-
module: {
|
|
96
|
-
rules: [
|
|
97
|
-
{
|
|
98
|
-
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
99
|
-
type: "asset/resource"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
103
|
-
type: "asset/resource"
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
plugins: [
|
|
108
|
-
unpackConfig.define && definePlugin(unpackConfig.define),
|
|
109
|
-
!unpackConfig.mpa && new HtmlPlugin({
|
|
110
|
-
template: unpackConfig.html?.template || (isRspack ? void 0 : ""),
|
|
111
|
-
// @ts-expect-error
|
|
112
|
-
templateContent: unpackConfig.html?.templateContent || (!unpackConfig.html?.template ? import_constants.TEMPLATE_CONTENT : isRspack ? void 0 : false),
|
|
113
|
-
templateParameters: {
|
|
114
|
-
mountId: unpackConfig.html?.mountId,
|
|
115
|
-
title: (0, import_utils.isFunction)(unpackConfig.html?.title) ? unpackConfig.html?.title({ entryName: "index" }) : unpackConfig.html?.title || "",
|
|
116
|
-
headTag: unpackConfig.html?.headTag || "",
|
|
117
|
-
...unpackConfig.html?.templateParameters
|
|
118
|
-
},
|
|
119
|
-
minify: false,
|
|
120
|
-
chunks: ["main"]
|
|
121
|
-
}),
|
|
122
|
-
unpackConfig.performance?.bundleAnalyze && (0, import_utils.isProd)() && new BundleAnalyzerPlugin(),
|
|
123
|
-
unpackConfig.performance?.removeMomentLocale && new IgnorePlugin({
|
|
124
|
-
resourceRegExp: /^\.\/locale$/,
|
|
125
|
-
contextRegExp: /moment$/
|
|
126
|
-
}),
|
|
127
|
-
unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
|
|
128
|
-
unpackConfig.build?.typeCheck && (0, import_utils.isDev)() && isTs && new TsCheckerRspackPlugin({
|
|
129
|
-
typescript: {
|
|
130
|
-
// set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
|
|
131
|
-
mode: "readonly",
|
|
132
|
-
// avoid OOM issue
|
|
133
|
-
memoryLimit: 8192,
|
|
134
|
-
// use tsconfig of user project
|
|
135
|
-
configFile: tsconfigPath,
|
|
136
|
-
// use typescript of user project
|
|
137
|
-
typescriptPath: require.resolve("typescript", {
|
|
138
|
-
paths: [unpackConfig.root]
|
|
139
|
-
})
|
|
140
|
-
},
|
|
141
|
-
issue: {
|
|
142
|
-
// ignore types errors from node_modules
|
|
143
|
-
exclude: [({ file = "" }) => import_constants.NODE_MODULES_REGEX.test(file)]
|
|
144
|
-
},
|
|
145
|
-
logger: {
|
|
146
|
-
log(message) {
|
|
147
|
-
if (message.includes("Found")) {
|
|
148
|
-
console.log(message.split(" in ")[0]);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
error(message) {
|
|
152
|
-
console.log(message.replace(/ERROR/g, "Type Error"));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}),
|
|
156
|
-
new PluginProgress()
|
|
157
|
-
].filter(Boolean),
|
|
158
|
-
externals: unpackConfig.externals,
|
|
159
|
-
resolve: {
|
|
160
|
-
alias: {
|
|
161
|
-
"@": import_node_path.default.resolve(unpackConfig.root, "src"),
|
|
162
|
-
...isTs ? getAliasFromTsconfig() : {},
|
|
163
|
-
...unpackConfig.resolve?.alias
|
|
164
|
-
},
|
|
165
|
-
extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
|
|
166
|
-
},
|
|
167
|
-
experiments: {
|
|
168
|
-
lazyCompilation: unpackConfig.dev?.lazyCompilation && (0, import_utils.isDevServer)(),
|
|
169
|
-
css: false,
|
|
170
|
-
...isRspack && (0, import_utils.isDev)() ? { incremental: true } : {}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"compiled/webpack-bundle-analyzer/index.js": function(module) {
|
|
4
|
+
module.exports = require("/home/runner/work/unpack/unpack/packages/core/compiled/webpack-bundle-analyzer/index.js");
|
|
171
5
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
minimize: Boolean(unpackConfig.build?.minify),
|
|
175
|
-
minimizer: [
|
|
176
|
-
new import_jsMinify.JsMinifyPlugin({
|
|
177
|
-
target: import_constants.ESBUILD_TARGET
|
|
178
|
-
}),
|
|
179
|
-
new import_minimizer.LightningcssMinifyPlugin(minifyOptions.lightningcss)
|
|
180
|
-
]
|
|
6
|
+
"copy-webpack-plugin": function(module) {
|
|
7
|
+
module.exports = require("copy-webpack-plugin");
|
|
181
8
|
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
type: "filesystem"
|
|
185
|
-
} : void 0,
|
|
186
|
-
watchOptions: {
|
|
187
|
-
ignored: /[\\/](?:\.git|node_modules)[\\/]/
|
|
9
|
+
"ts-checker-rspack-plugin": function(module) {
|
|
10
|
+
module.exports = require("ts-checker-rspack-plugin");
|
|
188
11
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
12
|
+
};
|
|
13
|
+
var __webpack_module_cache__ = {};
|
|
14
|
+
function __webpack_require__(moduleId) {
|
|
15
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
16
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
17
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
18
|
+
exports: {}
|
|
19
|
+
};
|
|
20
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
21
|
+
return module.exports;
|
|
22
|
+
}
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.n = function(module) {
|
|
25
|
+
var getter = module && module.__esModule ? function() {
|
|
26
|
+
return module['default'];
|
|
27
|
+
} : function() {
|
|
28
|
+
return module;
|
|
29
|
+
};
|
|
30
|
+
__webpack_require__.d(getter, {
|
|
31
|
+
a: getter
|
|
32
|
+
});
|
|
33
|
+
return getter;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
(()=>{
|
|
37
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
38
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: definition[key]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
(()=>{
|
|
45
|
+
__webpack_require__.o = function(obj, prop) {
|
|
46
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
(()=>{
|
|
50
|
+
__webpack_require__.r = function(exports1) {
|
|
51
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
52
|
+
value: 'Module'
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
55
|
+
value: true
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
var __webpack_exports__ = {};
|
|
60
|
+
(()=>{
|
|
61
|
+
__webpack_require__.r(__webpack_exports__);
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
63
|
+
getBundlerConfig: ()=>getBundlerConfig
|
|
199
64
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
65
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
66
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
67
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
68
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
69
|
+
const core_namespaceObject = require("@rspack/core");
|
|
70
|
+
const external_html_webpack_plugin_namespaceObject = require("html-webpack-plugin");
|
|
71
|
+
var external_html_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_html_webpack_plugin_namespaceObject);
|
|
72
|
+
const external_utils_cjs_namespaceObject = require("../utils.cjs");
|
|
73
|
+
const external_json5_namespaceObject = require("json5");
|
|
74
|
+
var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
|
|
75
|
+
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
76
|
+
const minimizer_cjs_namespaceObject = require("../lightningcss/minimizer.cjs");
|
|
77
|
+
const external_plugin_cjs_namespaceObject = require("../plugin.cjs");
|
|
78
|
+
const rspack_cjs_namespaceObject = require("../plugin-progress/rspack.cjs");
|
|
79
|
+
const webpack_cjs_namespaceObject = require("../plugin-progress/webpack.cjs");
|
|
80
|
+
const external_webpack_namespaceObject = require("webpack");
|
|
81
|
+
var external_webpack_default = /*#__PURE__*/ __webpack_require__.n(external_webpack_namespaceObject);
|
|
82
|
+
const external_chunkSplit_cjs_namespaceObject = require("./chunkSplit.cjs");
|
|
83
|
+
const external_css_cjs_namespaceObject = require("./css.cjs");
|
|
84
|
+
const external_experimentCss_cjs_namespaceObject = require("./experimentCss.cjs");
|
|
85
|
+
const external_helper_cjs_namespaceObject = require("./helper.cjs");
|
|
86
|
+
const external_jsMinify_cjs_namespaceObject = require("./jsMinify.cjs");
|
|
87
|
+
const { TsCheckerRspackPlugin } = __webpack_require__("ts-checker-rspack-plugin");
|
|
88
|
+
const BundleAnalyzerPlugin = __webpack_require__("compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
89
|
+
const CopyWebpackPlugin = __webpack_require__("copy-webpack-plugin");
|
|
90
|
+
async function getBundlerConfig(unpackConfig) {
|
|
91
|
+
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, _unpackConfig_build9, _unpackConfig_experiments;
|
|
92
|
+
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
93
|
+
const HtmlPlugin = isRspack ? core_namespaceObject.rspack.HtmlRspackPlugin : external_html_webpack_plugin_default();
|
|
94
|
+
const definePlugin = (define)=>isRspack ? new core_namespaceObject.rspack.DefinePlugin(define) : new (external_webpack_default()).DefinePlugin(define);
|
|
95
|
+
const JS_FILENAME = (0, external_helper_cjs_namespaceObject.getOutputFilename)({
|
|
96
|
+
type: 'js',
|
|
97
|
+
hash: null === (_unpackConfig_build = unpackConfig.build) || void 0 === _unpackConfig_build ? void 0 : _unpackConfig_build.filenameHash
|
|
98
|
+
});
|
|
99
|
+
const IgnorePlugin = isRspack ? core_namespaceObject.rspack.IgnorePlugin : external_webpack_default().IgnorePlugin;
|
|
100
|
+
const CopyPlugin = isRspack ? core_namespaceObject.rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
101
|
+
const tsconfigPath = external_node_path_default().resolve(unpackConfig.root, 'tsconfig.json');
|
|
102
|
+
const isTs = external_node_fs_default().existsSync(tsconfigPath);
|
|
103
|
+
const getAliasFromTsconfig = ()=>{
|
|
104
|
+
var _json5_parse_compilerOptions, _json5_parse;
|
|
105
|
+
const paths = null === (_json5_parse = external_json5_default().parse(external_node_fs_default().readFileSync(tsconfigPath, 'utf-8'))) || void 0 === _json5_parse ? void 0 : null === (_json5_parse_compilerOptions = _json5_parse.compilerOptions) || void 0 === _json5_parse_compilerOptions ? void 0 : _json5_parse_compilerOptions.paths;
|
|
106
|
+
return paths ? Object.keys(paths).reduce((acc, key)=>{
|
|
107
|
+
acc[key.replace(/\/\*$/, '')] = external_node_path_default().resolve(unpackConfig.root, paths[key][0].replace(/\/\*$/, ''));
|
|
108
|
+
return acc;
|
|
109
|
+
}, {}) : {};
|
|
110
|
+
};
|
|
111
|
+
const minifyOptions = (0, external_utils_cjs_namespaceObject.isPlainObject)(null === (_unpackConfig_build1 = unpackConfig.build) || void 0 === _unpackConfig_build1 ? void 0 : _unpackConfig_build1.minify) ? null === (_unpackConfig_build2 = unpackConfig.build) || void 0 === _unpackConfig_build2 ? void 0 : _unpackConfig_build2.minify : {};
|
|
112
|
+
const PluginProgress = isRspack ? rspack_cjs_namespaceObject.RspackPluginProgress : webpack_cjs_namespaceObject.WebpackPluginProgress;
|
|
113
|
+
let config = {
|
|
114
|
+
context: unpackConfig.root,
|
|
115
|
+
mode: (0, external_utils_cjs_namespaceObject.isDev)() ? 'development' : 'production',
|
|
116
|
+
entry: unpackConfig.mpa ? {} : {
|
|
117
|
+
main: await (0, external_helper_cjs_namespaceObject.getEntry)(unpackConfig.root, unpackConfig.entry)
|
|
118
|
+
},
|
|
119
|
+
stats: 'errors-only',
|
|
120
|
+
output: {
|
|
121
|
+
clean: true,
|
|
122
|
+
path: external_node_path_default().resolve(unpackConfig.root, null === (_unpackConfig_build3 = unpackConfig.build) || void 0 === _unpackConfig_build3 ? void 0 : _unpackConfig_build3.outDir),
|
|
123
|
+
filename: JS_FILENAME,
|
|
124
|
+
chunkFilename: JS_FILENAME,
|
|
125
|
+
crossOriginLoading: 'anonymous',
|
|
126
|
+
pathinfo: false,
|
|
127
|
+
publicPath: null === (_unpackConfig_build4 = unpackConfig.build) || void 0 === _unpackConfig_build4 ? void 0 : _unpackConfig_build4.publicPath
|
|
128
|
+
},
|
|
129
|
+
infrastructureLogging: {
|
|
130
|
+
level: 'warn'
|
|
131
|
+
},
|
|
132
|
+
devtool: null === (_unpackConfig_build5 = unpackConfig.build) || void 0 === _unpackConfig_build5 ? void 0 : _unpackConfig_build5.sourceMap,
|
|
133
|
+
module: {
|
|
134
|
+
rules: [
|
|
135
|
+
{
|
|
136
|
+
test: /\.(png|svg|jpg|jpeg|gif)$/i,
|
|
137
|
+
type: 'asset/resource'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/i,
|
|
141
|
+
type: 'asset/resource'
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
plugins: [
|
|
146
|
+
unpackConfig.define && definePlugin(unpackConfig.define),
|
|
147
|
+
!unpackConfig.mpa && new HtmlPlugin({
|
|
148
|
+
template: (null === (_unpackConfig_html = unpackConfig.html) || void 0 === _unpackConfig_html ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
149
|
+
templateContent: (null === (_unpackConfig_html1 = unpackConfig.html) || void 0 === _unpackConfig_html1 ? void 0 : _unpackConfig_html1.templateContent) || ((null === (_unpackConfig_html2 = unpackConfig.html) || void 0 === _unpackConfig_html2 ? void 0 : _unpackConfig_html2.template) ? isRspack ? void 0 : false : external_constants_cjs_namespaceObject.TEMPLATE_CONTENT),
|
|
150
|
+
templateParameters: {
|
|
151
|
+
mountId: null === (_unpackConfig_html3 = unpackConfig.html) || void 0 === _unpackConfig_html3 ? void 0 : _unpackConfig_html3.mountId,
|
|
152
|
+
title: (0, external_utils_cjs_namespaceObject.isFunction)(null === (_unpackConfig_html4 = unpackConfig.html) || void 0 === _unpackConfig_html4 ? void 0 : _unpackConfig_html4.title) ? null === (_unpackConfig_html5 = unpackConfig.html) || void 0 === _unpackConfig_html5 ? void 0 : _unpackConfig_html5.title({
|
|
153
|
+
entryName: 'index'
|
|
154
|
+
}) : (null === (_unpackConfig_html6 = unpackConfig.html) || void 0 === _unpackConfig_html6 ? void 0 : _unpackConfig_html6.title) || '',
|
|
155
|
+
headTag: (null === (_unpackConfig_html7 = unpackConfig.html) || void 0 === _unpackConfig_html7 ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
156
|
+
...null === (_unpackConfig_html8 = unpackConfig.html) || void 0 === _unpackConfig_html8 ? void 0 : _unpackConfig_html8.templateParameters
|
|
157
|
+
},
|
|
158
|
+
minify: false,
|
|
159
|
+
chunks: [
|
|
160
|
+
'main'
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
(null === (_unpackConfig_performance = unpackConfig.performance) || void 0 === _unpackConfig_performance ? void 0 : _unpackConfig_performance.bundleAnalyze) && (0, external_utils_cjs_namespaceObject.isProd)() && new BundleAnalyzerPlugin(),
|
|
164
|
+
(null === (_unpackConfig_performance1 = unpackConfig.performance) || void 0 === _unpackConfig_performance1 ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new IgnorePlugin({
|
|
165
|
+
resourceRegExp: /^\.\/locale$/,
|
|
166
|
+
contextRegExp: /moment$/
|
|
167
|
+
}),
|
|
168
|
+
(null === (_unpackConfig_build6 = unpackConfig.build) || void 0 === _unpackConfig_build6 ? void 0 : _unpackConfig_build6.copy) && new CopyPlugin({
|
|
169
|
+
patterns: unpackConfig.build.copy
|
|
170
|
+
}),
|
|
171
|
+
(null === (_unpackConfig_build7 = unpackConfig.build) || void 0 === _unpackConfig_build7 ? void 0 : _unpackConfig_build7.typeCheck) && (0, external_utils_cjs_namespaceObject.isDev)() && isTs && new TsCheckerRspackPlugin({
|
|
172
|
+
typescript: {
|
|
173
|
+
mode: 'readonly',
|
|
174
|
+
memoryLimit: 8192,
|
|
175
|
+
configFile: tsconfigPath,
|
|
176
|
+
typescriptPath: require.resolve("typescript", {
|
|
177
|
+
paths: [
|
|
178
|
+
unpackConfig.root
|
|
179
|
+
]
|
|
180
|
+
})
|
|
181
|
+
},
|
|
182
|
+
issue: {
|
|
183
|
+
exclude: [
|
|
184
|
+
({ file = '' })=>external_constants_cjs_namespaceObject.NODE_MODULES_REGEX.test(file)
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
logger: {
|
|
188
|
+
log (message) {
|
|
189
|
+
if (message.includes('Found')) console.log(message.split(' in ')[0]);
|
|
190
|
+
},
|
|
191
|
+
error (message) {
|
|
192
|
+
console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
new PluginProgress()
|
|
197
|
+
].filter(Boolean),
|
|
198
|
+
externals: unpackConfig.externals,
|
|
199
|
+
resolve: {
|
|
200
|
+
alias: {
|
|
201
|
+
'@': external_node_path_default().resolve(unpackConfig.root, 'src'),
|
|
202
|
+
...isTs ? getAliasFromTsconfig() : {},
|
|
203
|
+
...null === (_unpackConfig_resolve = unpackConfig.resolve) || void 0 === _unpackConfig_resolve ? void 0 : _unpackConfig_resolve.alias
|
|
204
|
+
},
|
|
205
|
+
extensions: [
|
|
206
|
+
'.tsx',
|
|
207
|
+
'.ts',
|
|
208
|
+
'.jsx',
|
|
209
|
+
'.js',
|
|
210
|
+
...(null === (_unpackConfig_resolve1 = unpackConfig.resolve) || void 0 === _unpackConfig_resolve1 ? void 0 : _unpackConfig_resolve1.extensions) || []
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
experiments: {
|
|
214
|
+
lazyCompilation: (null === (_unpackConfig_dev = unpackConfig.dev) || void 0 === _unpackConfig_dev ? void 0 : _unpackConfig_dev.lazyCompilation) && (0, external_utils_cjs_namespaceObject.isDevServer)(),
|
|
215
|
+
css: false,
|
|
216
|
+
...isRspack && (0, external_utils_cjs_namespaceObject.isDev)() ? {
|
|
217
|
+
incremental: true
|
|
218
|
+
} : {},
|
|
219
|
+
...isRspack ? {
|
|
220
|
+
parallelCodeSplitting: true
|
|
221
|
+
} : {}
|
|
222
|
+
},
|
|
223
|
+
optimization: {
|
|
224
|
+
moduleIds: (0, external_utils_cjs_namespaceObject.isDev)() ? 'named' : 'deterministic',
|
|
225
|
+
minimize: Boolean(null === (_unpackConfig_build8 = unpackConfig.build) || void 0 === _unpackConfig_build8 ? void 0 : _unpackConfig_build8.minify),
|
|
226
|
+
minimizer: [
|
|
227
|
+
new external_jsMinify_cjs_namespaceObject.JsMinifyPlugin({
|
|
228
|
+
target: external_constants_cjs_namespaceObject.ESBUILD_TARGET
|
|
229
|
+
}),
|
|
230
|
+
new minimizer_cjs_namespaceObject.LightningcssMinifyPlugin(minifyOptions.lightningcss)
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
cache: (null === (_unpackConfig_build9 = unpackConfig.build) || void 0 === _unpackConfig_build9 ? void 0 : _unpackConfig_build9.cache) && 'webpack' === unpackConfig.bundler ? {
|
|
234
|
+
type: 'filesystem'
|
|
235
|
+
} : void 0,
|
|
236
|
+
watchOptions: {
|
|
237
|
+
ignored: /[\\/](?:\.git|node_modules)[\\/]/
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
config = (null === (_unpackConfig_experiments = unpackConfig.experiments) || void 0 === _unpackConfig_experiments ? void 0 : _unpackConfig_experiments.css) ? (0, external_experimentCss_cjs_namespaceObject.applyExperimentCssConfig)({
|
|
241
|
+
config,
|
|
242
|
+
unpackConfig
|
|
243
|
+
}) : (0, external_css_cjs_namespaceObject.applyCssConfig)({
|
|
244
|
+
config,
|
|
245
|
+
unpackConfig
|
|
246
|
+
});
|
|
247
|
+
config = (0, external_chunkSplit_cjs_namespaceObject.applyChunkSplitConfig)({
|
|
248
|
+
config,
|
|
249
|
+
unpackConfig
|
|
250
|
+
});
|
|
251
|
+
for (const plugin of (0, external_plugin_cjs_namespaceObject.getNormalizedPluginsByHook)('bundlerConfig', unpackConfig.plugins))config = await plugin.bundlerConfig(config, {
|
|
252
|
+
unpackConfig,
|
|
253
|
+
mergeConfig: external_utils_cjs_namespaceObject.mergeConfig,
|
|
254
|
+
bundler: isRspack ? core_namespaceObject.rspack : external_webpack_default()
|
|
255
|
+
});
|
|
256
|
+
if (unpackConfig.bundlerConfig) config = (0, external_utils_cjs_namespaceObject.isFunction)(unpackConfig.bundlerConfig) ? await unpackConfig.bundlerConfig(config, {
|
|
257
|
+
mergeConfig: external_utils_cjs_namespaceObject.mergeConfig
|
|
258
|
+
}) : (0, external_utils_cjs_namespaceObject.mergeConfig)(config, unpackConfig.bundlerConfig);
|
|
259
|
+
return config;
|
|
208
260
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
getBundlerConfig
|
|
261
|
+
})();
|
|
262
|
+
var __webpack_export_target__ = exports;
|
|
263
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
264
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
265
|
+
value: true
|
|
215
266
|
});
|
|
@@ -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;AAmBzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+KhG"}
|