@unpackjs/core 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/css-loader/index.js +49 -49
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +37 -37
- package/compiled/sass-loader/index.js +8 -8
- package/dist/bundler-config/cache.cjs +16 -8
- package/dist/bundler-config/cache.d.ts +2 -1
- package/dist/bundler-config/cache.d.ts.map +1 -1
- package/dist/bundler-config/cache.js +23 -15
- package/dist/bundler-config/chunkSplit.d.ts.map +1 -1
- package/dist/bundler-config/chunkSplit.js +3 -3
- package/dist/bundler-config/css.cjs +13 -15
- package/dist/bundler-config/css.js +19 -21
- package/dist/bundler-config/experimentCss.cjs +12 -11
- package/dist/bundler-config/experimentCss.js +15 -14
- package/dist/bundler-config/helpers.d.ts.map +1 -1
- package/dist/bundler-config/helpers.js +6 -6
- package/dist/bundler-config/index.cjs +40 -13
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +56 -29
- package/dist/bundler-config/jsMinify.cjs +8 -10
- package/dist/bundler-config/jsMinify.d.ts +1 -1
- package/dist/bundler-config/jsMinify.d.ts.map +1 -1
- package/dist/bundler-config/jsMinify.js +11 -13
- package/dist/bundler-config/oxlint/.oxlintrc.json +0 -1
- package/dist/bundler-config/oxlint/plugin.cjs +1 -1
- package/dist/bundler-config/oxlint/plugin.js +5 -5
- package/dist/bundler-config/progress/helpers.cjs +16 -2
- package/dist/bundler-config/progress/helpers.d.ts.map +1 -1
- package/dist/bundler-config/progress/helpers.js +18 -4
- package/dist/bundler-config/progress/rspack.cjs +1 -1
- package/dist/bundler-config/progress/rspack.js +2 -2
- package/dist/bundler-config/progress/webpack.cjs +2 -2
- package/dist/bundler-config/progress/webpack.js +5 -5
- package/dist/colors.js +3 -3
- package/dist/config.cjs +6 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -6
- package/dist/constants.cjs +16 -12
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -9
- package/dist/createUnpack.cjs +25 -23
- package/dist/createUnpack.d.ts +9 -4
- package/dist/createUnpack.d.ts.map +1 -1
- package/dist/createUnpack.js +27 -25
- package/dist/fs.cjs +10 -1
- package/dist/fs.d.ts +1 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +13 -7
- package/dist/global.js +1 -1
- package/dist/index.cjs +63 -50
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/lightningcss/loader.js +1 -1
- package/dist/lightningcss/minimizer.cjs +7 -8
- package/dist/lightningcss/minimizer.d.ts +2 -2
- package/dist/lightningcss/minimizer.d.ts.map +1 -1
- package/dist/lightningcss/minimizer.js +8 -9
- package/dist/loadEnv.cjs +122 -0
- package/dist/loadEnv.d.ts +64 -0
- package/dist/loadEnv.d.ts.map +1 -0
- package/dist/loadEnv.js +80 -0
- package/dist/loadingAnimation.cjs +76 -0
- package/dist/loadingAnimation.d.ts +9 -0
- package/dist/loadingAnimation.d.ts.map +1 -0
- package/dist/loadingAnimation.js +44 -0
- package/dist/logger.cjs +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +5 -5
- package/dist/openBrowser.d.ts.map +1 -1
- package/dist/openBrowser.js +3 -3
- package/dist/plugin.js +1 -1
- package/dist/prebundleDeps.cjs +27 -6
- package/dist/prebundleDeps.d.ts.map +1 -1
- package/dist/prebundleDeps.js +46 -25
- package/dist/progressBar.cjs +5 -2
- package/dist/progressBar.d.ts +2 -0
- package/dist/progressBar.d.ts.map +1 -1
- package/dist/progressBar.js +6 -3
- package/dist/reporter.cjs +4 -2
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +14 -12
- package/dist/run/build.cjs +4 -4
- package/dist/run/build.d.ts +1 -1
- package/dist/run/build.d.ts.map +1 -1
- package/dist/run/build.js +5 -5
- package/dist/run/dev.cjs +21 -13
- package/dist/run/dev.d.ts +1 -1
- package/dist/run/dev.d.ts.map +1 -1
- package/dist/run/dev.js +25 -17
- package/dist/run/index.js +1 -1
- package/dist/typed-css-modules/loader.cjs +2 -2
- package/dist/typed-css-modules/loader.d.ts.map +1 -1
- package/dist/typed-css-modules/loader.js +10 -10
- package/dist/typed-css-modules/plugin.js +5 -5
- package/dist/typed-css-modules/utils.d.ts.map +1 -1
- package/dist/typed-css-modules/utils.js +1 -1
- package/dist/types/chunkSplit.js +1 -1
- package/dist/types/config.d.ts +30 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -1
- package/dist/types/index.cjs +15 -15
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -3
- package/dist/types/lightningcss.d.ts +2 -2
- package/dist/types/lightningcss.d.ts.map +1 -1
- package/dist/types/lightningcss.js +1 -1
- package/dist/types/logger.js +1 -1
- package/dist/types/oxc.js +1 -1
- package/dist/types/plugin.d.ts +2 -2
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/plugin.js +1 -1
- package/dist/utils.cjs +3 -12
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -20
- package/dist/watchFiles.cjs +1 -1
- package/dist/watchFiles.d.ts +1 -1
- package/dist/watchFiles.d.ts.map +1 -1
- package/dist/watchFiles.js +4 -4
- package/package.json +5 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
LoadingAnimation: ()=>LoadingAnimation
|
|
28
|
+
});
|
|
29
|
+
function _define_property(obj, key, value) {
|
|
30
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
31
|
+
value: value,
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true
|
|
35
|
+
});
|
|
36
|
+
else obj[key] = value;
|
|
37
|
+
return obj;
|
|
38
|
+
}
|
|
39
|
+
class LoadingAnimation {
|
|
40
|
+
getCurrentChar() {
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
if (now - this.lastUpdateTime >= this.interval) {
|
|
43
|
+
this.currentIndex = (this.currentIndex + 1) % this.chars.length;
|
|
44
|
+
this.lastUpdateTime = now;
|
|
45
|
+
}
|
|
46
|
+
return this.chars[this.currentIndex];
|
|
47
|
+
}
|
|
48
|
+
reset() {
|
|
49
|
+
this.currentIndex = 0;
|
|
50
|
+
this.lastUpdateTime = 0;
|
|
51
|
+
}
|
|
52
|
+
constructor(){
|
|
53
|
+
_define_property(this, "chars", [
|
|
54
|
+
"\u280B",
|
|
55
|
+
"\u2819",
|
|
56
|
+
"\u2839",
|
|
57
|
+
"\u2838",
|
|
58
|
+
"\u283C",
|
|
59
|
+
"\u2834",
|
|
60
|
+
"\u2826",
|
|
61
|
+
"\u2827",
|
|
62
|
+
"\u2807",
|
|
63
|
+
"\u280F"
|
|
64
|
+
]);
|
|
65
|
+
_define_property(this, "currentIndex", 0);
|
|
66
|
+
_define_property(this, "lastUpdateTime", 0);
|
|
67
|
+
_define_property(this, "interval", 150);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.LoadingAnimation = __webpack_exports__.LoadingAnimation;
|
|
71
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
72
|
+
"LoadingAnimation"
|
|
73
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
74
|
+
Object.defineProperty(exports, '__esModule', {
|
|
75
|
+
value: true
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadingAnimation.d.ts","sourceRoot":"","sources":["../src/loadingAnimation.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAA+D;IAC5E,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,QAAQ,CAAM;IAEtB,cAAc,IAAI,MAAM;IASxB,KAAK,IAAI,IAAI;CAId"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
|
+
value: value,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
else obj[key] = value;
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
class LoadingAnimation {
|
|
14
|
+
getCurrentChar() {
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
if (now - this.lastUpdateTime >= this.interval) {
|
|
17
|
+
this.currentIndex = (this.currentIndex + 1) % this.chars.length;
|
|
18
|
+
this.lastUpdateTime = now;
|
|
19
|
+
}
|
|
20
|
+
return this.chars[this.currentIndex];
|
|
21
|
+
}
|
|
22
|
+
reset() {
|
|
23
|
+
this.currentIndex = 0;
|
|
24
|
+
this.lastUpdateTime = 0;
|
|
25
|
+
}
|
|
26
|
+
constructor(){
|
|
27
|
+
_define_property(this, "chars", [
|
|
28
|
+
"\u280B",
|
|
29
|
+
"\u2819",
|
|
30
|
+
"\u2839",
|
|
31
|
+
"\u2838",
|
|
32
|
+
"\u283C",
|
|
33
|
+
"\u2834",
|
|
34
|
+
"\u2826",
|
|
35
|
+
"\u2827",
|
|
36
|
+
"\u2807",
|
|
37
|
+
"\u280F"
|
|
38
|
+
]);
|
|
39
|
+
_define_property(this, "currentIndex", 0);
|
|
40
|
+
_define_property(this, "lastUpdateTime", 0);
|
|
41
|
+
_define_property(this, "interval", 150);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export { LoadingAnimation };
|
package/dist/logger.cjs
CHANGED
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,MAAM,EAAgB,MAAM,iBAAiB,CAAA;AA2ErE,eAAO,MAAM,MAAM,QAAiB,CAAA"}
|
package/dist/logger.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
3
|
+
import node_readline from "node:readline";
|
|
4
4
|
import { colors } from "./colors.js";
|
|
5
5
|
import { LogColor } from "./types/index.js";
|
|
6
6
|
import { isDebug } from "./utils.js";
|
|
@@ -11,7 +11,7 @@ const prefixes = {
|
|
|
11
11
|
info: "\u2139",
|
|
12
12
|
ready: "\u2713",
|
|
13
13
|
event: "\xbb",
|
|
14
|
-
debug:
|
|
14
|
+
debug: '-'
|
|
15
15
|
};
|
|
16
16
|
const createLogger = ()=>{
|
|
17
17
|
const log = (type, message, ...args)=>{
|
|
@@ -44,8 +44,8 @@ const createLogger = ()=>{
|
|
|
44
44
|
const repeatCount = process.stdout.rows - 2;
|
|
45
45
|
const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
|
|
46
46
|
console.log(blank);
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
node_readline.cursorTo(process.stdout, 0, 0);
|
|
48
|
+
node_readline.clearScreenDown(process.stdout);
|
|
49
49
|
},
|
|
50
50
|
greet: (msg)=>{
|
|
51
51
|
const { npm_execpath, npm_lifecycle_event } = process.env;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../src/openBrowser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openBrowser.d.ts","sourceRoot":"","sources":["../src/openBrowser.ts"],"names":[],"mappings":"AAMA,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,oBAkC5C"}
|
package/dist/openBrowser.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
4
4
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_open__ from "open";
|
|
6
6
|
import { exec } from "node:child_process";
|
|
7
|
-
import
|
|
7
|
+
import node_path from "node:path";
|
|
8
8
|
import { logger } from "./logger.js";
|
|
9
9
|
var __webpack_modules__ = {
|
|
10
10
|
open: function(module) {
|
|
@@ -39,7 +39,7 @@ async function openBrowser(url) {
|
|
|
39
39
|
const openedBrowser = supportedChromiumBrowsers.find((b)=>ps.includes(b));
|
|
40
40
|
if (openedBrowser) {
|
|
41
41
|
await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${openedBrowser}"`, {
|
|
42
|
-
cwd:
|
|
42
|
+
cwd: node_path.join(openBrowser_dirname, '../bin')
|
|
43
43
|
});
|
|
44
44
|
return true;
|
|
45
45
|
}
|
package/dist/plugin.js
CHANGED
package/dist/prebundleDeps.cjs
CHANGED
|
@@ -49,10 +49,23 @@ var external_html_webpack_plugin_default = /*#__PURE__*/ __webpack_require__.n(e
|
|
|
49
49
|
const external_tinyglobby_namespaceObject = require("tinyglobby");
|
|
50
50
|
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
51
51
|
const external_constants_cjs_namespaceObject = require("./constants.cjs");
|
|
52
|
+
const external_fs_cjs_namespaceObject = require("./fs.cjs");
|
|
52
53
|
const external_global_cjs_namespaceObject = require("./global.cjs");
|
|
53
54
|
const external_logger_cjs_namespaceObject = require("./logger.cjs");
|
|
54
55
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
55
56
|
const CACHE_DIR = 'umd';
|
|
57
|
+
const FAILED_DEPS_CACHE_FILE = 'failed-deps.json';
|
|
58
|
+
const getFailedDepsCache = (failedDepsCachePath)=>{
|
|
59
|
+
if (external_node_fs_default().existsSync(failedDepsCachePath)) return JSON.parse(external_node_fs_default().readFileSync(failedDepsCachePath, 'utf-8'));
|
|
60
|
+
return {};
|
|
61
|
+
};
|
|
62
|
+
const saveFailedDepsCache = (failedDepsCachePath, cache)=>{
|
|
63
|
+
const cacheDir = external_node_path_default().dirname(failedDepsCachePath);
|
|
64
|
+
if (!external_node_fs_default().existsSync(cacheDir)) external_node_fs_default().mkdirSync(cacheDir, {
|
|
65
|
+
recursive: true
|
|
66
|
+
});
|
|
67
|
+
external_node_fs_default().writeFileSync(failedDepsCachePath, JSON.stringify(cache, null, 2), 'utf-8');
|
|
68
|
+
};
|
|
56
69
|
const getExternalLibraryName = (pkgName)=>{
|
|
57
70
|
const externalAlias = {
|
|
58
71
|
react: 'React',
|
|
@@ -93,11 +106,13 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
93
106
|
bundled: 0
|
|
94
107
|
};
|
|
95
108
|
const failedDeps = [];
|
|
109
|
+
const { root } = unpackConfig;
|
|
110
|
+
const failedDepsCachePath = external_node_path_default().resolve(root, external_constants_cjs_namespaceObject.TEMP_DIR, FAILED_DEPS_CACHE_FILE);
|
|
111
|
+
const failedCache = getFailedDepsCache(failedDepsCachePath);
|
|
96
112
|
const updateProgress = ()=>{
|
|
97
113
|
(0, external_utils_cjs_namespaceObject.logUpdate)(`${external_colors_cjs_namespaceObject.colors.magenta("\xbb")} optimizing dependencies (${count.bundled}/${count.total})`);
|
|
98
114
|
if (count.total === count.bundled + failedDeps.length) console.log();
|
|
99
115
|
};
|
|
100
|
-
const { root } = unpackConfig;
|
|
101
116
|
const bundleDep = ({ name, entry, version })=>new Promise((resolve)=>{
|
|
102
117
|
const pkgDir = external_node_path_default().resolve(root, external_constants_cjs_namespaceObject.TEMP_DIR, CACHE_DIR, name);
|
|
103
118
|
const outDir = external_node_path_default().resolve(pkgDir, version);
|
|
@@ -112,7 +127,6 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
112
127
|
};
|
|
113
128
|
};
|
|
114
129
|
if (external_node_fs_default().existsSync(outDir)) return void resolve(getResult());
|
|
115
|
-
(0, external_utils_cjs_namespaceObject.removeDir)(pkgDir);
|
|
116
130
|
count.total++;
|
|
117
131
|
updateProgress();
|
|
118
132
|
const getSwcOptions = ({ tsx })=>({
|
|
@@ -223,7 +237,8 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
223
237
|
if (null == stats ? void 0 : stats.hasErrors()) {
|
|
224
238
|
isFailed = true;
|
|
225
239
|
failedDeps.push(name);
|
|
226
|
-
|
|
240
|
+
failedCache[name] = version;
|
|
241
|
+
(0, external_fs_cjs_namespaceObject.removeDir)(outDir);
|
|
227
242
|
} else count.bundled++;
|
|
228
243
|
updateProgress();
|
|
229
244
|
compiler.close(()=>{
|
|
@@ -243,16 +258,22 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
243
258
|
const noEntryDeps = [];
|
|
244
259
|
const needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
245
260
|
const packageJson = JSON.parse(external_node_fs_default().readFileSync(external_node_path_default().resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8'));
|
|
261
|
+
const version = packageJson.version;
|
|
262
|
+
if (failedCache[pkgName] === version) return;
|
|
246
263
|
const entry = getPkgEntry(packageJson);
|
|
247
|
-
if (!entry)
|
|
264
|
+
if (!entry) {
|
|
265
|
+
noEntryDeps.push(pkgName);
|
|
266
|
+
failedCache[pkgName] = version;
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
248
269
|
return {
|
|
249
270
|
name: pkgName,
|
|
250
271
|
entry: external_node_path_default().resolve(root, 'node_modules', pkgName, entry),
|
|
251
|
-
version
|
|
272
|
+
version
|
|
252
273
|
};
|
|
253
274
|
}).filter(Boolean);
|
|
254
|
-
if (noEntryDeps[0]) external_logger_cjs_namespaceObject.logger.warn(`could not find entry for "${external_colors_cjs_namespaceObject.colors.bold(noEntryDeps.join(', '))}"`);
|
|
255
275
|
const bundledDeps = await Promise.all(needBundleDeps.map((depInfo)=>bundleDep(depInfo)));
|
|
276
|
+
saveFailedDepsCache(failedDepsCachePath, failedCache);
|
|
256
277
|
if (failedDeps[0]) external_logger_cjs_namespaceObject.logger.warn(`something went wrong while optimizing "${external_colors_cjs_namespaceObject.colors.bold(failedDeps.join(', '))}"`);
|
|
257
278
|
const cachePath = external_node_path_default().resolve(root, external_constants_cjs_namespaceObject.TEMP_DIR, CACHE_DIR);
|
|
258
279
|
const app = external_express_default()();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prebundleDeps.d.ts","sourceRoot":"","sources":["../src/prebundleDeps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prebundleDeps.d.ts","sourceRoot":"","sources":["../src/prebundleDeps.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA0E3C,eAAO,MAAM,aAAa,GAAU,mBAEjC;IACD,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,YAAY,CAuRvB,CAAA"}
|
package/dist/prebundleDeps.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import node_path from "node:path";
|
|
5
5
|
import { rspack } from "@rspack/core";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import cors from "cors";
|
|
7
|
+
import express from "express";
|
|
8
|
+
import html_webpack_plugin from "html-webpack-plugin";
|
|
9
9
|
import { globSync } from "tinyglobby";
|
|
10
10
|
import { colors } from "./colors.js";
|
|
11
11
|
import { TEMP_DIR } from "./constants.js";
|
|
12
|
+
import { removeDir } from "./fs.js";
|
|
12
13
|
import { restartCleaners } from "./global.js";
|
|
13
14
|
import { logger } from "./logger.js";
|
|
14
|
-
import { getCompiledPkgPath, getPort, getUserDepPath, isPlainObject, isString, logUpdate
|
|
15
|
+
import { getCompiledPkgPath, getPort, getUserDepPath, isPlainObject, isString, logUpdate } from "./utils.js";
|
|
15
16
|
const CACHE_DIR = 'umd';
|
|
17
|
+
const FAILED_DEPS_CACHE_FILE = 'failed-deps.json';
|
|
18
|
+
const getFailedDepsCache = (failedDepsCachePath)=>{
|
|
19
|
+
if (node_fs.existsSync(failedDepsCachePath)) return JSON.parse(node_fs.readFileSync(failedDepsCachePath, 'utf-8'));
|
|
20
|
+
return {};
|
|
21
|
+
};
|
|
22
|
+
const saveFailedDepsCache = (failedDepsCachePath, cache)=>{
|
|
23
|
+
const cacheDir = node_path.dirname(failedDepsCachePath);
|
|
24
|
+
if (!node_fs.existsSync(cacheDir)) node_fs.mkdirSync(cacheDir, {
|
|
25
|
+
recursive: true
|
|
26
|
+
});
|
|
27
|
+
node_fs.writeFileSync(failedDepsCachePath, JSON.stringify(cache, null, 2), 'utf-8');
|
|
28
|
+
};
|
|
16
29
|
const getExternalLibraryName = (pkgName)=>{
|
|
17
30
|
const externalAlias = {
|
|
18
31
|
react: 'React',
|
|
@@ -53,14 +66,16 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
53
66
|
bundled: 0
|
|
54
67
|
};
|
|
55
68
|
const failedDeps = [];
|
|
69
|
+
const { root } = unpackConfig;
|
|
70
|
+
const failedDepsCachePath = node_path.resolve(root, TEMP_DIR, FAILED_DEPS_CACHE_FILE);
|
|
71
|
+
const failedCache = getFailedDepsCache(failedDepsCachePath);
|
|
56
72
|
const updateProgress = ()=>{
|
|
57
73
|
logUpdate(`${colors.magenta("\xbb")} optimizing dependencies (${count.bundled}/${count.total})`);
|
|
58
74
|
if (count.total === count.bundled + failedDeps.length) console.log();
|
|
59
75
|
};
|
|
60
|
-
const { root } = unpackConfig;
|
|
61
76
|
const bundleDep = ({ name, entry, version })=>new Promise((resolve)=>{
|
|
62
|
-
const pkgDir =
|
|
63
|
-
const outDir =
|
|
77
|
+
const pkgDir = node_path.resolve(root, TEMP_DIR, CACHE_DIR, name);
|
|
78
|
+
const outDir = node_path.resolve(pkgDir, version);
|
|
64
79
|
const getResult = ()=>{
|
|
65
80
|
const assets = globSync('**/index.{js,css}', {
|
|
66
81
|
cwd: outDir,
|
|
@@ -71,8 +86,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
71
86
|
assets
|
|
72
87
|
};
|
|
73
88
|
};
|
|
74
|
-
if (
|
|
75
|
-
removeDir(pkgDir);
|
|
89
|
+
if (node_fs.existsSync(outDir)) return void resolve(getResult());
|
|
76
90
|
count.total++;
|
|
77
91
|
updateProgress();
|
|
78
92
|
const getSwcOptions = ({ tsx })=>({
|
|
@@ -183,6 +197,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
183
197
|
if (null == stats ? void 0 : stats.hasErrors()) {
|
|
184
198
|
isFailed = true;
|
|
185
199
|
failedDeps.push(name);
|
|
200
|
+
failedCache[name] = version;
|
|
186
201
|
removeDir(outDir);
|
|
187
202
|
} else count.bundled++;
|
|
188
203
|
updateProgress();
|
|
@@ -193,7 +208,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
193
208
|
});
|
|
194
209
|
const userOptions = isPlainObject(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) ? unpackConfig.dev.prebundle : {};
|
|
195
210
|
const ignoreCssDeps = userOptions.ignoreCss || [];
|
|
196
|
-
const packageJson = JSON.parse(
|
|
211
|
+
const packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'package.json'), 'utf-8'));
|
|
197
212
|
const existExternals = getExistExternals(unpackConfig.externals);
|
|
198
213
|
const excludeDeps = [
|
|
199
214
|
...existExternals || [],
|
|
@@ -202,22 +217,28 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
202
217
|
const shouldIncludeDeps = Object.keys(packageJson.dependencies).filter((pkgName)=>!excludeDeps.includes(pkgName));
|
|
203
218
|
const noEntryDeps = [];
|
|
204
219
|
const needBundleDeps = shouldIncludeDeps.map((pkgName)=>{
|
|
205
|
-
const packageJson = JSON.parse(
|
|
220
|
+
const packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'node_modules', pkgName, 'package.json'), 'utf-8'));
|
|
221
|
+
const version = packageJson.version;
|
|
222
|
+
if (failedCache[pkgName] === version) return;
|
|
206
223
|
const entry = getPkgEntry(packageJson);
|
|
207
|
-
if (!entry)
|
|
224
|
+
if (!entry) {
|
|
225
|
+
noEntryDeps.push(pkgName);
|
|
226
|
+
failedCache[pkgName] = version;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
208
229
|
return {
|
|
209
230
|
name: pkgName,
|
|
210
|
-
entry:
|
|
211
|
-
version
|
|
231
|
+
entry: node_path.resolve(root, 'node_modules', pkgName, entry),
|
|
232
|
+
version
|
|
212
233
|
};
|
|
213
234
|
}).filter(Boolean);
|
|
214
|
-
if (noEntryDeps[0]) logger.warn(`could not find entry for "${colors.bold(noEntryDeps.join(', '))}"`);
|
|
215
235
|
const bundledDeps = await Promise.all(needBundleDeps.map((depInfo)=>bundleDep(depInfo)));
|
|
236
|
+
saveFailedDepsCache(failedDepsCachePath, failedCache);
|
|
216
237
|
if (failedDeps[0]) logger.warn(`something went wrong while optimizing "${colors.bold(failedDeps.join(', '))}"`);
|
|
217
|
-
const cachePath =
|
|
218
|
-
const app =
|
|
219
|
-
app.use(
|
|
220
|
-
app.use(`/${CACHE_DIR}`,
|
|
238
|
+
const cachePath = node_path.resolve(root, TEMP_DIR, CACHE_DIR);
|
|
239
|
+
const app = express();
|
|
240
|
+
app.use(cors());
|
|
241
|
+
app.use(`/${CACHE_DIR}`, express["static"](cachePath));
|
|
221
242
|
const port = await getPort();
|
|
222
243
|
const staticServer = app.listen(port, ()=>{});
|
|
223
244
|
restartCleaners.push(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
@@ -228,7 +249,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
228
249
|
bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
229
250
|
externals[dep.name] = getExternalValue(dep.name);
|
|
230
251
|
dep.assets.forEach((absPath)=>{
|
|
231
|
-
const relativePath =
|
|
252
|
+
const relativePath = node_path.relative(cachePath, absPath);
|
|
232
253
|
const preDeps = [
|
|
233
254
|
'react',
|
|
234
255
|
'react-dom',
|
|
@@ -236,7 +257,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
236
257
|
'react-router-dom'
|
|
237
258
|
];
|
|
238
259
|
const serverPath = `//localhost:${port}/${CACHE_DIR}/${relativePath}`;
|
|
239
|
-
switch(
|
|
260
|
+
switch(node_path.extname(relativePath)){
|
|
240
261
|
case '.js':
|
|
241
262
|
if (preDeps.includes(dep.name)) preJsAssets.push({
|
|
242
263
|
path: serverPath,
|
|
@@ -259,7 +280,7 @@ const prebundleDeps = async ({ unpackConfig })=>{
|
|
|
259
280
|
...externals,
|
|
260
281
|
...unpackConfig.externals
|
|
261
282
|
};
|
|
262
|
-
const HtmlPlugin = 'rspack' === unpackConfig.bundler ? rspack.HtmlRspackPlugin :
|
|
283
|
+
const HtmlPlugin = 'rspack' === unpackConfig.bundler ? rspack.HtmlRspackPlugin : html_webpack_plugin;
|
|
263
284
|
unpackConfig.plugins.push({
|
|
264
285
|
name: 'unpack:prebundle',
|
|
265
286
|
bundlerConfig: (config)=>{
|
package/dist/progressBar.cjs
CHANGED
|
@@ -27,6 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
ProgressBar: ()=>ProgressBar
|
|
28
28
|
});
|
|
29
29
|
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
30
|
+
const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
|
|
30
31
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
31
32
|
function _define_property(obj, key, value) {
|
|
32
33
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -41,16 +42,18 @@ function _define_property(obj, key, value) {
|
|
|
41
42
|
class ProgressBar {
|
|
42
43
|
update({ current: originalCurrent, message = '' }) {
|
|
43
44
|
const { columns: terminalWidth } = process.stdout;
|
|
44
|
-
const messageWidth = terminalWidth - this.prefix.length - 8;
|
|
45
45
|
let current = originalCurrent;
|
|
46
46
|
if (originalCurrent >= 0.98) current = 1;
|
|
47
|
-
|
|
47
|
+
const loadingChar = this.loadingAnimation.getCurrentChar();
|
|
48
|
+
const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
|
|
49
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${external_colors_cjs_namespaceObject.colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
|
|
48
50
|
}
|
|
49
51
|
done() {
|
|
50
52
|
console.log();
|
|
51
53
|
}
|
|
52
54
|
constructor(){
|
|
53
55
|
_define_property(this, "prefix", 'transforming');
|
|
56
|
+
_define_property(this, "loadingAnimation", new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation());
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
exports.ProgressBar = __webpack_exports__.ProgressBar;
|
package/dist/progressBar.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../src/progressBar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../src/progressBar.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAGrD,qBAAa,WAAW;IACtB,MAAM,SAAiB;IACvB,gBAAgB,mBAAyB;IAEzC,MAAM,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAY,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAcxF,IAAI;CAGL"}
|
package/dist/progressBar.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { colors } from "./colors.js";
|
|
4
|
+
import { LoadingAnimation } from "./loadingAnimation.js";
|
|
4
5
|
import { logUpdate } from "./utils.js";
|
|
5
6
|
function _define_property(obj, key, value) {
|
|
6
7
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -15,16 +16,18 @@ function _define_property(obj, key, value) {
|
|
|
15
16
|
class ProgressBar {
|
|
16
17
|
update({ current: originalCurrent, message = '' }) {
|
|
17
18
|
const { columns: terminalWidth } = process.stdout;
|
|
18
|
-
const messageWidth = terminalWidth - this.prefix.length - 8;
|
|
19
19
|
let current = originalCurrent;
|
|
20
20
|
if (originalCurrent >= 0.98) current = 1;
|
|
21
|
-
|
|
21
|
+
const loadingChar = this.loadingAnimation.getCurrentChar();
|
|
22
|
+
const messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
|
|
23
|
+
logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
|
|
22
24
|
}
|
|
23
25
|
done() {
|
|
24
26
|
console.log();
|
|
25
27
|
}
|
|
26
28
|
constructor(){
|
|
27
29
|
_define_property(this, "prefix", 'transforming');
|
|
30
|
+
_define_property(this, "loadingAnimation", new LoadingAnimation());
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
export { ProgressBar };
|
package/dist/reporter.cjs
CHANGED
|
@@ -43,6 +43,7 @@ const external_node_util_namespaceObject = require("node:util");
|
|
|
43
43
|
const external_node_zlib_namespaceObject = require("node:zlib");
|
|
44
44
|
var external_node_zlib_default = /*#__PURE__*/ __webpack_require__.n(external_node_zlib_namespaceObject);
|
|
45
45
|
const external_colors_cjs_namespaceObject = require("./colors.cjs");
|
|
46
|
+
const external_loadingAnimation_cjs_namespaceObject = require("./loadingAnimation.cjs");
|
|
46
47
|
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
47
48
|
const chunkSizeLimit = 500;
|
|
48
49
|
const gzip = (0, external_node_util_namespaceObject.promisify)(external_node_zlib_default().gzip);
|
|
@@ -83,7 +84,8 @@ async function printFileSize({ root, stats }) {
|
|
|
83
84
|
return acc;
|
|
84
85
|
}, {});
|
|
85
86
|
let compressedCount = 0;
|
|
86
|
-
|
|
87
|
+
const loadingAnimation = new external_loadingAnimation_cjs_namespaceObject.LoadingAnimation();
|
|
88
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
|
|
87
89
|
const distPath = stats.compilation.outputOptions.path;
|
|
88
90
|
const distFolder = external_node_path_default().relative(root, distPath);
|
|
89
91
|
const origin = stats.toJson({
|
|
@@ -106,7 +108,7 @@ async function printFileSize({ root, stats }) {
|
|
|
106
108
|
totalSize += size;
|
|
107
109
|
totalCompressedSize += compressedSize;
|
|
108
110
|
compressedCount++;
|
|
109
|
-
(0, external_utils_cjs_namespaceObject.logUpdate)(
|
|
111
|
+
(0, external_utils_cjs_namespaceObject.logUpdate)(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
|
|
110
112
|
if (compressedCount === origin.assets.length) {
|
|
111
113
|
(0, external_utils_cjs_namespaceObject.logUpdate)(`\u{2713} computed gzip size (${compressedCount})`);
|
|
112
114
|
console.log();
|
package/dist/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AAKpD,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,YAAY,GAAG,WAAW,CAAA;CAClC,CAAA;AA2BD,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,iBAiG3D"}
|
package/dist/reporter.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import node_path from "node:path";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
|
-
import
|
|
6
|
+
import node_zlib from "node:zlib";
|
|
7
7
|
import { colors } from "./colors.js";
|
|
8
|
+
import { LoadingAnimation } from "./loadingAnimation.js";
|
|
8
9
|
import { logUpdate } from "./utils.js";
|
|
9
10
|
const chunkSizeLimit = 500;
|
|
10
|
-
const gzip = promisify(
|
|
11
|
+
const gzip = promisify(node_zlib.gzip);
|
|
11
12
|
const numberFormatter = new Intl.NumberFormat('en', {
|
|
12
13
|
maximumFractionDigits: 2,
|
|
13
14
|
minimumFractionDigits: 2
|
|
@@ -45,9 +46,10 @@ async function printFileSize({ root, stats }) {
|
|
|
45
46
|
return acc;
|
|
46
47
|
}, {});
|
|
47
48
|
let compressedCount = 0;
|
|
48
|
-
|
|
49
|
+
const loadingAnimation = new LoadingAnimation();
|
|
50
|
+
logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (0)...`);
|
|
49
51
|
const distPath = stats.compilation.outputOptions.path;
|
|
50
|
-
const distFolder =
|
|
52
|
+
const distFolder = node_path.relative(root, distPath);
|
|
51
53
|
const origin = stats.toJson({
|
|
52
54
|
all: false,
|
|
53
55
|
assets: true,
|
|
@@ -62,25 +64,25 @@ async function printFileSize({ root, stats }) {
|
|
|
62
64
|
let totalSize = 0;
|
|
63
65
|
let totalCompressedSize = 0;
|
|
64
66
|
await Promise.all(origin.assets.map(async (asset)=>{
|
|
65
|
-
const content = await
|
|
67
|
+
const content = await node_fs.promises.readFile(node_path.join(distPath, asset.name));
|
|
66
68
|
const size = content.length;
|
|
67
69
|
const compressedSize = await getCompressedSize(content);
|
|
68
70
|
totalSize += size;
|
|
69
71
|
totalCompressedSize += compressedSize;
|
|
70
72
|
compressedCount++;
|
|
71
|
-
logUpdate(
|
|
73
|
+
logUpdate(`${loadingAnimation.getCurrentChar()} computing gzip size (${compressedCount})...`);
|
|
72
74
|
if (compressedCount === origin.assets.length) {
|
|
73
75
|
logUpdate(`\u{2713} computed gzip size (${compressedCount})`);
|
|
74
76
|
console.log();
|
|
75
77
|
}
|
|
76
78
|
const chunk = {
|
|
77
|
-
name:
|
|
79
|
+
name: node_path.basename(asset.name),
|
|
78
80
|
path: `${distFolder}/${asset.name}`,
|
|
79
81
|
size,
|
|
80
82
|
compressedSize
|
|
81
83
|
};
|
|
82
84
|
if (chunk.path.length > longest) longest = chunk.path.length;
|
|
83
|
-
const ext =
|
|
85
|
+
const ext = node_path.extname(asset.name);
|
|
84
86
|
switch(ext){
|
|
85
87
|
case '.html':
|
|
86
88
|
chunkGroupMap.HTML.chunks.push(chunk);
|
|
@@ -102,7 +104,7 @@ async function printFileSize({ root, stats }) {
|
|
|
102
104
|
group.chunks.sort((a, b)=>a.size - b.size).forEach((chunk)=>{
|
|
103
105
|
const isLarge = 'JS' === group.type && chunk.size / 1000 > chunkSizeLimit;
|
|
104
106
|
const sizeColor = isLarge ? 'yellow' : 'dim';
|
|
105
|
-
const relativeOutDir =
|
|
107
|
+
const relativeOutDir = node_path.dirname(chunk.path) + '/';
|
|
106
108
|
let log = colors.dim(relativeOutDir);
|
|
107
109
|
log += colors[group.color](chunk.name.padEnd(longest + 2 - relativeOutDir.length));
|
|
108
110
|
log += colors[sizeColor](displaySize(chunk.size).padStart(sizePad));
|