@unpackjs/core 2.4.1 → 2.4.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/dist/index.cjs +2028 -196
- package/dist/index.js +1876 -39
- package/dist/lightningcssLoader.mjs +18 -0
- package/dist/typedCssModulesLoader.mjs +139 -0
- package/{dist → dist-types}/bundler-config/cache.d.ts +1 -1
- package/dist-types/bundler-config/cache.d.ts.map +1 -0
- package/{dist → dist-types}/bundler-config/chunkSplit.d.ts +1 -1
- package/dist-types/bundler-config/chunkSplit.d.ts.map +1 -0
- package/{dist → dist-types}/bundler-config/css.d.ts +1 -1
- package/dist-types/bundler-config/css.d.ts.map +1 -0
- package/{dist → dist-types}/bundler-config/experimentCss.d.ts +1 -1
- package/dist-types/bundler-config/experimentCss.d.ts.map +1 -0
- package/{dist → dist-types}/bundler-config/index.d.ts +1 -1
- package/dist-types/bundler-config/index.d.ts.map +1 -0
- package/{dist/lightningcss/loader.d.ts → dist-types/bundler-config/loaders/lightningcssLoader.d.ts} +2 -2
- package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts.map +1 -0
- package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts +6 -0
- package/dist-types/bundler-config/loaders/typedCssModulesLoader.d.ts.map +1 -0
- package/{dist/bundler-config → dist-types/bundler-config/plugins}/jsMinify.d.ts +1 -1
- package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +1 -0
- package/{dist/lightningcss/minimizer.d.ts → dist-types/bundler-config/plugins/lightningcssMinify.d.ts} +2 -3
- package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts.map +1 -0
- package/{dist/bundler-config/oxlint/plugin.d.ts → dist-types/bundler-config/plugins/oxlint/index.d.ts} +1 -1
- package/dist-types/bundler-config/plugins/oxlint/index.d.ts.map +1 -0
- package/dist-types/bundler-config/plugins/progress/helpers.d.ts.map +1 -0
- package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/rspack.d.ts +1 -1
- package/dist-types/bundler-config/plugins/progress/rspack.d.ts.map +1 -0
- package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/webpack.d.ts +1 -1
- package/dist-types/bundler-config/plugins/progress/webpack.d.ts.map +1 -0
- package/{dist/typed-css-modules/plugin.d.ts → dist-types/bundler-config/plugins/typedCssModules.d.ts} +2 -2
- package/dist-types/bundler-config/plugins/typedCssModules.d.ts.map +1 -0
- package/{dist → dist-types}/config.d.ts +1 -1
- package/dist-types/config.d.ts.map +1 -0
- package/{dist → dist-types}/createUnpack.d.ts +1 -1
- package/{dist → dist-types}/createUnpack.d.ts.map +1 -1
- package/{dist → dist-types}/index.d.ts +1 -1
- package/{dist → dist-types}/index.d.ts.map +1 -1
- package/dist-types/logger.d.ts +3 -0
- package/{dist → dist-types}/logger.d.ts.map +1 -1
- package/{dist → dist-types}/plugin.d.ts +1 -1
- package/{dist → dist-types}/plugin.d.ts.map +1 -1
- package/dist-types/run/build.d.ts +3 -0
- package/{dist → dist-types}/run/build.d.ts.map +1 -1
- package/{dist → dist-types}/run/dev.d.ts +1 -1
- package/{dist → dist-types}/run/dev.d.ts.map +1 -1
- package/{dist → dist-types}/types/config.d.ts +1 -1
- package/{dist → dist-types}/types/config.d.ts.map +1 -1
- package/{dist → dist-types}/types/index.d.ts +1 -0
- package/{dist → dist-types}/types/index.d.ts.map +1 -1
- package/{dist → dist-types}/utils.d.ts +5 -1
- package/dist-types/utils.d.ts.map +1 -0
- package/package.json +6 -37
- package/dist/bundler-config/cache.cjs +0 -114
- package/dist/bundler-config/cache.d.ts.map +0 -1
- package/dist/bundler-config/cache.js +0 -72
- package/dist/bundler-config/chunkSplit.cjs +0 -192
- package/dist/bundler-config/chunkSplit.d.ts.map +0 -1
- package/dist/bundler-config/chunkSplit.js +0 -150
- package/dist/bundler-config/css.cjs +0 -189
- package/dist/bundler-config/css.d.ts.map +0 -1
- package/dist/bundler-config/css.js +0 -149
- package/dist/bundler-config/experimentCss.cjs +0 -214
- package/dist/bundler-config/experimentCss.d.ts.map +0 -1
- package/dist/bundler-config/experimentCss.js +0 -175
- package/dist/bundler-config/helpers.cjs +0 -77
- package/dist/bundler-config/helpers.js +0 -31
- package/dist/bundler-config/index.cjs +0 -309
- package/dist/bundler-config/index.d.ts.map +0 -1
- package/dist/bundler-config/index.js +0 -262
- package/dist/bundler-config/jsMinify.cjs +0 -113
- package/dist/bundler-config/jsMinify.d.ts.map +0 -1
- package/dist/bundler-config/jsMinify.js +0 -71
- package/dist/bundler-config/oxlint/plugin.cjs +0 -143
- package/dist/bundler-config/oxlint/plugin.d.ts.map +0 -1
- package/dist/bundler-config/oxlint/plugin.js +0 -104
- package/dist/bundler-config/progress/helpers.cjs +0 -126
- package/dist/bundler-config/progress/helpers.d.ts.map +0 -1
- package/dist/bundler-config/progress/helpers.js +0 -81
- package/dist/bundler-config/progress/rspack.cjs +0 -70
- package/dist/bundler-config/progress/rspack.d.ts.map +0 -1
- package/dist/bundler-config/progress/rspack.js +0 -38
- package/dist/bundler-config/progress/webpack.cjs +0 -87
- package/dist/bundler-config/progress/webpack.d.ts.map +0 -1
- package/dist/bundler-config/progress/webpack.js +0 -45
- package/dist/colors.cjs +0 -82
- package/dist/colors.js +0 -40
- package/dist/config.cjs +0 -148
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -101
- package/dist/constants.cjs +0 -122
- package/dist/constants.js +0 -51
- package/dist/createUnpack.cjs +0 -107
- package/dist/createUnpack.js +0 -75
- package/dist/fs.cjs +0 -91
- package/dist/fs.js +0 -34
- package/dist/global.cjs +0 -36
- package/dist/global.js +0 -4
- package/dist/lightningcss/loader.cjs +0 -57
- package/dist/lightningcss/loader.d.ts.map +0 -1
- package/dist/lightningcss/loader.js +0 -25
- package/dist/lightningcss/minimizer.cjs +0 -94
- package/dist/lightningcss/minimizer.d.ts.map +0 -1
- package/dist/lightningcss/minimizer.js +0 -59
- package/dist/loadEnv.cjs +0 -122
- package/dist/loadEnv.js +0 -80
- package/dist/loadingAnimation.cjs +0 -76
- package/dist/loadingAnimation.js +0 -44
- package/dist/logger.cjs +0 -116
- package/dist/logger.d.ts +0 -3
- package/dist/logger.js +0 -74
- package/dist/openBrowser.cjs +0 -89
- package/dist/openBrowser.js +0 -49
- package/dist/plugin.cjs +0 -42
- package/dist/plugin.js +0 -10
- package/dist/prebundleDeps.cjs +0 -349
- package/dist/prebundleDeps.js +0 -303
- package/dist/progressBar.cjs +0 -66
- package/dist/progressBar.js +0 -34
- package/dist/reporter.cjs +0 -164
- package/dist/reporter.js +0 -120
- package/dist/run/build.cjs +0 -68
- package/dist/run/build.d.ts +0 -3
- package/dist/run/build.js +0 -26
- package/dist/run/dev.cjs +0 -118
- package/dist/run/dev.js +0 -75
- package/dist/run/index.cjs +0 -69
- package/dist/run/index.js +0 -4
- package/dist/typed-css-modules/loader.cjs +0 -141
- package/dist/typed-css-modules/loader.d.ts +0 -8
- package/dist/typed-css-modules/loader.d.ts.map +0 -1
- package/dist/typed-css-modules/loader.js +0 -92
- package/dist/typed-css-modules/plugin.cjs +0 -118
- package/dist/typed-css-modules/plugin.d.ts.map +0 -1
- package/dist/typed-css-modules/plugin.js +0 -75
- package/dist/typed-css-modules/utils.cjs +0 -46
- package/dist/typed-css-modules/utils.d.ts +0 -6
- package/dist/typed-css-modules/utils.d.ts.map +0 -1
- package/dist/typed-css-modules/utils.js +0 -14
- package/dist/types/chunkSplit.cjs +0 -18
- package/dist/types/chunkSplit.js +0 -2
- package/dist/types/config.cjs +0 -18
- package/dist/types/config.js +0 -2
- package/dist/types/index.cjs +0 -96
- package/dist/types/index.js +0 -7
- package/dist/types/lightningcss.cjs +0 -18
- package/dist/types/lightningcss.js +0 -2
- package/dist/types/logger.cjs +0 -45
- package/dist/types/logger.js +0 -13
- package/dist/types/oxc.cjs +0 -18
- package/dist/types/oxc.js +0 -2
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.js +0 -2
- package/dist/utils.cjs +0 -346
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -204
- package/dist/watchFiles.cjs +0 -69
- package/dist/watchFiles.js +0 -27
- /package/dist/{bundler-config/oxlint/.oxlintrc.json → .oxlintrc.json} +0 -0
- /package/{dist → dist-types}/bundler-config/helpers.d.ts +0 -0
- /package/{dist → dist-types}/bundler-config/helpers.d.ts.map +0 -0
- /package/{dist/bundler-config → dist-types/bundler-config/plugins}/progress/helpers.d.ts +0 -0
- /package/{dist → dist-types}/colors.d.ts +0 -0
- /package/{dist → dist-types}/colors.d.ts.map +0 -0
- /package/{dist → dist-types}/constants.d.ts +0 -0
- /package/{dist → dist-types}/constants.d.ts.map +0 -0
- /package/{dist → dist-types}/fs.d.ts +0 -0
- /package/{dist → dist-types}/fs.d.ts.map +0 -0
- /package/{dist → dist-types}/global.d.ts +0 -0
- /package/{dist → dist-types}/global.d.ts.map +0 -0
- /package/{dist → dist-types}/loadEnv.d.ts +0 -0
- /package/{dist → dist-types}/loadEnv.d.ts.map +0 -0
- /package/{dist → dist-types}/loadingAnimation.d.ts +0 -0
- /package/{dist → dist-types}/loadingAnimation.d.ts.map +0 -0
- /package/{dist → dist-types}/openBrowser.d.ts +0 -0
- /package/{dist → dist-types}/openBrowser.d.ts.map +0 -0
- /package/{dist → dist-types}/prebundleDeps.d.ts +0 -0
- /package/{dist → dist-types}/prebundleDeps.d.ts.map +0 -0
- /package/{dist → dist-types}/progressBar.d.ts +0 -0
- /package/{dist → dist-types}/progressBar.d.ts.map +0 -0
- /package/{dist → dist-types}/reporter.d.ts +0 -0
- /package/{dist → dist-types}/reporter.d.ts.map +0 -0
- /package/{dist → dist-types}/run/index.d.ts +0 -0
- /package/{dist → dist-types}/run/index.d.ts.map +0 -0
- /package/{dist → dist-types}/types/chunkSplit.d.ts +0 -0
- /package/{dist → dist-types}/types/chunkSplit.d.ts.map +0 -0
- /package/{dist → dist-types}/types/lightningcss.d.ts +0 -0
- /package/{dist → dist-types}/types/lightningcss.d.ts.map +0 -0
- /package/{dist → dist-types}/types/logger.d.ts +0 -0
- /package/{dist → dist-types}/types/logger.d.ts.map +0 -0
- /package/{dist → dist-types}/types/oxc.d.ts +0 -0
- /package/{dist → dist-types}/types/oxc.d.ts.map +0 -0
- /package/{dist → dist-types}/types/plugin.d.ts +0 -0
- /package/{dist → dist-types}/types/plugin.d.ts.map +0 -0
- /package/{dist → dist-types}/watchFiles.d.ts +0 -0
- /package/{dist → dist-types}/watchFiles.d.ts.map +0 -0
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
applyCacheConfig: ()=>applyCacheConfig
|
|
37
|
-
});
|
|
38
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
39
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
40
|
-
const external_config_cjs_namespaceObject = require("../config.cjs");
|
|
41
|
-
const external_fs_cjs_namespaceObject = require("../fs.cjs");
|
|
42
|
-
const external_logger_cjs_namespaceObject = require("../logger.cjs");
|
|
43
|
-
const external_utils_cjs_namespaceObject = require("../utils.cjs");
|
|
44
|
-
async function getBuildDependencies(root, userBuildDependencies, envFilePaths) {
|
|
45
|
-
const rootPackageJson = external_node_path_default().join(root, 'package.json');
|
|
46
|
-
const browserslistConfig = external_node_path_default().join(root, '.browserslistrc');
|
|
47
|
-
const tsconfigPath = external_node_path_default().join(root, 'tsconfig.json');
|
|
48
|
-
const buildDependencies = {};
|
|
49
|
-
if (await (0, external_fs_cjs_namespaceObject.isFileExists)(rootPackageJson)) buildDependencies.packageJson = [
|
|
50
|
-
rootPackageJson
|
|
51
|
-
];
|
|
52
|
-
if (await (0, external_fs_cjs_namespaceObject.isFileExists)(tsconfigPath)) buildDependencies.tsconfig = [
|
|
53
|
-
tsconfigPath
|
|
54
|
-
];
|
|
55
|
-
buildDependencies.unpackConfig = [
|
|
56
|
-
(0, external_config_cjs_namespaceObject.resolveConfigPath)(root)
|
|
57
|
-
];
|
|
58
|
-
if (await (0, external_fs_cjs_namespaceObject.isFileExists)(browserslistConfig)) buildDependencies.browserslistrc = [
|
|
59
|
-
browserslistConfig
|
|
60
|
-
];
|
|
61
|
-
const tailwindExts = [
|
|
62
|
-
'ts',
|
|
63
|
-
'js',
|
|
64
|
-
'cjs',
|
|
65
|
-
'mjs'
|
|
66
|
-
];
|
|
67
|
-
const configs = tailwindExts.map((ext)=>external_node_path_default().join(root, `tailwind.config.${ext}`));
|
|
68
|
-
const tailwindConfig = (0, external_fs_cjs_namespaceObject.findExists)(configs);
|
|
69
|
-
if (tailwindConfig) buildDependencies.tailwindcss = [
|
|
70
|
-
tailwindConfig
|
|
71
|
-
];
|
|
72
|
-
if (envFilePaths && envFilePaths.length > 0) buildDependencies.envFiles = envFilePaths;
|
|
73
|
-
return {
|
|
74
|
-
...buildDependencies,
|
|
75
|
-
userBuildDependencies
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
|
|
79
|
-
var _unpackConfig_build, _unpackConfig_dev;
|
|
80
|
-
if (!(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.cache) || (0, external_utils_cjs_namespaceObject.isDevServer)() && (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation)) return config;
|
|
81
|
-
const cacheConfig = (0, external_utils_cjs_namespaceObject.isPlainObject)(unpackConfig.build.cache) ? unpackConfig.build.cache : {};
|
|
82
|
-
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
83
|
-
const buildDependencies = await getBuildDependencies(unpackConfig.root, cacheConfig.buildDependencies || [], envFilePaths);
|
|
84
|
-
let cacheDirectory = cacheConfig.cacheDirectory;
|
|
85
|
-
if (cacheDirectory) cacheDirectory = external_node_path_default().isAbsolute(cacheDirectory) ? cacheDirectory : external_node_path_default().join(unpackConfig.root, cacheDirectory);
|
|
86
|
-
external_logger_cjs_namespaceObject.logger.info('persistent cache enabled');
|
|
87
|
-
config = isRspack ? (0, external_utils_cjs_namespaceObject.mergeConfig)(config, {
|
|
88
|
-
cache: true,
|
|
89
|
-
experiments: {
|
|
90
|
-
cache: {
|
|
91
|
-
type: 'persistent',
|
|
92
|
-
buildDependencies: Object.values(buildDependencies).flat(),
|
|
93
|
-
storage: {
|
|
94
|
-
type: 'filesystem',
|
|
95
|
-
directory: cacheDirectory
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}) : (0, external_utils_cjs_namespaceObject.mergeConfig)(config, {
|
|
100
|
-
cache: {
|
|
101
|
-
type: 'filesystem',
|
|
102
|
-
buildDependencies,
|
|
103
|
-
cacheDirectory
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
return config;
|
|
107
|
-
}
|
|
108
|
-
exports.applyCacheConfig = __webpack_exports__.applyCacheConfig;
|
|
109
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
110
|
-
"applyCacheConfig"
|
|
111
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
112
|
-
Object.defineProperty(exports, '__esModule', {
|
|
113
|
-
value: true
|
|
114
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/bundler-config/cache.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA6CzE,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,YAAY,EACZ,YAAY,GACb,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0ChC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import 'module';
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import node_path from "node:path";
|
|
4
|
-
import { resolveConfigPath } from "../config.js";
|
|
5
|
-
import { findExists, isFileExists } from "../fs.js";
|
|
6
|
-
import { logger } from "../logger.js";
|
|
7
|
-
import { isDevServer, isPlainObject, mergeConfig } from "../utils.js";
|
|
8
|
-
async function getBuildDependencies(root, userBuildDependencies, envFilePaths) {
|
|
9
|
-
const rootPackageJson = node_path.join(root, 'package.json');
|
|
10
|
-
const browserslistConfig = node_path.join(root, '.browserslistrc');
|
|
11
|
-
const tsconfigPath = node_path.join(root, 'tsconfig.json');
|
|
12
|
-
const buildDependencies = {};
|
|
13
|
-
if (await isFileExists(rootPackageJson)) buildDependencies.packageJson = [
|
|
14
|
-
rootPackageJson
|
|
15
|
-
];
|
|
16
|
-
if (await isFileExists(tsconfigPath)) buildDependencies.tsconfig = [
|
|
17
|
-
tsconfigPath
|
|
18
|
-
];
|
|
19
|
-
buildDependencies.unpackConfig = [
|
|
20
|
-
resolveConfigPath(root)
|
|
21
|
-
];
|
|
22
|
-
if (await isFileExists(browserslistConfig)) buildDependencies.browserslistrc = [
|
|
23
|
-
browserslistConfig
|
|
24
|
-
];
|
|
25
|
-
const tailwindExts = [
|
|
26
|
-
'ts',
|
|
27
|
-
'js',
|
|
28
|
-
'cjs',
|
|
29
|
-
'mjs'
|
|
30
|
-
];
|
|
31
|
-
const configs = tailwindExts.map((ext)=>node_path.join(root, `tailwind.config.${ext}`));
|
|
32
|
-
const tailwindConfig = findExists(configs);
|
|
33
|
-
if (tailwindConfig) buildDependencies.tailwindcss = [
|
|
34
|
-
tailwindConfig
|
|
35
|
-
];
|
|
36
|
-
if (envFilePaths && envFilePaths.length > 0) buildDependencies.envFiles = envFilePaths;
|
|
37
|
-
return {
|
|
38
|
-
...buildDependencies,
|
|
39
|
-
userBuildDependencies
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
|
|
43
|
-
var _unpackConfig_build, _unpackConfig_dev;
|
|
44
|
-
if (!(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.cache) || isDevServer() && (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation)) return config;
|
|
45
|
-
const cacheConfig = isPlainObject(unpackConfig.build.cache) ? unpackConfig.build.cache : {};
|
|
46
|
-
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
47
|
-
const buildDependencies = await getBuildDependencies(unpackConfig.root, cacheConfig.buildDependencies || [], envFilePaths);
|
|
48
|
-
let cacheDirectory = cacheConfig.cacheDirectory;
|
|
49
|
-
if (cacheDirectory) cacheDirectory = node_path.isAbsolute(cacheDirectory) ? cacheDirectory : node_path.join(unpackConfig.root, cacheDirectory);
|
|
50
|
-
logger.info('persistent cache enabled');
|
|
51
|
-
config = isRspack ? mergeConfig(config, {
|
|
52
|
-
cache: true,
|
|
53
|
-
experiments: {
|
|
54
|
-
cache: {
|
|
55
|
-
type: 'persistent',
|
|
56
|
-
buildDependencies: Object.values(buildDependencies).flat(),
|
|
57
|
-
storage: {
|
|
58
|
-
type: 'filesystem',
|
|
59
|
-
directory: cacheDirectory
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}) : mergeConfig(config, {
|
|
64
|
-
cache: {
|
|
65
|
-
type: 'filesystem',
|
|
66
|
-
buildDependencies,
|
|
67
|
-
cacheDirectory
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return config;
|
|
71
|
-
}
|
|
72
|
-
export { applyCacheConfig };
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
applyChunkSplitConfig: ()=>applyChunkSplitConfig
|
|
37
|
-
});
|
|
38
|
-
const external_node_assert_namespaceObject = require("node:assert");
|
|
39
|
-
var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
|
|
40
|
-
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
41
|
-
const external_utils_cjs_namespaceObject = require("../utils.cjs");
|
|
42
|
-
function getForceSplittingGroups(forceSplitting, strategy) {
|
|
43
|
-
const cacheGroups = {};
|
|
44
|
-
const pairs = Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index)=>[
|
|
45
|
-
`force-split-${index}`,
|
|
46
|
-
regexp
|
|
47
|
-
]) : Object.entries(forceSplitting);
|
|
48
|
-
for (const [key, regexp] of pairs)cacheGroups[key] = {
|
|
49
|
-
test: regexp,
|
|
50
|
-
name: key,
|
|
51
|
-
chunks: 'all',
|
|
52
|
-
priority: 'single-vendor' === strategy ? 1 : 0,
|
|
53
|
-
enforce: true
|
|
54
|
-
};
|
|
55
|
-
return cacheGroups;
|
|
56
|
-
}
|
|
57
|
-
function splitByExperience(ctx) {
|
|
58
|
-
const { defaultConfig, forceSplittingGroups } = ctx;
|
|
59
|
-
const experienceCacheGroup = {};
|
|
60
|
-
const packageRegExps = {
|
|
61
|
-
axios: /node_modules[\\/]axios(-.+)?[\\/]/,
|
|
62
|
-
polyfill: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/
|
|
63
|
-
};
|
|
64
|
-
for (const [name, test] of Object.entries(packageRegExps)){
|
|
65
|
-
const key = `lib-${name}`;
|
|
66
|
-
experienceCacheGroup[key] = {
|
|
67
|
-
test,
|
|
68
|
-
priority: 0,
|
|
69
|
-
name: key
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
...defaultConfig,
|
|
74
|
-
cacheGroups: {
|
|
75
|
-
...defaultConfig.cacheGroups,
|
|
76
|
-
...experienceCacheGroup,
|
|
77
|
-
...forceSplittingGroups
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function splitBySize(ctx) {
|
|
82
|
-
const { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
|
|
83
|
-
external_node_assert_default()('split-by-size' === chunkSplit.strategy);
|
|
84
|
-
return {
|
|
85
|
-
...defaultConfig,
|
|
86
|
-
minSize: chunkSplit.minSize ?? 0,
|
|
87
|
-
maxSize: chunkSplit.maxSize ?? Number.POSITIVE_INFINITY,
|
|
88
|
-
cacheGroups: {
|
|
89
|
-
...defaultConfig.cacheGroups,
|
|
90
|
-
...forceSplittingGroups
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
const MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
|
|
95
|
-
function getPackageNameFromModulePath(modulePath) {
|
|
96
|
-
const handleModuleContext = null == modulePath ? void 0 : modulePath.match(MODULE_PATH_REGEX);
|
|
97
|
-
if (!handleModuleContext) return;
|
|
98
|
-
const [, scope, name] = handleModuleContext;
|
|
99
|
-
const packageName = [
|
|
100
|
-
'npm',
|
|
101
|
-
(scope ?? '').replace('@', ''),
|
|
102
|
-
name
|
|
103
|
-
].filter(Boolean).join('.');
|
|
104
|
-
return packageName;
|
|
105
|
-
}
|
|
106
|
-
function splitByModule(ctx) {
|
|
107
|
-
const { forceSplittingGroups, defaultConfig } = ctx;
|
|
108
|
-
return {
|
|
109
|
-
...defaultConfig,
|
|
110
|
-
minSize: 0,
|
|
111
|
-
maxInitialRequests: Number.POSITIVE_INFINITY,
|
|
112
|
-
cacheGroups: {
|
|
113
|
-
...defaultConfig.cacheGroups,
|
|
114
|
-
...forceSplittingGroups,
|
|
115
|
-
vendors: {
|
|
116
|
-
priority: -9,
|
|
117
|
-
test: external_constants_cjs_namespaceObject.NODE_MODULES_REGEX,
|
|
118
|
-
name (module) {
|
|
119
|
-
return module ? getPackageNameFromModulePath(module.context) : void 0;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function splitCustom(ctx) {
|
|
126
|
-
const { forceSplittingGroups, defaultConfig } = ctx;
|
|
127
|
-
return {
|
|
128
|
-
...defaultConfig,
|
|
129
|
-
cacheGroups: {
|
|
130
|
-
...defaultConfig.cacheGroups,
|
|
131
|
-
...forceSplittingGroups
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function allInOne(_ctx) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
function singleVendor(ctx) {
|
|
139
|
-
const { defaultConfig, forceSplittingGroups } = ctx;
|
|
140
|
-
const singleVendorCacheGroup = {
|
|
141
|
-
singleVendor: {
|
|
142
|
-
test: external_constants_cjs_namespaceObject.NODE_MODULES_REGEX,
|
|
143
|
-
priority: 0,
|
|
144
|
-
chunks: 'all',
|
|
145
|
-
name: 'vendor',
|
|
146
|
-
enforce: true
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
...defaultConfig,
|
|
151
|
-
cacheGroups: {
|
|
152
|
-
...defaultConfig.cacheGroups,
|
|
153
|
-
...singleVendorCacheGroup,
|
|
154
|
-
...forceSplittingGroups
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
const SPLIT_STRATEGY_DISPATCHER = {
|
|
159
|
-
'split-by-experience': splitByExperience,
|
|
160
|
-
'split-by-module': splitByModule,
|
|
161
|
-
'split-by-size': splitBySize,
|
|
162
|
-
custom: splitCustom,
|
|
163
|
-
'all-in-one': allInOne,
|
|
164
|
-
'single-vendor': singleVendor
|
|
165
|
-
};
|
|
166
|
-
const applyChunkSplitConfig = ({ config, unpackConfig })=>{
|
|
167
|
-
const { chunkSplit } = unpackConfig.performance || {};
|
|
168
|
-
if (null == chunkSplit ? void 0 : chunkSplit.strategy) {
|
|
169
|
-
let forceSplittingGroups = {};
|
|
170
|
-
if (null == chunkSplit ? void 0 : chunkSplit.forceSplitting) forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting, chunkSplit.strategy);
|
|
171
|
-
const defaultConfig = {
|
|
172
|
-
chunks: 'all'
|
|
173
|
-
};
|
|
174
|
-
const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
|
|
175
|
-
defaultConfig,
|
|
176
|
-
forceSplittingGroups,
|
|
177
|
-
chunkSplit
|
|
178
|
-
});
|
|
179
|
-
(0, external_utils_cjs_namespaceObject.setValueByPath)(config, [
|
|
180
|
-
'optimization',
|
|
181
|
-
'splitChunks'
|
|
182
|
-
], splitChunksOptions);
|
|
183
|
-
}
|
|
184
|
-
return config;
|
|
185
|
-
};
|
|
186
|
-
exports.applyChunkSplitConfig = __webpack_exports__.applyChunkSplitConfig;
|
|
187
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
188
|
-
"applyChunkSplitConfig"
|
|
189
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
190
|
-
Object.defineProperty(exports, '__esModule', {
|
|
191
|
-
value: true
|
|
192
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunkSplit.d.ts","sourceRoot":"","sources":["../../src/bundler-config/chunkSplit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAKpB,YAAY,EACb,MAAM,iBAAiB,CAAA;AA4KxB,eAAO,MAAM,qBAAqB,GAAI,2BAGnC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBAkBH,CAAA"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import 'module';
|
|
2
|
-
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import node_assert from "node:assert";
|
|
4
|
-
import { NODE_MODULES_REGEX } from "../constants.js";
|
|
5
|
-
import { setValueByPath } from "../utils.js";
|
|
6
|
-
function getForceSplittingGroups(forceSplitting, strategy) {
|
|
7
|
-
const cacheGroups = {};
|
|
8
|
-
const pairs = Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index)=>[
|
|
9
|
-
`force-split-${index}`,
|
|
10
|
-
regexp
|
|
11
|
-
]) : Object.entries(forceSplitting);
|
|
12
|
-
for (const [key, regexp] of pairs)cacheGroups[key] = {
|
|
13
|
-
test: regexp,
|
|
14
|
-
name: key,
|
|
15
|
-
chunks: 'all',
|
|
16
|
-
priority: 'single-vendor' === strategy ? 1 : 0,
|
|
17
|
-
enforce: true
|
|
18
|
-
};
|
|
19
|
-
return cacheGroups;
|
|
20
|
-
}
|
|
21
|
-
function splitByExperience(ctx) {
|
|
22
|
-
const { defaultConfig, forceSplittingGroups } = ctx;
|
|
23
|
-
const experienceCacheGroup = {};
|
|
24
|
-
const packageRegExps = {
|
|
25
|
-
axios: /node_modules[\\/]axios(-.+)?[\\/]/,
|
|
26
|
-
polyfill: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/
|
|
27
|
-
};
|
|
28
|
-
for (const [name, test] of Object.entries(packageRegExps)){
|
|
29
|
-
const key = `lib-${name}`;
|
|
30
|
-
experienceCacheGroup[key] = {
|
|
31
|
-
test,
|
|
32
|
-
priority: 0,
|
|
33
|
-
name: key
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
...defaultConfig,
|
|
38
|
-
cacheGroups: {
|
|
39
|
-
...defaultConfig.cacheGroups,
|
|
40
|
-
...experienceCacheGroup,
|
|
41
|
-
...forceSplittingGroups
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function splitBySize(ctx) {
|
|
46
|
-
const { forceSplittingGroups, defaultConfig, chunkSplit } = ctx;
|
|
47
|
-
node_assert('split-by-size' === chunkSplit.strategy);
|
|
48
|
-
return {
|
|
49
|
-
...defaultConfig,
|
|
50
|
-
minSize: chunkSplit.minSize ?? 0,
|
|
51
|
-
maxSize: chunkSplit.maxSize ?? Number.POSITIVE_INFINITY,
|
|
52
|
-
cacheGroups: {
|
|
53
|
-
...defaultConfig.cacheGroups,
|
|
54
|
-
...forceSplittingGroups
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
|
|
59
|
-
function getPackageNameFromModulePath(modulePath) {
|
|
60
|
-
const handleModuleContext = null == modulePath ? void 0 : modulePath.match(MODULE_PATH_REGEX);
|
|
61
|
-
if (!handleModuleContext) return;
|
|
62
|
-
const [, scope, name] = handleModuleContext;
|
|
63
|
-
const packageName = [
|
|
64
|
-
'npm',
|
|
65
|
-
(scope ?? '').replace('@', ''),
|
|
66
|
-
name
|
|
67
|
-
].filter(Boolean).join('.');
|
|
68
|
-
return packageName;
|
|
69
|
-
}
|
|
70
|
-
function splitByModule(ctx) {
|
|
71
|
-
const { forceSplittingGroups, defaultConfig } = ctx;
|
|
72
|
-
return {
|
|
73
|
-
...defaultConfig,
|
|
74
|
-
minSize: 0,
|
|
75
|
-
maxInitialRequests: Number.POSITIVE_INFINITY,
|
|
76
|
-
cacheGroups: {
|
|
77
|
-
...defaultConfig.cacheGroups,
|
|
78
|
-
...forceSplittingGroups,
|
|
79
|
-
vendors: {
|
|
80
|
-
priority: -9,
|
|
81
|
-
test: NODE_MODULES_REGEX,
|
|
82
|
-
name (module) {
|
|
83
|
-
return module ? getPackageNameFromModulePath(module.context) : void 0;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function splitCustom(ctx) {
|
|
90
|
-
const { forceSplittingGroups, defaultConfig } = ctx;
|
|
91
|
-
return {
|
|
92
|
-
...defaultConfig,
|
|
93
|
-
cacheGroups: {
|
|
94
|
-
...defaultConfig.cacheGroups,
|
|
95
|
-
...forceSplittingGroups
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function allInOne(_ctx) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
function singleVendor(ctx) {
|
|
103
|
-
const { defaultConfig, forceSplittingGroups } = ctx;
|
|
104
|
-
const singleVendorCacheGroup = {
|
|
105
|
-
singleVendor: {
|
|
106
|
-
test: NODE_MODULES_REGEX,
|
|
107
|
-
priority: 0,
|
|
108
|
-
chunks: 'all',
|
|
109
|
-
name: 'vendor',
|
|
110
|
-
enforce: true
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
...defaultConfig,
|
|
115
|
-
cacheGroups: {
|
|
116
|
-
...defaultConfig.cacheGroups,
|
|
117
|
-
...singleVendorCacheGroup,
|
|
118
|
-
...forceSplittingGroups
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const SPLIT_STRATEGY_DISPATCHER = {
|
|
123
|
-
'split-by-experience': splitByExperience,
|
|
124
|
-
'split-by-module': splitByModule,
|
|
125
|
-
'split-by-size': splitBySize,
|
|
126
|
-
custom: splitCustom,
|
|
127
|
-
'all-in-one': allInOne,
|
|
128
|
-
'single-vendor': singleVendor
|
|
129
|
-
};
|
|
130
|
-
const applyChunkSplitConfig = ({ config, unpackConfig })=>{
|
|
131
|
-
const { chunkSplit } = unpackConfig.performance || {};
|
|
132
|
-
if (null == chunkSplit ? void 0 : chunkSplit.strategy) {
|
|
133
|
-
let forceSplittingGroups = {};
|
|
134
|
-
if (null == chunkSplit ? void 0 : chunkSplit.forceSplitting) forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting, chunkSplit.strategy);
|
|
135
|
-
const defaultConfig = {
|
|
136
|
-
chunks: 'all'
|
|
137
|
-
};
|
|
138
|
-
const splitChunksOptions = SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy]({
|
|
139
|
-
defaultConfig,
|
|
140
|
-
forceSplittingGroups,
|
|
141
|
-
chunkSplit
|
|
142
|
-
});
|
|
143
|
-
setValueByPath(config, [
|
|
144
|
-
'optimization',
|
|
145
|
-
'splitChunks'
|
|
146
|
-
], splitChunksOptions);
|
|
147
|
-
}
|
|
148
|
-
return config;
|
|
149
|
-
};
|
|
150
|
-
export { applyChunkSplitConfig };
|