@unpackjs/core 1.7.5 → 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 +180 -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 -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 -1047
- package/compiled/commander/index.js +0 -2428
- 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
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_esbuild__ from "esbuild";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_webpack__ from "webpack";
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
|
+
value: value,
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
else obj[key] = value;
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
const { RawSource, SourceMapSource } = __WEBPACK_EXTERNAL_MODULE_webpack__["default"].sources;
|
|
13
16
|
const isJsFile = /\.[cm]?js(\?.*)?$/i;
|
|
14
|
-
const PLUGIN_NAME =
|
|
17
|
+
const PLUGIN_NAME = 'JsMinifyPlugin';
|
|
15
18
|
class JsMinifyPlugin {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
name: PLUGIN_NAME,
|
|
34
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
35
|
-
additionalAssets: true
|
|
36
|
-
},
|
|
37
|
-
() => this.transformAssets(compilation)
|
|
38
|
-
);
|
|
39
|
-
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (stats) => {
|
|
40
|
-
stats.hooks.print.for("asset.info.minimized").tap(
|
|
41
|
-
PLUGIN_NAME,
|
|
42
|
-
(minimized, { green, formatFlag }) => minimized && green && formatFlag ? green(formatFlag("minimized")) : ""
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async transformAssets(compilation) {
|
|
48
|
-
const {
|
|
49
|
-
options: { devtool }
|
|
50
|
-
} = compilation.compiler;
|
|
51
|
-
const sourceMap = !!devtool && devtool.includes("source-map");
|
|
52
|
-
const assets = compilation.getAssets().filter((asset) => !asset.info.minimized && isJsFile.test(asset.name));
|
|
53
|
-
const { implementation, ...transformOptions } = this.options;
|
|
54
|
-
await Promise.all(
|
|
55
|
-
assets.map(async (asset) => {
|
|
56
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
57
|
-
const output = await this.transform(Buffer.isBuffer(source) ? source.toString() : source, {
|
|
58
|
-
...transformOptions,
|
|
59
|
-
minify: true,
|
|
60
|
-
sourcemap: sourceMap,
|
|
61
|
-
sourcefile: asset.name
|
|
19
|
+
apply(compiler) {
|
|
20
|
+
const { implementation, ...transformOptions } = this.options;
|
|
21
|
+
const meta = JSON.stringify({
|
|
22
|
+
name: PLUGIN_NAME,
|
|
23
|
+
version: "1.7.6",
|
|
24
|
+
options: transformOptions
|
|
25
|
+
});
|
|
26
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
27
|
+
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash)=>hash.update(meta));
|
|
28
|
+
compilation.hooks.processAssets.tapPromise({
|
|
29
|
+
name: PLUGIN_NAME,
|
|
30
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
31
|
+
additionalAssets: true
|
|
32
|
+
}, ()=>this.transformAssets(compilation));
|
|
33
|
+
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (stats)=>{
|
|
34
|
+
stats.hooks.print.for('asset.info.minimized').tap(PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
|
|
35
|
+
});
|
|
62
36
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
}
|
|
38
|
+
async transformAssets(compilation) {
|
|
39
|
+
const { options: { devtool } } = compilation.compiler;
|
|
40
|
+
const sourceMap = !!devtool && devtool.includes('source-map');
|
|
41
|
+
const assets = compilation.getAssets().filter((asset)=>!asset.info.minimized && isJsFile.test(asset.name));
|
|
42
|
+
const { implementation, ...transformOptions } = this.options;
|
|
43
|
+
await Promise.all(assets.map(async (asset)=>{
|
|
44
|
+
const { source, map } = asset.source.sourceAndMap();
|
|
45
|
+
const output = await this.transform(Buffer.isBuffer(source) ? source.toString() : source, {
|
|
46
|
+
...transformOptions,
|
|
47
|
+
minify: true,
|
|
48
|
+
sourcemap: sourceMap,
|
|
49
|
+
sourcefile: asset.name
|
|
50
|
+
});
|
|
51
|
+
let newMap;
|
|
52
|
+
if (output.map) {
|
|
53
|
+
newMap = JSON.parse(output.map);
|
|
54
|
+
newMap.sources = [
|
|
55
|
+
asset.name
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
const newSource = sourceMap && newMap ? new SourceMapSource(output.code, asset.name, newMap, source, map, true) : new RawSource(output.code);
|
|
59
|
+
const newInfo = {
|
|
60
|
+
...asset.info,
|
|
61
|
+
minimized: true
|
|
62
|
+
};
|
|
63
|
+
compilation.updateAsset(asset.name, newSource, newInfo);
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
constructor(options = {}){
|
|
67
|
+
_define_property(this, "options", {});
|
|
68
|
+
_define_property(this, "transform", void 0);
|
|
69
|
+
const { implementation } = options;
|
|
70
|
+
this.transform = (null == implementation ? void 0 : implementation.transform) ?? __WEBPACK_EXTERNAL_MODULE_esbuild__.transform;
|
|
71
|
+
this.options = options;
|
|
72
|
+
}
|
|
74
73
|
}
|
|
75
|
-
export {
|
|
76
|
-
JsMinifyPlugin
|
|
77
|
-
};
|
|
74
|
+
export { JsMinifyPlugin };
|
package/dist/colors.cjs
CHANGED
|
@@ -1,60 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
14
|
+
};
|
|
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
|
+
});
|
|
22
|
+
};
|
|
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
|
+
default: ()=>colors_rslib_entry_
|
|
31
43
|
});
|
|
32
|
-
|
|
33
|
-
var
|
|
44
|
+
const external_picocolors_namespaceObject = require("picocolors");
|
|
45
|
+
var external_picocolors_default = /*#__PURE__*/ __webpack_require__.n(external_picocolors_namespaceObject);
|
|
34
46
|
const colors = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
...external_picocolors_default(),
|
|
48
|
+
rainbow: (input)=>{
|
|
49
|
+
const startColor = [
|
|
50
|
+
48,
|
|
51
|
+
112,
|
|
52
|
+
198
|
|
53
|
+
];
|
|
54
|
+
const endColor = [
|
|
55
|
+
97,
|
|
56
|
+
193,
|
|
57
|
+
198
|
|
58
|
+
];
|
|
59
|
+
const isWord = (char)=>!/[\s\n]/.test(char);
|
|
60
|
+
const chars = [
|
|
61
|
+
...input
|
|
62
|
+
];
|
|
63
|
+
const steps = chars.filter(isWord).length;
|
|
64
|
+
let r = startColor[0];
|
|
65
|
+
let g = startColor[1];
|
|
66
|
+
let b = startColor[2];
|
|
67
|
+
const rStep = (endColor[0] - r) / steps;
|
|
68
|
+
const gStep = (endColor[1] - g) / steps;
|
|
69
|
+
const bStep = (endColor[2] - b) / steps;
|
|
70
|
+
let output = '';
|
|
71
|
+
for (const char of chars){
|
|
72
|
+
if (isWord(char)) {
|
|
73
|
+
r += rStep;
|
|
74
|
+
g += gStep;
|
|
75
|
+
b += bStep;
|
|
76
|
+
}
|
|
77
|
+
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
78
|
+
}
|
|
79
|
+
return output;
|
|
56
80
|
}
|
|
57
|
-
return output;
|
|
58
|
-
}
|
|
59
81
|
};
|
|
60
|
-
|
|
82
|
+
const colors_rslib_entry_ = colors;
|
|
83
|
+
var __webpack_export_target__ = exports;
|
|
84
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
85
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
package/dist/colors.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
-
var getDirname = () => path.dirname(getFilename());
|
|
8
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
-
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
-
import picocolors from "picocolors";
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_picocolors__ from "picocolors";
|
|
11
4
|
const colors = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
...__WEBPACK_EXTERNAL_MODULE_picocolors__["default"],
|
|
6
|
+
rainbow: (input)=>{
|
|
7
|
+
const startColor = [
|
|
8
|
+
48,
|
|
9
|
+
112,
|
|
10
|
+
198
|
|
11
|
+
];
|
|
12
|
+
const endColor = [
|
|
13
|
+
97,
|
|
14
|
+
193,
|
|
15
|
+
198
|
|
16
|
+
];
|
|
17
|
+
const isWord = (char)=>!/[\s\n]/.test(char);
|
|
18
|
+
const chars = [
|
|
19
|
+
...input
|
|
20
|
+
];
|
|
21
|
+
const steps = chars.filter(isWord).length;
|
|
22
|
+
let r = startColor[0];
|
|
23
|
+
let g = startColor[1];
|
|
24
|
+
let b = startColor[2];
|
|
25
|
+
const rStep = (endColor[0] - r) / steps;
|
|
26
|
+
const gStep = (endColor[1] - g) / steps;
|
|
27
|
+
const bStep = (endColor[2] - b) / steps;
|
|
28
|
+
let output = '';
|
|
29
|
+
for (const char of chars){
|
|
30
|
+
if (isWord(char)) {
|
|
31
|
+
r += rStep;
|
|
32
|
+
g += gStep;
|
|
33
|
+
b += bStep;
|
|
34
|
+
}
|
|
35
|
+
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
36
|
+
}
|
|
37
|
+
return output;
|
|
33
38
|
}
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var colors_default = colors;
|
|
38
|
-
export {
|
|
39
|
-
colors_default as default
|
|
40
39
|
};
|
|
40
|
+
const colors_rslib_entry_ = colors;
|
|
41
|
+
export { colors_rslib_entry_ as default };
|
package/dist/config.cjs
CHANGED
|
@@ -1,103 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
14
|
+
};
|
|
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
|
+
});
|
|
22
|
+
};
|
|
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
|
+
defineConfig: ()=>defineConfig,
|
|
43
|
+
loadConfig: ()=>loadConfig
|
|
32
44
|
});
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
async function loadConfig({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(0, import_utils.setNodeEnv)(cliOptions?.watch ? "development" : "production");
|
|
45
|
-
} else {
|
|
46
|
-
(0, import_utils.setNodeEnv)("development");
|
|
47
|
-
(0, import_utils.setDevServer)(true);
|
|
48
|
-
}
|
|
49
|
-
const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
|
|
50
|
-
let userConfig = {};
|
|
51
|
-
if (configPath) {
|
|
52
|
-
userConfig = await (0, import_bundleRequire.bundleRequire)(configPath);
|
|
53
|
-
if (typeof userConfig === "function") {
|
|
54
|
-
const params = {
|
|
55
|
-
env: (0, import_utils.getNodeEnv)(),
|
|
56
|
-
command: process.argv[2]
|
|
57
|
-
};
|
|
58
|
-
userConfig = await userConfig(params);
|
|
59
|
-
if (userConfig === void 0) {
|
|
60
|
-
throw new Error("Unpack config function must return a config object.");
|
|
61
|
-
}
|
|
45
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
46
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
47
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
48
|
+
const external_jiti_namespaceObject = require("jiti");
|
|
49
|
+
const external_logger_cjs_namespaceObject = require("./logger.cjs");
|
|
50
|
+
const external_utils_cjs_namespaceObject = require("./utils.cjs");
|
|
51
|
+
async function loadConfig({ cliOptions, command }) {
|
|
52
|
+
if ('build' === command) (0, external_utils_cjs_namespaceObject.setNodeEnv)((null == cliOptions ? void 0 : cliOptions.watch) ? 'development' : 'production');
|
|
53
|
+
else {
|
|
54
|
+
(0, external_utils_cjs_namespaceObject.setNodeEnv)('development');
|
|
55
|
+
(0, external_utils_cjs_namespaceObject.setDevServer)(true);
|
|
62
56
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
const configPath = resolveConfigPath(process.cwd(), null == cliOptions ? void 0 : cliOptions.config);
|
|
58
|
+
let userConfig = {};
|
|
59
|
+
if (configPath) {
|
|
60
|
+
const jiti = (0, external_jiti_namespaceObject.createJiti)(__filename, {
|
|
61
|
+
moduleCache: false,
|
|
62
|
+
interopDefault: true
|
|
63
|
+
});
|
|
64
|
+
userConfig = await jiti.import(configPath, {
|
|
65
|
+
default: true
|
|
66
|
+
});
|
|
67
|
+
if ('function' == typeof userConfig) {
|
|
68
|
+
const params = {
|
|
69
|
+
env: (0, external_utils_cjs_namespaceObject.getNodeEnv)(),
|
|
70
|
+
command: process.argv[2]
|
|
71
|
+
};
|
|
72
|
+
userConfig = await userConfig(params);
|
|
73
|
+
if (void 0 === userConfig) throw new Error('Unpack config function must return a config object.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (null == cliOptions ? void 0 : cliOptions.port) (0, external_utils_cjs_namespaceObject.setValueByPath)(userConfig, [
|
|
77
|
+
'server',
|
|
78
|
+
'port'
|
|
79
|
+
], cliOptions.port);
|
|
80
|
+
if (null == cliOptions ? void 0 : cliOptions.open) (0, external_utils_cjs_namespaceObject.setValueByPath)(userConfig, [
|
|
81
|
+
'server',
|
|
82
|
+
'open'
|
|
83
|
+
], cliOptions.open);
|
|
84
|
+
if (null == cliOptions ? void 0 : cliOptions.analyze) (0, external_utils_cjs_namespaceObject.setValueByPath)(userConfig, [
|
|
85
|
+
'performance',
|
|
86
|
+
'bundleAnalyze'
|
|
87
|
+
], cliOptions.analyze);
|
|
88
|
+
return userConfig;
|
|
71
89
|
}
|
|
72
90
|
function defineConfig(config) {
|
|
73
|
-
|
|
91
|
+
return config;
|
|
74
92
|
}
|
|
75
93
|
function resolveConfigPath(root, customConfig) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (customConfig) {
|
|
95
|
+
const customConfigPath = (0, external_node_path_namespaceObject.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_namespaceObject.join)(root, customConfig);
|
|
96
|
+
if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
|
|
97
|
+
external_logger_cjs_namespaceObject.logger.warn(`Could not find config file: ${customConfigPath}`);
|
|
80
98
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const configFile = (0, import_node_path.join)(root, file);
|
|
93
|
-
if (import_node_fs.default.existsSync(configFile)) {
|
|
94
|
-
return configFile;
|
|
99
|
+
const CONFIG_FILES = [
|
|
100
|
+
'unpack.config.ts',
|
|
101
|
+
'unpack.config.js',
|
|
102
|
+
'unpack.config.mjs',
|
|
103
|
+
'unpack.config.cjs',
|
|
104
|
+
'unpack.config.mts',
|
|
105
|
+
'unpack.config.cts'
|
|
106
|
+
];
|
|
107
|
+
for (const file of CONFIG_FILES){
|
|
108
|
+
const configFile = (0, external_node_path_namespaceObject.join)(root, file);
|
|
109
|
+
if (external_node_fs_default().existsSync(configFile)) return configFile;
|
|
95
110
|
}
|
|
96
|
-
|
|
97
|
-
return null;
|
|
111
|
+
return null;
|
|
98
112
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
var __webpack_export_target__ = exports;
|
|
114
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
115
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
116
|
+
value: true
|
|
103
117
|
});
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CliOptions, Command, NodeEnv, UnpackConfig } from '
|
|
1
|
+
import type { CliOptions, Command, NodeEnv, UnpackConfig } from 'src/types/index';
|
|
2
2
|
export declare function loadConfig({ cliOptions, command, }: {
|
|
3
3
|
cliOptions?: CliOptions;
|
|
4
4
|
command: Command;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAIjF,wBAAsB,UAAU,CAAC,EAC/B,UAAU,EACV,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiCxB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AACjF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,YAAY,CAAA;AACvE,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;AACxF,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAAA;AAChE,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAAA;AAC9E,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA"}
|