@utoo/pack-cli 1.4.12 → 1.4.13-alpha.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/cjs/utils/common.js +22 -1
- package/package.json +2 -2
package/cjs/utils/common.js
CHANGED
|
@@ -49,6 +49,27 @@ const CONFIG_FILE_NAMES = [
|
|
|
49
49
|
function resolveOptionalPath(baseDir, value) {
|
|
50
50
|
return typeof value === "string" ? path_1.default.resolve(baseDir, value) : undefined;
|
|
51
51
|
}
|
|
52
|
+
function isRecord(value) {
|
|
53
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
54
|
+
}
|
|
55
|
+
function applyCliConfigDefaults(config, dev) {
|
|
56
|
+
const isProduction = config.mode !== "development" && dev !== true;
|
|
57
|
+
const optimization = isRecord(config.optimization) ? config.optimization : {};
|
|
58
|
+
return {
|
|
59
|
+
...config,
|
|
60
|
+
persistentCaching: config.persistentCaching ?? true,
|
|
61
|
+
...(isProduction
|
|
62
|
+
? {
|
|
63
|
+
optimization: {
|
|
64
|
+
...optimization,
|
|
65
|
+
concatenateModules: optimization.concatenateModules ?? true,
|
|
66
|
+
removeUnusedExports: optimization.removeUnusedExports ?? true,
|
|
67
|
+
removeUnusedImports: optimization.removeUnusedImports ?? true,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
: {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
52
73
|
async function resolveFromConfigFile(configDir) {
|
|
53
74
|
const resolvedDir = path_1.default.resolve(configDir);
|
|
54
75
|
for (const name of CONFIG_FILE_NAMES) {
|
|
@@ -92,7 +113,7 @@ async function resolveBuildOptions(flags) {
|
|
|
92
113
|
configDir;
|
|
93
114
|
rootPath = rootPath || resolveOptionalPath(configDir, configRootPath);
|
|
94
115
|
projectOptions = {
|
|
95
|
-
config,
|
|
116
|
+
config: applyCliConfigDefaults(config, dev),
|
|
96
117
|
processEnv,
|
|
97
118
|
watch,
|
|
98
119
|
dev,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack-cli",
|
|
3
3
|
"description": "Utoo pack cli",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.13-alpha.1",
|
|
5
5
|
"author": "xusd320",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"up": "./bin/run.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@utoo/pack": "1.4.
|
|
15
|
+
"@utoo/pack": "1.4.13-alpha.1",
|
|
16
16
|
"citty": "^0.1.6"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|