@utoo/pack-shared 1.4.13-alpha.0 → 1.4.13-alpha.2
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/webpackCompat.js +15 -6
- package/esm/webpackCompat.js +15 -6
- package/package.json +1 -1
package/cjs/webpackCompat.js
CHANGED
|
@@ -12,17 +12,18 @@ function compatOptionsFromWebpack(webpackConfig) {
|
|
|
12
12
|
if (outputCompat && copy) {
|
|
13
13
|
outputCompat.copy = copy;
|
|
14
14
|
}
|
|
15
|
+
const modeCompat = compatMode(mode);
|
|
15
16
|
return {
|
|
16
17
|
config: {
|
|
17
18
|
entry: compatEntry(entry, html),
|
|
18
|
-
mode:
|
|
19
|
+
mode: modeCompat,
|
|
19
20
|
module: compatModule(module),
|
|
20
21
|
resolve: compatResolve(resolve),
|
|
21
22
|
externals: compatExternals(externals, externalsType),
|
|
22
23
|
output: outputCompat,
|
|
23
24
|
target: compatTarget(target),
|
|
24
25
|
sourceMaps: compatSourceMaps(devtool),
|
|
25
|
-
optimization: compatOptimization(optimization),
|
|
26
|
+
optimization: compatOptimization(optimization, modeCompat),
|
|
26
27
|
define: compatFromWebpackPlugin(plugins, compatDefine),
|
|
27
28
|
provider: compatFromWebpackPlugin(plugins, compatProvider),
|
|
28
29
|
stats: compatStats(stats),
|
|
@@ -475,8 +476,16 @@ function compatTarget(webpackTarget) {
|
|
|
475
476
|
function compatSourceMaps(webpackSourceMaps) {
|
|
476
477
|
return !!webpackSourceMaps;
|
|
477
478
|
}
|
|
478
|
-
function compatOptimization(webpackOptimization) {
|
|
479
|
+
function compatOptimization(webpackOptimization, mode) {
|
|
480
|
+
const productionDefault = mode === "production" ? true : undefined;
|
|
479
481
|
if (!webpackOptimization) {
|
|
482
|
+
if (mode === "production") {
|
|
483
|
+
return {
|
|
484
|
+
concatenateModules: true,
|
|
485
|
+
removeUnusedExports: true,
|
|
486
|
+
removeUnusedImports: true,
|
|
487
|
+
};
|
|
488
|
+
}
|
|
480
489
|
return;
|
|
481
490
|
}
|
|
482
491
|
const { moduleIds, minimize, concatenateModules, usedExports } = webpackOptimization;
|
|
@@ -489,10 +498,10 @@ function compatOptimization(webpackOptimization) {
|
|
|
489
498
|
: undefined,
|
|
490
499
|
noMangling: webpackOptimization.mangleExports === false,
|
|
491
500
|
minify: minimize,
|
|
492
|
-
concatenateModules,
|
|
501
|
+
concatenateModules: concatenateModules !== null && concatenateModules !== void 0 ? concatenateModules : productionDefault,
|
|
493
502
|
treeShaking: false,
|
|
494
|
-
removeUnusedExports: enableWebpackUsedExports,
|
|
495
|
-
removeUnusedImports: enableWebpackUsedExports,
|
|
503
|
+
removeUnusedExports: enableWebpackUsedExports !== null && enableWebpackUsedExports !== void 0 ? enableWebpackUsedExports : productionDefault,
|
|
504
|
+
removeUnusedImports: enableWebpackUsedExports !== null && enableWebpackUsedExports !== void 0 ? enableWebpackUsedExports : productionDefault,
|
|
496
505
|
};
|
|
497
506
|
}
|
|
498
507
|
function compatStats(webpackStats) {
|
package/esm/webpackCompat.js
CHANGED
|
@@ -9,17 +9,18 @@ export function compatOptionsFromWebpack(webpackConfig) {
|
|
|
9
9
|
if (outputCompat && copy) {
|
|
10
10
|
outputCompat.copy = copy;
|
|
11
11
|
}
|
|
12
|
+
const modeCompat = compatMode(mode);
|
|
12
13
|
return {
|
|
13
14
|
config: {
|
|
14
15
|
entry: compatEntry(entry, html),
|
|
15
|
-
mode:
|
|
16
|
+
mode: modeCompat,
|
|
16
17
|
module: compatModule(module),
|
|
17
18
|
resolve: compatResolve(resolve),
|
|
18
19
|
externals: compatExternals(externals, externalsType),
|
|
19
20
|
output: outputCompat,
|
|
20
21
|
target: compatTarget(target),
|
|
21
22
|
sourceMaps: compatSourceMaps(devtool),
|
|
22
|
-
optimization: compatOptimization(optimization),
|
|
23
|
+
optimization: compatOptimization(optimization, modeCompat),
|
|
23
24
|
define: compatFromWebpackPlugin(plugins, compatDefine),
|
|
24
25
|
provider: compatFromWebpackPlugin(plugins, compatProvider),
|
|
25
26
|
stats: compatStats(stats),
|
|
@@ -472,8 +473,16 @@ function compatTarget(webpackTarget) {
|
|
|
472
473
|
function compatSourceMaps(webpackSourceMaps) {
|
|
473
474
|
return !!webpackSourceMaps;
|
|
474
475
|
}
|
|
475
|
-
function compatOptimization(webpackOptimization) {
|
|
476
|
+
function compatOptimization(webpackOptimization, mode) {
|
|
477
|
+
const productionDefault = mode === "production" ? true : undefined;
|
|
476
478
|
if (!webpackOptimization) {
|
|
479
|
+
if (mode === "production") {
|
|
480
|
+
return {
|
|
481
|
+
concatenateModules: true,
|
|
482
|
+
removeUnusedExports: true,
|
|
483
|
+
removeUnusedImports: true,
|
|
484
|
+
};
|
|
485
|
+
}
|
|
477
486
|
return;
|
|
478
487
|
}
|
|
479
488
|
const { moduleIds, minimize, concatenateModules, usedExports } = webpackOptimization;
|
|
@@ -486,10 +495,10 @@ function compatOptimization(webpackOptimization) {
|
|
|
486
495
|
: undefined,
|
|
487
496
|
noMangling: webpackOptimization.mangleExports === false,
|
|
488
497
|
minify: minimize,
|
|
489
|
-
concatenateModules,
|
|
498
|
+
concatenateModules: concatenateModules !== null && concatenateModules !== void 0 ? concatenateModules : productionDefault,
|
|
490
499
|
treeShaking: false,
|
|
491
|
-
removeUnusedExports: enableWebpackUsedExports,
|
|
492
|
-
removeUnusedImports: enableWebpackUsedExports,
|
|
500
|
+
removeUnusedExports: enableWebpackUsedExports !== null && enableWebpackUsedExports !== void 0 ? enableWebpackUsedExports : productionDefault,
|
|
501
|
+
removeUnusedImports: enableWebpackUsedExports !== null && enableWebpackUsedExports !== void 0 ? enableWebpackUsedExports : productionDefault,
|
|
493
502
|
};
|
|
494
503
|
}
|
|
495
504
|
function compatStats(webpackStats) {
|