@unpackjs/core 1.7.4 → 1.7.6
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 +178 -178
- package/compiled/less-loader/index.js +11 -11
- package/compiled/line-diff/index.js +4 -4
- package/compiled/portfinder/index.js +37 -37
- package/compiled/postcss-loader/index.js +261 -256
- package/compiled/sass-loader/index.js +18 -18
- 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.d.ts +1 -1
- package/dist/bundler-config/chunkSplit.js +125 -134
- package/dist/bundler-config/css.cjs +181 -158
- package/dist/bundler-config/css.d.ts +1 -1
- package/dist/bundler-config/css.js +139 -151
- package/dist/bundler-config/experimentCss.cjs +203 -159
- package/dist/bundler-config/experimentCss.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +64 -70
- package/dist/constants.cjs +62 -62
- package/dist/constants.js +20 -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/cache.cjs +40 -32
- package/dist/lightningcss/cache.js +10 -20
- package/dist/lightningcss/loader.cjs +56 -53
- package/dist/lightningcss/loader.d.ts +1 -1
- package/dist/lightningcss/loader.js +25 -34
- package/dist/lightningcss/minimizer.cjs +90 -109
- package/dist/lightningcss/minimizer.d.ts +1 -1
- package/dist/lightningcss/minimizer.js +59 -87
- package/dist/logger.cjs +104 -98
- package/dist/logger.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/plugin-progress/rspack.js +59 -57
- package/dist/plugin-progress/webpack.cjs +111 -89
- package/dist/plugin-progress/webpack.d.ts +1 -1
- 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 +135 -120
- package/dist/reporter.js +88 -98
- package/dist/run/build.cjs +68 -67
- package/dist/run/build.d.ts +1 -1
- package/dist/run/build.js +24 -45
- package/dist/run/dev.cjs +96 -83
- package/dist/run/dev.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/typed-css-modules/loader.js +118 -151
- package/dist/typed-css-modules/plugin.cjs +113 -88
- package/dist/typed-css-modules/plugin.d.ts +1 -1
- package/dist/typed-css-modules/plugin.js +68 -66
- package/dist/typed-css-modules/utils.cjs +43 -42
- package/dist/typed-css-modules/utils.d.ts +1 -1
- 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.d.ts +1 -5
- package/dist/types/config.d.ts.map +1 -1
- 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 +14 -17
- package/compiled/commander/index.d.ts +0 -971
- package/compiled/commander/index.js +0 -2190
- 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/prebundleDeps.cjs
CHANGED
|
@@ -1,350 +1,340 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 prebundleDeps_exports = {};
|
|
29
|
-
__export(prebundleDeps_exports, {
|
|
30
|
-
prebundleDeps: () => prebundleDeps
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(prebundleDeps_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_cors = __toESM(require("cors"));
|
|
37
|
-
var import_express = __toESM(require("express"));
|
|
38
|
-
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
39
|
-
var import_tinyglobby = require("tinyglobby");
|
|
40
|
-
var import_colors = __toESM(require("./colors.cjs"));
|
|
41
|
-
var import_constants = require("./constants.cjs");
|
|
42
|
-
var import_logger = require("./logger.cjs");
|
|
43
|
-
var import_utils = require("./utils.cjs");
|
|
44
|
-
const app = (0, import_express.default)();
|
|
45
|
-
app.use((0, import_cors.default)());
|
|
46
|
-
const CACHE_DIR = "umd";
|
|
47
|
-
const externalAlias = {
|
|
48
|
-
react: "React",
|
|
49
|
-
"react-dom": "ReactDOM",
|
|
50
|
-
"react-router": "ReactRouter",
|
|
51
|
-
"react-router-dom": "ReactRouterDOM"
|
|
52
|
-
};
|
|
53
|
-
const count = {
|
|
54
|
-
total: 0,
|
|
55
|
-
bundled: 0
|
|
56
|
-
};
|
|
57
|
-
const failedDeps = [];
|
|
58
|
-
const noEntryDeps = [];
|
|
59
|
-
const updateProgress = () => {
|
|
60
|
-
(0, import_utils.logUpdate)(
|
|
61
|
-
`${import_colors.default.magenta(import_colors.default.bold("»"))} Optimizing dependencies (${count.bundled}/${count.total})`
|
|
62
|
-
);
|
|
63
|
-
if (count.total === count.bundled + failedDeps.length) {
|
|
64
|
-
console.log();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const getExternalLibraryName = (pkgName) => {
|
|
68
|
-
return externalAlias[pkgName] || pkgName;
|
|
69
|
-
};
|
|
70
|
-
const getExternalValue = (pkgName) => {
|
|
71
|
-
return `window ${getExternalLibraryName(pkgName)}`;
|
|
72
|
-
};
|
|
73
|
-
const bundleDep = ({
|
|
74
|
-
root,
|
|
75
|
-
name,
|
|
76
|
-
entry,
|
|
77
|
-
version
|
|
78
|
-
}) => {
|
|
79
|
-
return new Promise((resolve) => {
|
|
80
|
-
const pkgDir = import_node_path.default.resolve(root, import_constants.TEMP_DIR, CACHE_DIR, name);
|
|
81
|
-
const outDir = import_node_path.default.resolve(pkgDir, version);
|
|
82
|
-
const getResult = () => {
|
|
83
|
-
const assets = (0, import_tinyglobby.globSync)("**/index.{js,css}", {
|
|
84
|
-
cwd: outDir,
|
|
85
|
-
absolute: true
|
|
86
|
-
});
|
|
87
|
-
return {
|
|
88
|
-
name,
|
|
89
|
-
assets
|
|
90
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = function(module) {
|
|
5
|
+
var getter = module && module.__esModule ? function() {
|
|
6
|
+
return module['default'];
|
|
7
|
+
} : function() {
|
|
8
|
+
return module;
|
|
9
|
+
};
|
|
10
|
+
__webpack_require__.d(getter, {
|
|
11
|
+
a: getter
|
|
12
|
+
});
|
|
13
|
+
return getter;
|
|
91
14
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const getSwcOptions = ({ tsx }) => {
|
|
100
|
-
return {
|
|
101
|
-
jsc: {
|
|
102
|
-
parser: {
|
|
103
|
-
tsx,
|
|
104
|
-
syntax: "typescript",
|
|
105
|
-
dynamicImport: true,
|
|
106
|
-
decorators: true
|
|
107
|
-
},
|
|
108
|
-
transform: {
|
|
109
|
-
react: {
|
|
110
|
-
runtime: "automatic"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
115
22
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
implementation: (0, import_utils.getUserDepPath)(root, "less")
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
test: /\.s[ac]ss$/i,
|
|
171
|
-
type: "css/auto",
|
|
172
|
-
use: [
|
|
173
|
-
{
|
|
174
|
-
loader: (0, import_utils.getCompiledPkgPath)("sass-loader"),
|
|
175
|
-
options: {
|
|
176
|
-
api: "modern-compiler",
|
|
177
|
-
implementation: (0, import_utils.getUserDepPath)(root, ["sass-embedded", "sass"])
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
}
|
|
182
|
-
]
|
|
183
|
-
},
|
|
184
|
-
optimization: {
|
|
185
|
-
splitChunks: false
|
|
186
|
-
},
|
|
187
|
-
experiments: {
|
|
188
|
-
css: true
|
|
189
|
-
},
|
|
190
|
-
externals: {
|
|
191
|
-
react: getExternalValue("react"),
|
|
192
|
-
"react-dom": getExternalValue("react-dom")
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
compiler.run((_, stats) => {
|
|
196
|
-
let isFailed = false;
|
|
197
|
-
if (stats?.hasErrors()) {
|
|
198
|
-
isFailed = true;
|
|
199
|
-
failedDeps.push(name);
|
|
200
|
-
(0, import_utils.removeDir)(outDir);
|
|
201
|
-
} else {
|
|
202
|
-
count.bundled++;
|
|
203
|
-
}
|
|
204
|
-
updateProgress();
|
|
205
|
-
compiler.close(() => {
|
|
206
|
-
resolve(!isFailed ? getResult() : void 0);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
prebundleDeps: ()=>prebundleDeps
|
|
43
|
+
});
|
|
44
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
45
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
46
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
47
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
48
|
+
const core_namespaceObject = require("@rspack/core");
|
|
49
|
+
const external_cors_namespaceObject = require("cors");
|
|
50
|
+
var external_cors_default = /*#__PURE__*/ __webpack_require__.n(external_cors_namespaceObject);
|
|
51
|
+
const external_express_namespaceObject = require("express");
|
|
52
|
+
var external_express_default = /*#__PURE__*/ __webpack_require__.n(external_express_namespaceObject);
|
|
53
|
+
const external_html_webpack_plugin_namespaceObject = require("html-webpack-plugin");
|
|
54
|
+
var external_html_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(external_html_webpack_plugin_namespaceObject);
|
|
55
|
+
const external_tinyglobby_namespaceObject = require("tinyglobby");
|
|
56
|
+
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
57
|
+
var external_colors_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_colors_cjs_namespaceObject);
|
|
58
|
+
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
59
|
+
const external_global_cjs_namespaceObject = require("./global.cjs");
|
|
60
|
+
const external_logger_cjs_namespaceObject = require("./logger.cjs");
|
|
61
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
62
|
+
const CACHE_DIR = 'umd';
|
|
63
|
+
const getExternalLibraryName = (pkgName)=>{
|
|
64
|
+
const externalAlias = {
|
|
65
|
+
react: 'React',
|
|
66
|
+
'react-dom': 'ReactDOM',
|
|
67
|
+
'react-router': 'ReactRouter',
|
|
68
|
+
'react-router-dom': 'ReactRouterDOM'
|
|
69
|
+
};
|
|
70
|
+
return externalAlias[pkgName] || pkgName;
|
|
210
71
|
};
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
externals.forEach((item)
|
|
215
|
-
|
|
216
|
-
Object.keys(item).forEach((key) => existExternals.add(key));
|
|
217
|
-
}
|
|
72
|
+
const getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`;
|
|
73
|
+
const getExistExternals = (externals)=>{
|
|
74
|
+
const existExternals = new Set();
|
|
75
|
+
if (Array.isArray(externals)) externals.forEach((item)=>{
|
|
76
|
+
if ((0, external_utils_cjs_namespaceObject.isPlainObject)(item)) Object.keys(item).forEach((key)=>existExternals.add(key));
|
|
218
77
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
return Array.from(existExternals);
|
|
78
|
+
else if ((0, external_utils_cjs_namespaceObject.isPlainObject)(externals)) Object.keys(externals).forEach((key)=>existExternals.add(key));
|
|
79
|
+
return Array.from(existExternals);
|
|
223
80
|
};
|
|
224
|
-
const getPkgEntry = (packageJson)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return
|
|
236
|
-
if ((0, import_utils.isString)(defaultExport.browser))
|
|
237
|
-
return defaultExport.browser;
|
|
238
|
-
if ((0, import_utils.isString)(defaultExport.default))
|
|
239
|
-
return defaultExport.default;
|
|
81
|
+
const getPkgEntry = (packageJson)=>{
|
|
82
|
+
if (packageJson.module) return packageJson.module;
|
|
83
|
+
if (packageJson.exports) {
|
|
84
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(packageJson.exports)) return packageJson.exports;
|
|
85
|
+
const defaultExport = packageJson.exports['.'];
|
|
86
|
+
if (defaultExport) {
|
|
87
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(defaultExport)) return defaultExport;
|
|
88
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(defaultExport.import)) return defaultExport.import;
|
|
89
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(defaultExport.browser)) return defaultExport.browser;
|
|
90
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(defaultExport.default)) return defaultExport.default;
|
|
91
|
+
}
|
|
92
|
+
if ((0, external_utils_cjs_namespaceObject.isString)(packageJson.exports.default)) return packageJson.exports.default;
|
|
240
93
|
}
|
|
241
|
-
if (
|
|
242
|
-
return packageJson.exports.default;
|
|
243
|
-
}
|
|
244
|
-
if (packageJson.main)
|
|
245
|
-
return packageJson.main;
|
|
94
|
+
if (packageJson.main) return packageJson.main;
|
|
246
95
|
};
|
|
247
|
-
const prebundleDeps = async ({
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
);
|
|
258
|
-
const needBundleDeps = shouldIncludeDeps.map((pkgName) => {
|
|
259
|
-
const packageJson2 = JSON.parse(
|
|
260
|
-
import_node_fs.default.readFileSync(import_node_path.default.resolve(root, "node_modules", pkgName, "package.json"), "utf-8")
|
|
261
|
-
);
|
|
262
|
-
const entry = getPkgEntry(packageJson2);
|
|
263
|
-
if (!entry) {
|
|
264
|
-
noEntryDeps.push(pkgName);
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
return {
|
|
268
|
-
name: pkgName,
|
|
269
|
-
entry: import_node_path.default.resolve(root, "node_modules", pkgName, entry),
|
|
270
|
-
version: packageJson2.version
|
|
96
|
+
const prebundleDeps = async ({ unpackConfig })=>{
|
|
97
|
+
var _unpackConfig_dev;
|
|
98
|
+
const count = {
|
|
99
|
+
total: 0,
|
|
100
|
+
bundled: 0
|
|
101
|
+
};
|
|
102
|
+
const failedDeps = [];
|
|
103
|
+
const updateProgress = ()=>{
|
|
104
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${external_colors_cjs_default().magenta(external_colors_cjs_default().bold('»'))} Optimizing dependencies (${count.bundled}/${count.total})`);
|
|
105
|
+
if (count.total === count.bundled + failedDeps.length) console.log();
|
|
271
106
|
};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
107
|
+
const { root } = unpackConfig;
|
|
108
|
+
const bundleDep = ({ name, entry, version })=>new Promise((resolve)=>{
|
|
109
|
+
const pkgDir = external_node_path_default().resolve(root, external_constants_cjs_namespaceObject.TEMP_DIR, CACHE_DIR, name);
|
|
110
|
+
const outDir = external_node_path_default().resolve(pkgDir, version);
|
|
111
|
+
const getResult = ()=>{
|
|
112
|
+
const assets = (0, external_tinyglobby_namespaceObject.globSync)('**/index.{js,css}', {
|
|
113
|
+
cwd: outDir,
|
|
114
|
+
absolute: true
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
name,
|
|
118
|
+
assets
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
if (external_node_fs_default().existsSync(outDir)) {
|
|
122
|
+
resolve(getResult());
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
(0, external_utils_cjs_namespaceObject.removeDir)(pkgDir);
|
|
126
|
+
count.total++;
|
|
127
|
+
updateProgress();
|
|
128
|
+
const getSwcOptions = ({ tsx })=>({
|
|
129
|
+
jsc: {
|
|
130
|
+
parser: {
|
|
131
|
+
tsx,
|
|
132
|
+
syntax: "typescript",
|
|
133
|
+
dynamicImport: true,
|
|
134
|
+
decorators: true
|
|
135
|
+
},
|
|
136
|
+
transform: {
|
|
137
|
+
react: {
|
|
138
|
+
runtime: 'automatic'
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const compiler = (0, core_namespaceObject.rspack)({
|
|
144
|
+
entry: {
|
|
145
|
+
index: entry
|
|
146
|
+
},
|
|
147
|
+
context: root,
|
|
148
|
+
mode: 'development',
|
|
149
|
+
output: {
|
|
150
|
+
clean: true,
|
|
151
|
+
path: outDir,
|
|
152
|
+
pathinfo: false,
|
|
153
|
+
library: {
|
|
154
|
+
name: getExternalLibraryName(name),
|
|
155
|
+
type: 'umd',
|
|
156
|
+
umdNamedDefine: true
|
|
157
|
+
},
|
|
158
|
+
globalObject: 'this'
|
|
159
|
+
},
|
|
160
|
+
devtool: false,
|
|
161
|
+
module: {
|
|
162
|
+
rules: [
|
|
163
|
+
{
|
|
164
|
+
test: /\.(j|t)s$/,
|
|
165
|
+
use: [
|
|
166
|
+
{
|
|
167
|
+
loader: 'builtin:swc-loader',
|
|
168
|
+
options: getSwcOptions({
|
|
169
|
+
tsx: false
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
test: /\.(j|t)sx$/,
|
|
176
|
+
use: [
|
|
177
|
+
{
|
|
178
|
+
loader: 'builtin:swc-loader',
|
|
179
|
+
options: getSwcOptions({
|
|
180
|
+
tsx: true
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
test: /\.less$/,
|
|
187
|
+
type: 'css/auto',
|
|
188
|
+
use: [
|
|
189
|
+
{
|
|
190
|
+
loader: (0, external_utils_cjs_namespaceObject.getCompiledPkgPath)('less-loader'),
|
|
191
|
+
options: {
|
|
192
|
+
lessOptions: {
|
|
193
|
+
javascriptEnabled: true
|
|
194
|
+
},
|
|
195
|
+
implementation: (0, external_utils_cjs_namespaceObject.getUserDepPath)(root, 'less')
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
test: /\.s[ac]ss$/i,
|
|
202
|
+
type: 'css/auto',
|
|
203
|
+
use: [
|
|
204
|
+
{
|
|
205
|
+
loader: (0, external_utils_cjs_namespaceObject.getCompiledPkgPath)('sass-loader'),
|
|
206
|
+
options: {
|
|
207
|
+
api: 'modern-compiler',
|
|
208
|
+
implementation: (0, external_utils_cjs_namespaceObject.getUserDepPath)(root, [
|
|
209
|
+
'sass-embedded',
|
|
210
|
+
'sass'
|
|
211
|
+
])
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
optimization: {
|
|
219
|
+
splitChunks: false
|
|
220
|
+
},
|
|
221
|
+
experiments: {
|
|
222
|
+
css: true
|
|
223
|
+
},
|
|
224
|
+
externals: {
|
|
225
|
+
react: getExternalValue('react'),
|
|
226
|
+
'react-dom': getExternalValue('react-dom'),
|
|
227
|
+
'react-router': getExternalValue('react-router'),
|
|
228
|
+
'react-router-dom': getExternalValue('react-router-dom')
|
|
229
|
+
}
|
|
304
230
|
});
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
231
|
+
compiler.run((_, stats)=>{
|
|
232
|
+
let isFailed = false;
|
|
233
|
+
if (null == stats ? void 0 : stats.hasErrors()) {
|
|
234
|
+
isFailed = true;
|
|
235
|
+
failedDeps.push(name);
|
|
236
|
+
(0, external_utils_cjs_namespaceObject.removeDir)(outDir);
|
|
237
|
+
} else count.bundled++;
|
|
238
|
+
updateProgress();
|
|
239
|
+
compiler.close(()=>{
|
|
240
|
+
resolve(isFailed ? void 0 : getResult());
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
const userOptions = (0, external_utils_cjs_namespaceObject.isPlainObject)(null === (_unpackConfig_dev = unpackConfig.dev) || void 0 === _unpackConfig_dev ? void 0 : _unpackConfig_dev.prebundle) ? unpackConfig.dev.prebundle : {};
|
|
245
|
+
const packageJson = JSON.parse(external_node_fs_default().readFileSync(external_node_path_default().resolve(root, 'package.json'), 'utf-8'));
|
|
246
|
+
const existExternals = getExistExternals(unpackConfig.externals);
|
|
247
|
+
const excludeDeps = [
|
|
248
|
+
...existExternals || [],
|
|
249
|
+
...userOptions.exclude || []
|
|
250
|
+
];
|
|
251
|
+
const shouldIncludeDeps = Object.keys(packageJson.dependencies).filter((pkgName)=>!excludeDeps.includes(pkgName));
|
|
252
|
+
const noEntryDeps = [];
|
|
253
|
+
const needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
254
|
+
const packageJson = JSON.parse(external_node_fs_default().readFileSync(external_node_path_default().resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8'));
|
|
255
|
+
const entry = getPkgEntry(packageJson);
|
|
256
|
+
if (!entry) {
|
|
257
|
+
noEntryDeps.push(pkgName);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
name: pkgName,
|
|
262
|
+
entry: external_node_path_default().resolve(root, 'node_modules', pkgName, entry),
|
|
263
|
+
version: packageJson.version
|
|
264
|
+
};
|
|
265
|
+
}).filter(Boolean);
|
|
266
|
+
if (noEntryDeps[0]) external_logger_cjs_namespaceObject.logger.warn(`Could not find entry for "${external_colors_cjs_default().bold(noEntryDeps.join(', '))}"`);
|
|
267
|
+
const bundledDeps = await Promise.all(needBundleDeps.map((depInfo)=>bundleDep(depInfo)));
|
|
268
|
+
if (failedDeps[0]) external_logger_cjs_namespaceObject.logger.warn(`Something went wrong while optimizing "${external_colors_cjs_default().bold(failedDeps.join(', '))}"`);
|
|
269
|
+
const cachePath = external_node_path_default().resolve(root, external_constants_cjs_namespaceObject.TEMP_DIR, CACHE_DIR);
|
|
270
|
+
const app = external_express_default()();
|
|
271
|
+
app.use(external_cors_default()());
|
|
272
|
+
app.use(`/${CACHE_DIR}`, external_express_default().static(cachePath));
|
|
273
|
+
const port = await (0, external_utils_cjs_namespaceObject.getPort)(3200);
|
|
274
|
+
const staticServer = app.listen(port, ()=>{});
|
|
275
|
+
external_global_cjs_namespaceObject.restartCleaners.push(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
276
|
+
const externals = {};
|
|
277
|
+
const jsAssets = [];
|
|
278
|
+
const cssAssets = [];
|
|
279
|
+
const preJsAssets = [];
|
|
280
|
+
const ipv4Interfaces = (0, external_utils_cjs_namespaceObject.getIpv4Interfaces)();
|
|
281
|
+
bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
282
|
+
externals[dep.name] = getExternalValue(dep.name);
|
|
283
|
+
dep.assets.forEach((absPath)=>{
|
|
284
|
+
const relativePath = external_node_path_default().relative(cachePath, absPath);
|
|
285
|
+
const preDeps = [
|
|
286
|
+
'react',
|
|
287
|
+
'react-dom',
|
|
288
|
+
'react-router',
|
|
289
|
+
'react-router-dom'
|
|
290
|
+
];
|
|
291
|
+
const serverPath = `//${ipv4Interfaces[1].address}:${port}/${CACHE_DIR}/${relativePath}`;
|
|
292
|
+
switch(external_node_path_default().extname(relativePath)){
|
|
293
|
+
case '.js':
|
|
294
|
+
if (preDeps.includes(dep.name)) preJsAssets.push({
|
|
295
|
+
path: serverPath,
|
|
296
|
+
order: preDeps.indexOf(dep.name)
|
|
297
|
+
});
|
|
298
|
+
else jsAssets.push(serverPath);
|
|
299
|
+
break;
|
|
300
|
+
case '.css':
|
|
301
|
+
cssAssets.push(serverPath);
|
|
302
|
+
break;
|
|
303
|
+
default:
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
315
307
|
});
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
);
|
|
339
|
-
|
|
308
|
+
unpackConfig.externals = Array.isArray(unpackConfig.externals) ? [
|
|
309
|
+
externals,
|
|
310
|
+
...unpackConfig.externals
|
|
311
|
+
] : {
|
|
312
|
+
...externals,
|
|
313
|
+
...unpackConfig.externals
|
|
314
|
+
};
|
|
315
|
+
const HtmlPlugin = 'rspack' === unpackConfig.bundler ? core_namespaceObject.rspack.HtmlRspackPlugin : external_html_webpack_plugin_default();
|
|
316
|
+
unpackConfig.plugins.push({
|
|
317
|
+
name: 'unpack:prebundle',
|
|
318
|
+
bundlerConfig: (config)=>{
|
|
319
|
+
const PLUGIN_NAME = 'PluginInjectAssets';
|
|
320
|
+
config.plugins.push({
|
|
321
|
+
apply: (compiler)=>{
|
|
322
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
323
|
+
HtmlPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>{
|
|
324
|
+
args.assets.js.unshift(...preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path), ...jsAssets);
|
|
325
|
+
args.assets.css.unshift(...cssAssets);
|
|
326
|
+
return args;
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
return config;
|
|
340
332
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
return unpackConfig;
|
|
333
|
+
});
|
|
334
|
+
return unpackConfig;
|
|
346
335
|
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
336
|
+
var __webpack_export_target__ = exports;
|
|
337
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
338
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
339
|
+
value: true
|
|
350
340
|
});
|