@unpackjs/core 2.2.0 → 2.3.1
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 +39 -39
- 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.cjs +4 -4
- package/dist/colors.js +7 -7
- 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 +64 -51
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -11
- 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 +15 -3
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +19 -7
- 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
package/dist/loadEnv.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import node_fs from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { expand } from "dotenv-expand";
|
|
6
|
+
import { colors } from "./colors.js";
|
|
7
|
+
import { isFileSync } from "./fs.js";
|
|
8
|
+
import { logger } from "./logger.js";
|
|
9
|
+
import { getNodeEnv } from "./utils.js";
|
|
10
|
+
const DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
11
|
+
function parse(src) {
|
|
12
|
+
const obj = {};
|
|
13
|
+
let lines = src.toString();
|
|
14
|
+
lines = lines.replace(/\r\n?/gm, '\n');
|
|
15
|
+
let match;
|
|
16
|
+
while(null != (match = DOTENV_LINE.exec(lines))){
|
|
17
|
+
const key = match[1];
|
|
18
|
+
let value = match[2] || '';
|
|
19
|
+
value = value.trim();
|
|
20
|
+
const maybeQuote = value[0];
|
|
21
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, '$2');
|
|
22
|
+
if ('"' === maybeQuote) {
|
|
23
|
+
value = value.replace(/\\n/g, '\n');
|
|
24
|
+
value = value.replace(/\\r/g, '\r');
|
|
25
|
+
}
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
31
|
+
'PUBLIC_'
|
|
32
|
+
], processEnv = process.env } = {}) {
|
|
33
|
+
if ('local' === mode) throw new Error(`${colors.yellow('local')} cannot be used as a value for env mode, because ${colors.yellow('.env.local')} represents a temporary local file. Please use another value.`);
|
|
34
|
+
const filenames = [
|
|
35
|
+
'.env',
|
|
36
|
+
'.env.local',
|
|
37
|
+
`.env.${mode}`,
|
|
38
|
+
`.env.${mode}.local`
|
|
39
|
+
];
|
|
40
|
+
const filePaths = filenames.map((filename)=>join(cwd, filename)).filter(isFileSync);
|
|
41
|
+
const parsed = {};
|
|
42
|
+
for (const envPath of filePaths){
|
|
43
|
+
Object.assign(parsed, parse(node_fs.readFileSync(envPath)));
|
|
44
|
+
logger.debug('loaded env file:', envPath);
|
|
45
|
+
}
|
|
46
|
+
if (parsed.NODE_ENV) processEnv.NODE_ENV = parsed.NODE_ENV;
|
|
47
|
+
expand({
|
|
48
|
+
parsed,
|
|
49
|
+
processEnv
|
|
50
|
+
});
|
|
51
|
+
const publicVars = {};
|
|
52
|
+
const rawPublicVars = {};
|
|
53
|
+
const normalizedPrefixes = Array.isArray(prefixes) ? prefixes : [
|
|
54
|
+
prefixes
|
|
55
|
+
];
|
|
56
|
+
for (const key of Object.keys(processEnv))if (normalizedPrefixes.some((prefix)=>key.startsWith(prefix))) {
|
|
57
|
+
const val = processEnv[key];
|
|
58
|
+
publicVars[`import.meta.env.${key}`] = JSON.stringify(val);
|
|
59
|
+
publicVars[`process.env.${key}`] = JSON.stringify(val);
|
|
60
|
+
rawPublicVars[key] = val;
|
|
61
|
+
}
|
|
62
|
+
publicVars['import.meta.env'] = JSON.stringify(rawPublicVars);
|
|
63
|
+
publicVars['process.env'] = JSON.stringify(rawPublicVars);
|
|
64
|
+
let cleaned = false;
|
|
65
|
+
const cleanup = ()=>{
|
|
66
|
+
if (cleaned) return;
|
|
67
|
+
for (const key of Object.keys(parsed))if ('NODE_ENV' !== key) {
|
|
68
|
+
if (processEnv[key] === parsed[key]) delete processEnv[key];
|
|
69
|
+
}
|
|
70
|
+
cleaned = true;
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
parsed,
|
|
74
|
+
cleanup,
|
|
75
|
+
filePaths,
|
|
76
|
+
publicVars,
|
|
77
|
+
rawPublicVars
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export { loadEnv };
|
|
@@ -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
|
@@ -47,7 +47,14 @@ const prefixes = {
|
|
|
47
47
|
info: "\u2139",
|
|
48
48
|
ready: "\u2713",
|
|
49
49
|
event: "\xbb",
|
|
50
|
-
debug:
|
|
50
|
+
debug: ''
|
|
51
|
+
};
|
|
52
|
+
const formatTime = ()=>{
|
|
53
|
+
const now = new Date();
|
|
54
|
+
const hours = now.getHours().toString().padStart(2, '0');
|
|
55
|
+
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
56
|
+
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
57
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
51
58
|
};
|
|
52
59
|
const createLogger = ()=>{
|
|
53
60
|
const log = (type, message, ...args)=>{
|
|
@@ -68,12 +75,17 @@ const createLogger = ()=>{
|
|
|
68
75
|
case 'warn':
|
|
69
76
|
text = external_colors_cjs_namespaceObject.colors.yellow(message);
|
|
70
77
|
break;
|
|
78
|
+
case 'debug':
|
|
79
|
+
text = `${external_colors_cjs_namespaceObject.colors.dim(formatTime())} ${external_colors_cjs_namespaceObject.colors.magenta('debug')} ${message}`;
|
|
80
|
+
break;
|
|
71
81
|
default:
|
|
72
82
|
text = message;
|
|
73
83
|
break;
|
|
74
84
|
}
|
|
75
|
-
if ('debug' === type
|
|
76
|
-
|
|
85
|
+
if ('debug' === type) {
|
|
86
|
+
if (!(0, external_utils_cjs_namespaceObject.isDebug)()) return;
|
|
87
|
+
console.log(text, ...args);
|
|
88
|
+
} else console.log(`${label} ${text}`, ...args);
|
|
77
89
|
};
|
|
78
90
|
const logger = {
|
|
79
91
|
clear: ()=>{
|
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;AA0FrE,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,14 @@ const prefixes = {
|
|
|
11
11
|
info: "\u2139",
|
|
12
12
|
ready: "\u2713",
|
|
13
13
|
event: "\xbb",
|
|
14
|
-
debug:
|
|
14
|
+
debug: ''
|
|
15
|
+
};
|
|
16
|
+
const formatTime = ()=>{
|
|
17
|
+
const now = new Date();
|
|
18
|
+
const hours = now.getHours().toString().padStart(2, '0');
|
|
19
|
+
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
20
|
+
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
21
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
15
22
|
};
|
|
16
23
|
const createLogger = ()=>{
|
|
17
24
|
const log = (type, message, ...args)=>{
|
|
@@ -32,20 +39,25 @@ const createLogger = ()=>{
|
|
|
32
39
|
case 'warn':
|
|
33
40
|
text = colors.yellow(message);
|
|
34
41
|
break;
|
|
42
|
+
case 'debug':
|
|
43
|
+
text = `${colors.dim(formatTime())} ${colors.magenta('debug')} ${message}`;
|
|
44
|
+
break;
|
|
35
45
|
default:
|
|
36
46
|
text = message;
|
|
37
47
|
break;
|
|
38
48
|
}
|
|
39
|
-
if ('debug' === type
|
|
40
|
-
|
|
49
|
+
if ('debug' === type) {
|
|
50
|
+
if (!isDebug()) return;
|
|
51
|
+
console.log(text, ...args);
|
|
52
|
+
} else console.log(`${label} ${text}`, ...args);
|
|
41
53
|
};
|
|
42
54
|
const logger = {
|
|
43
55
|
clear: ()=>{
|
|
44
56
|
const repeatCount = process.stdout.rows - 2;
|
|
45
57
|
const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
|
|
46
58
|
console.log(blank);
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
node_readline.cursorTo(process.stdout, 0, 0);
|
|
60
|
+
node_readline.clearScreenDown(process.stdout);
|
|
49
61
|
},
|
|
50
62
|
greet: (msg)=>{
|
|
51
63
|
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 };
|