@shuvi/toolpack 1.0.63 → 2.0.0-dev.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/lib/utils/tsCheckerRspackPlugin.d.ts +4 -0
- package/lib/utils/tsCheckerRspackPlugin.js +7 -0
- package/lib/webpack/config/base.rspack.d.ts +35 -0
- package/lib/webpack/config/base.rspack.js +329 -0
- package/lib/webpack/config/browser.rspack.d.ts +3 -0
- package/lib/webpack/config/browser.rspack.js +228 -0
- package/lib/webpack/config/{browser.d.ts → browser.webpack.d.ts} +1 -1
- package/lib/webpack/config/{browser.js → browser.webpack.js} +11 -11
- package/lib/webpack/config/index.d.ts +4 -4
- package/lib/webpack/config/index.js +4 -4
- package/lib/webpack/config/index.webpack.d.ts +4 -0
- package/lib/webpack/config/index.webpack.js +20 -0
- package/lib/webpack/config/node.rspack.d.ts +2 -0
- package/lib/webpack/config/node.rspack.js +52 -0
- package/lib/webpack/config/{node.d.ts → node.webpack.d.ts} +1 -1
- package/lib/webpack/config/{node.js → node.webpack.js} +7 -7
- package/lib/webpack/config/parts/external.d.ts +1 -1
- package/lib/webpack/config/parts/helpers.rspack.d.ts +49 -0
- package/lib/webpack/config/parts/helpers.rspack.js +106 -0
- package/lib/webpack/config/parts/{helpers.d.ts → helpers.webpack.d.ts} +2 -2
- package/lib/webpack/config/parts/{style.d.ts → style.rspack.d.ts} +1 -1
- package/lib/webpack/config/parts/style.rspack.js +294 -0
- package/lib/webpack/config/parts/style.webpack.d.ts +12 -0
- package/lib/webpack/config/parts/{style.js → style.webpack.js} +2 -2
- package/lib/webpack/dynamic-dll/dep/getModuleExports.d.ts +1 -1
- package/lib/webpack/index.d.ts +5 -3
- package/lib/webpack/index.js +13 -8
- package/lib/webpack/index.webpack.d.ts +5 -0
- package/lib/webpack/index.webpack.js +29 -0
- package/lib/webpack/plugins/chunk-names-plugin.d.ts +3 -0
- package/lib/webpack/plugins/chunk-names-plugin.js +3 -0
- package/lib/webpack/plugins/copy-file-plugin.rspack.d.ts +14 -0
- package/lib/webpack/plugins/copy-file-plugin.rspack.js +88 -0
- package/lib/webpack/plugins/module-replace-plugin/dynamic-loader-options-hack.d.ts +8 -0
- package/lib/webpack/plugins/module-replace-plugin/dynamic-loader-options-hack.js +16 -0
- package/lib/webpack/plugins/module-replace-plugin/plugin.rspack.d.ts +38 -0
- package/lib/webpack/plugins/module-replace-plugin/plugin.rspack.js +224 -0
- package/lib/webpack/plugins/module-replace-plugin/stub-loader.d.ts +26 -0
- package/lib/webpack/plugins/module-replace-plugin/stub-loader.js +47 -1
- package/lib/webpack/plugins/module-replace-plugin/stub-loader.rspack.d.ts +31 -0
- package/lib/webpack/plugins/module-replace-plugin/stub-loader.rspack.js +89 -0
- package/lib/webpack/plugins/require-cache-hot-reloader-plugin.rspack.d.ts +13 -0
- package/lib/webpack/plugins/require-cache-hot-reloader-plugin.rspack.js +47 -0
- package/lib/webpack/rspack.d.ts +197 -0
- package/lib/webpack/rspack.js +192 -0
- package/lib/webpack/types.rspack.d.ts +45 -0
- package/lib/webpack/{types.d.ts → types.webpack.d.ts} +1 -1
- package/lib/webpack/types.webpack.js +2 -0
- package/lib/webpack/webpack.d.ts +1 -1
- package/lib/webpack/webpack.js +2 -2
- package/package.json +10 -5
- /package/lib/webpack/config/{base.d.ts → base.webpack.d.ts} +0 -0
- /package/lib/webpack/config/{base.js → base.webpack.js} +0 -0
- /package/lib/webpack/config/parts/{helpers.js → helpers.webpack.js} +0 -0
- /package/lib/webpack/{types.js → types.rspack.js} +0 -0
|
@@ -31,9 +31,9 @@ const crypto = __importStar(require("crypto"));
|
|
|
31
31
|
const webpack_1 = __importDefault(require("webpack"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
33
|
const resolve_1 = require("@shuvi/utils/resolve");
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
34
|
+
const base_webpack_1 = require("./base.webpack");
|
|
35
|
+
const style_webpack_1 = require("./parts/style.webpack");
|
|
36
|
+
const helpers_webpack_1 = require("./parts/helpers.webpack");
|
|
37
37
|
const BIG_LIBRARY_THRESHOLD = 160000; // byte
|
|
38
38
|
const SHUVI_PKGS_REGEX = /[\\/]node_modules[\\/](@shuvi|doura)[\\/]/;
|
|
39
39
|
const FRAMEWORK_REACT_MODULES = [
|
|
@@ -50,7 +50,7 @@ const FRAMEWORK_REACT_MODULES = [
|
|
|
50
50
|
];
|
|
51
51
|
function createBrowserWebpackChain(options) {
|
|
52
52
|
const { projectRoot, cacheDir, jsConfig, dev, publicPath } = options;
|
|
53
|
-
const chain = (0,
|
|
53
|
+
const chain = (0, base_webpack_1.baseWebpackChain)(options);
|
|
54
54
|
const useTypeScript = !!(jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.useTypeScript);
|
|
55
55
|
chain.target('web');
|
|
56
56
|
chain.devtool(dev ? 'cheap-module-source-map' : false);
|
|
@@ -107,14 +107,14 @@ function createBrowserWebpackChain(options) {
|
|
|
107
107
|
.substring(0, 8);
|
|
108
108
|
};
|
|
109
109
|
chain.optimization.splitChunks({
|
|
110
|
-
chunks:
|
|
110
|
+
chunks: helpers_webpack_1.splitChunksFilter,
|
|
111
111
|
cacheGroups: {
|
|
112
|
-
default: Object.assign({ name: getDefaultChunkName, filename: (0,
|
|
113
|
-
defaultVendors: Object.assign({ name: getDefaultChunkName, filename: (0,
|
|
112
|
+
default: Object.assign({ name: getDefaultChunkName, filename: (0, helpers_webpack_1.commonChunkFilename)({ dev: false }) }, helpers_webpack_1.defaultCacheGroups.default),
|
|
113
|
+
defaultVendors: Object.assign({ name: getDefaultChunkName, filename: (0, helpers_webpack_1.commonChunkFilename)({ dev: false }) }, helpers_webpack_1.defaultCacheGroups.defaultVendors),
|
|
114
114
|
framework: {
|
|
115
115
|
chunks: 'all',
|
|
116
116
|
name: 'framework',
|
|
117
|
-
filename: (0,
|
|
117
|
+
filename: (0, helpers_webpack_1.commonChunkFilename)({ dev: false }),
|
|
118
118
|
test(module, { moduleGraph }) {
|
|
119
119
|
const resource = module.nameForCondition();
|
|
120
120
|
if (!resource) {
|
|
@@ -154,7 +154,7 @@ function createBrowserWebpackChain(options) {
|
|
|
154
154
|
lib: {
|
|
155
155
|
test(module) {
|
|
156
156
|
return (module.size() > BIG_LIBRARY_THRESHOLD &&
|
|
157
|
-
|
|
157
|
+
helpers_webpack_1.NODE_MODULES_REGEXP.test(module.nameForCondition() || ''));
|
|
158
158
|
},
|
|
159
159
|
name(module) {
|
|
160
160
|
const hash = crypto.createHash('sha1');
|
|
@@ -169,7 +169,7 @@ function createBrowserWebpackChain(options) {
|
|
|
169
169
|
}
|
|
170
170
|
return hash.digest('hex').substring(0, 8);
|
|
171
171
|
},
|
|
172
|
-
filename: (0,
|
|
172
|
+
filename: (0, helpers_webpack_1.commonChunkFilename)({ dev: false }),
|
|
173
173
|
priority: 30,
|
|
174
174
|
minChunks: 1,
|
|
175
175
|
reuseExistingChunk: true
|
|
@@ -208,7 +208,7 @@ function createBrowserWebpackChain(options) {
|
|
|
208
208
|
// prevent errof of destructing process.env
|
|
209
209
|
'process.env': JSON.stringify('{}') })
|
|
210
210
|
]);
|
|
211
|
-
return (0,
|
|
211
|
+
return (0, style_webpack_1.withStyle)(chain, {
|
|
212
212
|
extractCss: !dev,
|
|
213
213
|
publicPath,
|
|
214
214
|
lightningCss: options.lightningCss,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './base';
|
|
2
|
-
export * from './browser';
|
|
3
|
-
export * from './node';
|
|
4
|
-
export * from './parts/helpers';
|
|
1
|
+
export * from './base.rspack';
|
|
2
|
+
export * from './browser.rspack';
|
|
3
|
+
export * from './node.rspack';
|
|
4
|
+
export * from './parts/helpers.rspack';
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base"), exports);
|
|
18
|
-
__exportStar(require("./browser"), exports);
|
|
19
|
-
__exportStar(require("./node"), exports);
|
|
20
|
-
__exportStar(require("./parts/helpers"), exports);
|
|
17
|
+
__exportStar(require("./base.rspack"), exports);
|
|
18
|
+
__exportStar(require("./browser.rspack"), exports);
|
|
19
|
+
__exportStar(require("./node.rspack"), exports);
|
|
20
|
+
__exportStar(require("./parts/helpers.rspack"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base.webpack"), exports);
|
|
18
|
+
__exportStar(require("./browser.webpack"), exports);
|
|
19
|
+
__exportStar(require("./node.webpack"), exports);
|
|
20
|
+
__exportStar(require("./parts/helpers.webpack"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodeRspackChain = createNodeRspackChain;
|
|
4
|
+
const base_rspack_1 = require("./base.rspack");
|
|
5
|
+
const external_1 = require("./parts/external");
|
|
6
|
+
const style_rspack_1 = require("./parts/style.rspack");
|
|
7
|
+
const helpers_rspack_1 = require("./parts/helpers.rspack");
|
|
8
|
+
function createNodeRspackChain(options) {
|
|
9
|
+
const { dev } = options;
|
|
10
|
+
const chain = (0, base_rspack_1.baseRspackChain)(options);
|
|
11
|
+
chain.target('node');
|
|
12
|
+
chain.devtool(dev ? 'cheap-module-source-map' : false);
|
|
13
|
+
chain.resolve.extensions.merge([
|
|
14
|
+
'.ts',
|
|
15
|
+
'.tsx',
|
|
16
|
+
'.js',
|
|
17
|
+
'.mjs',
|
|
18
|
+
'.jsx',
|
|
19
|
+
'.json',
|
|
20
|
+
'.wasm'
|
|
21
|
+
]);
|
|
22
|
+
// Rspack uses output.library for node target
|
|
23
|
+
chain.output.library({ type: 'commonjs2' });
|
|
24
|
+
chain.optimization.minimize(false);
|
|
25
|
+
/**
|
|
26
|
+
* Use splitChunks.chunks = 'all' for node/server builds in Rspack.
|
|
27
|
+
* This is the most compatible and recommended value for Rspack splitChunks.
|
|
28
|
+
*/
|
|
29
|
+
chain.optimization.splitChunks({ chunks: 'all' });
|
|
30
|
+
(0, helpers_rspack_1.addExternals)(chain, (0, external_1.nodeExternals)({
|
|
31
|
+
projectRoot: options.projectRoot,
|
|
32
|
+
include: options.include
|
|
33
|
+
}));
|
|
34
|
+
chain.module
|
|
35
|
+
.rule('main')
|
|
36
|
+
.oneOf('js')
|
|
37
|
+
.use('shuvi-swc-loader')
|
|
38
|
+
.tap(options => (Object.assign(Object.assign({}, options), { isServer: true })));
|
|
39
|
+
chain.plugin('define').tap(([options]) => [
|
|
40
|
+
Object.assign(Object.assign({}, options), { __BROWSER__: false,
|
|
41
|
+
/**
|
|
42
|
+
* swc.optimizer can't handle `typeof window` correctly for dependencies
|
|
43
|
+
*/
|
|
44
|
+
'typeof window': JSON.stringify('undefined') })
|
|
45
|
+
]);
|
|
46
|
+
return (0, style_rspack_1.withStyle)(chain, {
|
|
47
|
+
ssr: true,
|
|
48
|
+
lightningCss: options.lightningCss,
|
|
49
|
+
filename: 'static/css/[contenthash:8].css',
|
|
50
|
+
chunkFilename: 'static/css/[contenthash:8].chunk.css'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { WebpackChain, BaseOptions } from './base';
|
|
1
|
+
import { WebpackChain, BaseOptions } from './base.webpack';
|
|
2
2
|
export declare function createNodeWebpackChain(options: BaseOptions): WebpackChain;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodeWebpackChain = createNodeWebpackChain;
|
|
4
|
-
const
|
|
4
|
+
const base_webpack_1 = require("./base.webpack");
|
|
5
5
|
const external_1 = require("./parts/external");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const style_webpack_1 = require("./parts/style.webpack");
|
|
7
|
+
const helpers_webpack_1 = require("./parts/helpers.webpack");
|
|
8
8
|
function createNodeWebpackChain(options) {
|
|
9
9
|
const { dev } = options;
|
|
10
|
-
const chain = (0,
|
|
10
|
+
const chain = (0, base_webpack_1.baseWebpackChain)(options);
|
|
11
11
|
chain.target('node');
|
|
12
12
|
chain.devtool(dev ? 'cheap-module-source-map' : false);
|
|
13
13
|
chain.resolve.extensions.merge([
|
|
@@ -22,8 +22,8 @@ function createNodeWebpackChain(options) {
|
|
|
22
22
|
chain.output.libraryTarget('commonjs2');
|
|
23
23
|
chain.optimization.minimize(false);
|
|
24
24
|
// use default splitChunks config
|
|
25
|
-
chain.optimization.splitChunks((0,
|
|
26
|
-
(0,
|
|
25
|
+
chain.optimization.splitChunks((0, helpers_webpack_1.getDefaultSplitChunksConfig)(dev));
|
|
26
|
+
(0, helpers_webpack_1.addExternals)(chain, (0, external_1.nodeExternals)({
|
|
27
27
|
projectRoot: options.projectRoot,
|
|
28
28
|
include: options.include
|
|
29
29
|
}));
|
|
@@ -39,7 +39,7 @@ function createNodeWebpackChain(options) {
|
|
|
39
39
|
*/
|
|
40
40
|
'typeof window': JSON.stringify('undefined') })
|
|
41
41
|
]);
|
|
42
|
-
return (0,
|
|
42
|
+
return (0, style_webpack_1.withStyle)(chain, {
|
|
43
43
|
ssr: true,
|
|
44
44
|
lightningCss: options.lightningCss,
|
|
45
45
|
filename: 'static/css/[contenthash:8].css',
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RspackChain } from '../base.rspack';
|
|
2
|
+
import { ExternalsFunction } from '../../types.rspack';
|
|
3
|
+
export declare const checkRspackExternals: (rspackChain: RspackChain) => void;
|
|
4
|
+
export declare const addExternals: (rspackChain: RspackChain, externalFn: ExternalsFunction) => void;
|
|
5
|
+
export declare function shouldUseRelativeAssetPaths(publicPath: string): publicPath is "./";
|
|
6
|
+
export declare function splitChunksFilter(chunk: any): boolean;
|
|
7
|
+
export declare const commonChunkFilename: ({ dev }: {
|
|
8
|
+
dev: boolean;
|
|
9
|
+
}) => string;
|
|
10
|
+
export declare const NODE_MODULES_REGEXP: RegExp;
|
|
11
|
+
export declare const defaultCacheGroups: {
|
|
12
|
+
default: {
|
|
13
|
+
idHint: string;
|
|
14
|
+
reuseExistingChunk: boolean;
|
|
15
|
+
minChunks: number;
|
|
16
|
+
priority: number;
|
|
17
|
+
};
|
|
18
|
+
defaultVendors: {
|
|
19
|
+
idHint: string;
|
|
20
|
+
reuseExistingChunk: boolean;
|
|
21
|
+
test: RegExp;
|
|
22
|
+
priority: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** default splitChunks config https://github.com/webpack/webpack/blob/v5.73.0/lib/config/defaults.js#L1181 */
|
|
26
|
+
export declare const getDefaultSplitChunksConfig: (dev: boolean) => {
|
|
27
|
+
chunks: string;
|
|
28
|
+
minChunks: number;
|
|
29
|
+
minSize: number;
|
|
30
|
+
minRemainingSize: number | undefined;
|
|
31
|
+
enforceSizeThreshold: number;
|
|
32
|
+
maxAsyncRequests: number;
|
|
33
|
+
maxInitialRequests: number;
|
|
34
|
+
automaticNameDelimiter: string;
|
|
35
|
+
cacheGroups: {
|
|
36
|
+
default: {
|
|
37
|
+
idHint: string;
|
|
38
|
+
reuseExistingChunk: boolean;
|
|
39
|
+
minChunks: number;
|
|
40
|
+
priority: number;
|
|
41
|
+
};
|
|
42
|
+
defaultVendors: {
|
|
43
|
+
idHint: string;
|
|
44
|
+
reuseExistingChunk: boolean;
|
|
45
|
+
test: RegExp;
|
|
46
|
+
priority: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDefaultSplitChunksConfig = exports.defaultCacheGroups = exports.NODE_MODULES_REGEXP = exports.commonChunkFilename = exports.addExternals = exports.checkRspackExternals = void 0;
|
|
7
|
+
exports.shouldUseRelativeAssetPaths = shouldUseRelativeAssetPaths;
|
|
8
|
+
exports.splitChunksFilter = splitChunksFilter;
|
|
9
|
+
const invariant_1 = __importDefault(require("@shuvi/utils/invariant"));
|
|
10
|
+
const externalsFunctionMap = new WeakMap();
|
|
11
|
+
const checkRspackExternals = (rspackChain) => {
|
|
12
|
+
let externals = rspackChain.get('externals');
|
|
13
|
+
(0, invariant_1.default)(!externals ||
|
|
14
|
+
(typeof externals === 'function' &&
|
|
15
|
+
externals.name === 'defaultExternalsFn'), `Externals was modified directly, addExternals will have no effect.`);
|
|
16
|
+
};
|
|
17
|
+
exports.checkRspackExternals = checkRspackExternals;
|
|
18
|
+
const initExternalsHelpers = (rspackChain) => {
|
|
19
|
+
const externalFns = [];
|
|
20
|
+
const defaultExternalsFn = ({ context, request }, callback) => {
|
|
21
|
+
let callbackCalled = false;
|
|
22
|
+
const nextHandler = (err, result) => {
|
|
23
|
+
if (err) {
|
|
24
|
+
callback(err, undefined);
|
|
25
|
+
callbackCalled = true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
if (result !== 'next') {
|
|
29
|
+
callback(err, result);
|
|
30
|
+
callbackCalled = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
for (let i = 0; i < externalFns.length; i++) {
|
|
35
|
+
externalFns[i]({ context, request }, nextHandler);
|
|
36
|
+
if (callbackCalled) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (!callbackCalled) {
|
|
41
|
+
callback(null, undefined);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let externals = rspackChain.get('externals');
|
|
45
|
+
(0, invariant_1.default)(!externals, `rspackChain externals has been set, initExternalsHelpers can't work as expected.`);
|
|
46
|
+
if (!externals) {
|
|
47
|
+
externals = defaultExternalsFn;
|
|
48
|
+
rspackChain.externals(externals);
|
|
49
|
+
externalsFunctionMap.set(rspackChain, externalFns);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const addExternals = (rspackChain, externalFn) => {
|
|
53
|
+
let externals = rspackChain.get('externals');
|
|
54
|
+
if (!externals) {
|
|
55
|
+
initExternalsHelpers(rspackChain);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, exports.checkRspackExternals)(rspackChain);
|
|
59
|
+
}
|
|
60
|
+
const externalFns = externalsFunctionMap.get(rspackChain);
|
|
61
|
+
externalFns.push(externalFn);
|
|
62
|
+
};
|
|
63
|
+
exports.addExternals = addExternals;
|
|
64
|
+
function shouldUseRelativeAssetPaths(publicPath) {
|
|
65
|
+
return publicPath === './';
|
|
66
|
+
}
|
|
67
|
+
function splitChunksFilter(chunk) {
|
|
68
|
+
const excludes = {
|
|
69
|
+
// 'static/polyfill': true
|
|
70
|
+
};
|
|
71
|
+
return excludes[chunk.name] !== true;
|
|
72
|
+
}
|
|
73
|
+
const commonChunkFilename = ({ dev }) => {
|
|
74
|
+
return `static/common/${dev ? '[name]' : '[name].[contenthash:8]'}.js`;
|
|
75
|
+
};
|
|
76
|
+
exports.commonChunkFilename = commonChunkFilename;
|
|
77
|
+
exports.NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
|
|
78
|
+
exports.defaultCacheGroups = {
|
|
79
|
+
default: {
|
|
80
|
+
idHint: '',
|
|
81
|
+
reuseExistingChunk: true,
|
|
82
|
+
minChunks: 2,
|
|
83
|
+
priority: -20
|
|
84
|
+
},
|
|
85
|
+
defaultVendors: {
|
|
86
|
+
idHint: 'vendors',
|
|
87
|
+
reuseExistingChunk: true,
|
|
88
|
+
test: exports.NODE_MODULES_REGEXP,
|
|
89
|
+
priority: -10
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/** default splitChunks config https://github.com/webpack/webpack/blob/v5.73.0/lib/config/defaults.js#L1181 */
|
|
93
|
+
const getDefaultSplitChunksConfig = (dev) => {
|
|
94
|
+
return {
|
|
95
|
+
chunks: 'async',
|
|
96
|
+
minChunks: 1,
|
|
97
|
+
minSize: dev ? 10000 : 20000,
|
|
98
|
+
minRemainingSize: dev ? 0 : undefined,
|
|
99
|
+
enforceSizeThreshold: dev ? 30000 : 50000,
|
|
100
|
+
maxAsyncRequests: dev ? Infinity : 30,
|
|
101
|
+
maxInitialRequests: dev ? Infinity : 30,
|
|
102
|
+
automaticNameDelimiter: '-',
|
|
103
|
+
cacheGroups: exports.defaultCacheGroups
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
exports.getDefaultSplitChunksConfig = getDefaultSplitChunksConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WebpackChain } from '../base';
|
|
2
|
-
import { ExternalsFunction } from '../../types';
|
|
1
|
+
import { WebpackChain } from '../base.webpack';
|
|
2
|
+
import { ExternalsFunction } from '../../types.webpack';
|
|
3
3
|
export declare const checkWebpackExternals: (webpackChain: WebpackChain) => void;
|
|
4
4
|
export declare const addExternals: (webpackChain: WebpackChain, externalFn: ExternalsFunction) => void;
|
|
5
5
|
export declare function shouldUseRelativeAssetPaths(publicPath: string): publicPath is "./";
|