mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
perf: refactor devWarning for production code size (#35411)
* pref: better code style for production * refactor `devWarning` * don't use `useEffect` only wrap `devWarning` * chore: add 'noop' to coverage * chore: add test cases for devWarning * chore: add test case * chore: update test cases for devWarning * chore: restore test script command * fix: remove 'throw new Error' * should not use `throw` for browser * chore: update test case for AutoComplete * perf: add prefix for `devWarning` * update RegExp for UMD * add prefix for ES and CJS * chore: better code style * perf: * upgrade antd-tools * remove `injectWarningCondition` * rename `devWarning` to `warning` * chore: better code style * chore: better code style * chore: restore hasValidName
This commit is contained in:
@@ -60,24 +60,6 @@ function externalMoment(config) {
|
||||
};
|
||||
}
|
||||
|
||||
function injectWarningCondition(config) {
|
||||
config.module.rules.forEach(rule => {
|
||||
// Remove devWarning if needed
|
||||
if (rule.test.test('test.tsx')) {
|
||||
rule.use = [
|
||||
...rule.use,
|
||||
{
|
||||
loader: 'string-replace-loader',
|
||||
options: {
|
||||
search: 'devWarning(',
|
||||
replace: "if (process.env.NODE_ENV !== 'production') devWarning(",
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function processWebpackThemeConfig(themeConfig, theme, vars) {
|
||||
themeConfig.forEach(config => {
|
||||
ignoreMomentLocale(config);
|
||||
@@ -132,10 +114,6 @@ const webpackVariableConfig = injectLessVariables(getWebpackConfig(false), {
|
||||
'root-entry-name': 'variable',
|
||||
});
|
||||
|
||||
webpackConfig.forEach(config => {
|
||||
injectWarningCondition(config);
|
||||
});
|
||||
|
||||
if (process.env.RUN_ENV === 'PRODUCTION') {
|
||||
webpackConfig.forEach(config => {
|
||||
ignoreMomentLocale(config);
|
||||
|
||||
Reference in New Issue
Block a user