arui-scripts 15.8.0 → 15.8.1
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/.eslintignore +2 -0
- package/.eslintrc.js +13 -0
- package/.turbo/turbo-lint.log +260 -0
- package/.turbo/turbo-test.log +26 -26
- package/CHANGELOG.md +311 -305
- package/build/bin/index.js +9 -1
- package/build/commands/archive-build/index.js +4 -4
- package/build/commands/build/build-wrapper.js +3 -2
- package/build/commands/build/index.js +3 -5
- package/build/commands/bundle-analyze/index.js +5 -3
- package/build/commands/changelog/index.js +4 -2
- package/build/commands/docker-build/index.js +1 -1
- package/build/commands/docker-build-compiled/index.js +1 -1
- package/build/commands/start/index.js +8 -13
- package/build/commands/start/print-compiler-output.js +2 -1
- package/build/commands/start-prod/index.js +3 -5
- package/build/commands/test/index.js +10 -1
- package/build/commands/util/check-required-files.js +12 -8
- package/build/commands/util/client-assets-sizes.js +17 -22
- package/build/commands/util/docker-build.d.ts +1 -1
- package/build/commands/util/docker-build.js +12 -7
- package/build/commands/util/exec.js +2 -0
- package/build/commands/util/format-webpack-messages.js +9 -7
- package/build/commands/util/make-tmp-dir.js +3 -3
- package/build/commands/util/run-client-dev-server.js +1 -1
- package/build/commands/util/run-compilers.d.ts +1 -1
- package/build/commands/util/run-compilers.js +11 -11
- package/build/commands/util/run-server-watch-compiler.js +2 -3
- package/build/commands/util/yarn.js +1 -1
- package/build/configs/app-configs/calculate-dependent-config.js +2 -0
- package/build/configs/app-configs/get-defaults.js +4 -2
- package/build/configs/app-configs/index.d.ts +1 -1
- package/build/configs/app-configs/index.js +3 -3
- package/build/configs/app-configs/read-config-file.d.ts +1 -0
- package/build/configs/app-configs/read-config-file.js +25 -0
- package/build/configs/app-configs/types.d.ts +1 -1
- package/build/configs/app-configs/update-with-config-file.js +4 -10
- package/build/configs/app-configs/update-with-env.js +1 -1
- package/build/configs/app-configs/update-with-presets.js +11 -3
- package/build/configs/babel-client.js +21 -15
- package/build/configs/babel-dependencies.js +3 -3
- package/build/configs/babel-server.js +10 -10
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +1 -1
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +23 -14
- package/build/configs/dev-server.js +20 -18
- package/build/configs/jest/babel-transform.js +2 -0
- package/build/configs/jest/file-transform.js +2 -0
- package/build/configs/jest/index.js +13 -13
- package/build/configs/modules.js +11 -4
- package/build/configs/mq.css +18 -18
- package/build/configs/postcss.config.js +3 -6
- package/build/configs/process-assets-plugin-output.js +1 -1
- package/build/configs/stats-options.js +1 -1
- package/build/configs/supporting-browsers.js +1 -6
- package/build/configs/util/apply-overrides.d.ts +2 -2
- package/build/configs/util/apply-overrides.js +7 -2
- package/build/configs/util/find-loader.d.ts +1 -1
- package/build/configs/util/find-loader.js +2 -0
- package/build/configs/util/install-sourcemap-support.js +4 -0
- package/build/configs/util/node-assets-ignore.js +8 -6
- package/build/configs/util/register-ts-node.js +3 -2
- package/build/configs/webpack.client.js +131 -95
- package/build/configs/webpack.server.js +74 -54
- package/build/plugins/postcss-prefix-selector.js +5 -3
- package/build/plugins/reload-server-webpack-plugin.js +8 -6
- package/build/plugins/watch-missing-node-modules-plugin.js +3 -3
- package/build/templates/dockerfile-compiled.template.js +4 -2
- package/build/templates/dockerfile.template.js +2 -2
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/jest-preset.js +8 -8
- package/package.json +12 -3
- package/release.config.js +8 -2
- package/stylelint.config.js +11 -0
- package/tsconfig.eslint.json +5 -0
|
@@ -44,6 +44,6 @@ const statsOptions = (0, apply_overrides_1.default)('stats', {
|
|
|
44
44
|
// Add warnings
|
|
45
45
|
warnings: true,
|
|
46
46
|
// ignore warning from missing types
|
|
47
|
-
warningsFilter: /export .* was not found in
|
|
47
|
+
warningsFilter: /export .* was not found in/,
|
|
48
48
|
});
|
|
49
49
|
exports.default = statsOptions;
|
|
@@ -4,10 +4,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
|
-
const supportingBrowsers = (0, apply_overrides_1.default)(['browsers', 'supportingBrowsers'], [
|
|
8
|
-
'last 2 versions',
|
|
9
|
-
'ie >= 10',
|
|
10
|
-
'Android >= 4',
|
|
11
|
-
'iOS >= 9'
|
|
12
|
-
]);
|
|
7
|
+
const supportingBrowsers = (0, apply_overrides_1.default)(['browsers', 'supportingBrowsers'], ['last 2 versions', 'ie >= 10', 'Android >= 4', 'iOS >= 9']);
|
|
13
8
|
exports.default = supportingBrowsers;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
|
|
2
2
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
3
3
|
import { AppContextWithConfigs } from '../app-configs/types';
|
|
4
|
-
import { createSingleClientWebpackConfig } from
|
|
4
|
+
import { createSingleClientWebpackConfig } from '../webpack.client';
|
|
5
5
|
import { findLoader } from './find-loader';
|
|
6
6
|
type Overrides = {
|
|
7
7
|
webpack: WebpackConfiguration | WebpackConfiguration[];
|
|
@@ -23,7 +23,7 @@ type Overrides = {
|
|
|
23
23
|
browsers: string[];
|
|
24
24
|
supportingBrowsers: string[];
|
|
25
25
|
Dockerfile: string;
|
|
26
|
-
|
|
26
|
+
DockerfileCompiled: string;
|
|
27
27
|
nginx: string;
|
|
28
28
|
'start.sh': string;
|
|
29
29
|
serverExternalsExemptions: Array<string | RegExp>;
|
|
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const app_configs_1 = __importDefault(require("../app-configs"));
|
|
7
7
|
let overrides = [];
|
|
8
|
-
overrides = app_configs_1.default.overridesPath.map(path => {
|
|
8
|
+
overrides = app_configs_1.default.overridesPath.map((path) => {
|
|
9
9
|
try {
|
|
10
|
+
// eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires
|
|
10
11
|
const requireResult = require(path);
|
|
12
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
11
13
|
if (requireResult.__esModule) {
|
|
12
14
|
// ts-node импортирует esModules, из них надо вытягивать default именно так
|
|
13
15
|
return requireResult.default;
|
|
@@ -29,15 +31,18 @@ overrides = app_configs_1.default.overridesPath.map(path => {
|
|
|
29
31
|
*/
|
|
30
32
|
function applyOverrides(overridesKey, config, args) {
|
|
31
33
|
if (typeof overridesKey === 'string') {
|
|
34
|
+
// eslint-disable-next-line no-param-reassign
|
|
32
35
|
overridesKey = [overridesKey];
|
|
33
36
|
}
|
|
34
|
-
overridesKey.forEach(key => {
|
|
37
|
+
overridesKey.forEach((key) => {
|
|
35
38
|
overrides.forEach((override) => {
|
|
39
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
36
40
|
if (override.hasOwnProperty(key)) {
|
|
37
41
|
const overrideFn = override[key];
|
|
38
42
|
if (typeof overrideFn !== 'function') {
|
|
39
43
|
throw new TypeError(`Override ${key} must be a function`);
|
|
40
44
|
}
|
|
45
|
+
// eslint-disable-next-line no-param-reassign
|
|
41
46
|
config = overrideFn(config, app_configs_1.default, args);
|
|
42
47
|
}
|
|
43
48
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import webpack from
|
|
1
|
+
import webpack from 'webpack';
|
|
2
2
|
export declare function findLoader(config: webpack.Configuration, testRule: string): webpack.RuleSetRule | undefined;
|
|
@@ -6,6 +6,7 @@ function findLoader(config, testRule) {
|
|
|
6
6
|
for (const rule of config.module.rules) {
|
|
7
7
|
if (rule === '...' || !rule) {
|
|
8
8
|
// Webpack имеет странный тип для rules, который позволяет в него положить строку '...'. Успокаиваем TS
|
|
9
|
+
// eslint-disable-next-line no-continue
|
|
9
10
|
continue;
|
|
10
11
|
}
|
|
11
12
|
if (rule.test && rule.test.toString() === testRule) {
|
|
@@ -19,5 +20,6 @@ function findLoader(config, testRule) {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
}
|
|
23
|
+
return undefined;
|
|
22
24
|
}
|
|
23
25
|
exports.findLoader = findLoader;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// TODO: remove eslint-disable or add override to .eslintrc.js
|
|
3
|
+
/* eslint-disable global-require */
|
|
4
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
6
|
try {
|
|
3
7
|
require('source-map-support').install();
|
|
4
8
|
}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// ignore attempts to require any types of assets
|
|
3
3
|
(() => {
|
|
4
4
|
// simply ignore css files, it wont cause any damage
|
|
5
|
-
const ignoreExtensions = [
|
|
6
|
-
'.css'
|
|
7
|
-
];
|
|
5
|
+
const ignoreExtensions = ['.css'];
|
|
8
6
|
// warn about other requires, because it may lead to unexpected behaviour in production
|
|
9
7
|
const warnExtensions = [
|
|
10
8
|
'.gif',
|
|
@@ -20,12 +18,16 @@
|
|
|
20
18
|
'.aac',
|
|
21
19
|
'.mp3',
|
|
22
20
|
'.wav',
|
|
23
|
-
'.ogg'
|
|
21
|
+
'.ogg',
|
|
24
22
|
];
|
|
25
23
|
const noop = () => { };
|
|
26
24
|
const warn = (_, path) => console.warn(`\u001B[0;31mWARNING!
|
|
27
25
|
Trying to require ${path} in node.js.
|
|
28
26
|
Non-js files is ignored when required in node_modules\u001B[0m`);
|
|
29
|
-
ignoreExtensions.forEach(e =>
|
|
30
|
-
|
|
27
|
+
ignoreExtensions.forEach((e) => {
|
|
28
|
+
require.extensions[e] = noop;
|
|
29
|
+
});
|
|
30
|
+
warnExtensions.forEach((e) => {
|
|
31
|
+
require.extensions[e] = warn;
|
|
32
|
+
});
|
|
31
33
|
})();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// TODO: remove eslint-disable
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
4
|
// Мы используем ts-node для работы c конфигами, описаными на ts
|
|
3
|
-
require('ts-node')
|
|
4
|
-
.register({
|
|
5
|
+
require('ts-node').register({
|
|
5
6
|
transpileOnly: true,
|
|
6
7
|
ignore: [],
|
|
7
8
|
compilerOptions: {
|
|
@@ -4,37 +4,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createClientWebpackConfig = exports.createSingleClientWebpackConfig = void 0;
|
|
7
|
+
// TODO: remove eslint-disable and eslint-disable-next-line
|
|
8
|
+
/* eslint-disable global-require */
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
7
10
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
11
|
+
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
12
|
+
const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
|
|
13
|
+
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
14
|
+
const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
|
|
15
|
+
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
16
|
+
const compression_webpack_plugin_1 = __importDefault(require("compression-webpack-plugin"));
|
|
17
|
+
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
10
18
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
19
|
+
const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
|
|
11
20
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
12
|
-
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
13
|
-
const compression_webpack_plugin_1 = __importDefault(require("compression-webpack-plugin"));
|
|
14
|
-
const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
|
|
15
21
|
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
16
|
-
const
|
|
22
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
23
|
+
const webpack_deduplication_plugin_1 = require("webpack-deduplication-plugin");
|
|
24
|
+
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
25
|
+
const minimizers_1 = require("./config-extras/minimizers");
|
|
26
|
+
const check_node_version_1 = __importDefault(require("./util/check-node-version"));
|
|
17
27
|
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
18
28
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
19
29
|
const babel_client_1 = __importDefault(require("./babel-client"));
|
|
20
|
-
const postcss_1 = __importDefault(require("./postcss"));
|
|
21
|
-
const check_node_version_1 = __importDefault(require("./util/check-node-version"));
|
|
22
30
|
const babel_dependencies_1 = require("./babel-dependencies");
|
|
23
|
-
const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
|
|
24
|
-
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
25
|
-
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
26
|
-
const webpack_deduplication_plugin_1 = require("webpack-deduplication-plugin");
|
|
27
|
-
const minimizers_1 = require("./config-extras/minimizers");
|
|
28
|
-
const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
|
|
29
|
-
const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
|
|
30
31
|
const modules_1 = require("./modules");
|
|
32
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
33
|
+
const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
|
|
31
34
|
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
32
35
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
33
36
|
const noopPath = require.resolve('./util/noop');
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
38
|
function getSingleEntry(entryPoint, mode) {
|
|
35
39
|
return [
|
|
36
|
-
...(Array.isArray(app_configs_1.default.clientPolyfillsEntry)
|
|
37
|
-
|
|
40
|
+
...(Array.isArray(app_configs_1.default.clientPolyfillsEntry)
|
|
41
|
+
? app_configs_1.default.clientPolyfillsEntry
|
|
42
|
+
: [app_configs_1.default.clientPolyfillsEntry]),
|
|
43
|
+
...entryPoint,
|
|
38
44
|
].filter(Boolean);
|
|
39
45
|
}
|
|
40
46
|
// Нам важно шарить assets plugin между разными сборками, чтобы файл не перезаписывался
|
|
@@ -92,8 +98,8 @@ function getMinimizeConfig(mode) {
|
|
|
92
98
|
// Default number of concurrent runs: os.cpus().length - 1
|
|
93
99
|
parallel: true,
|
|
94
100
|
}),
|
|
95
|
-
new CssMinimizerPlugin()
|
|
96
|
-
].filter(Boolean)
|
|
101
|
+
new CssMinimizerPlugin(),
|
|
102
|
+
].filter(Boolean),
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
105
|
if (app_configs_1.default.keepCssVars) {
|
|
@@ -109,12 +115,12 @@ function getMinimizeConfig(mode) {
|
|
|
109
115
|
}),
|
|
110
116
|
},
|
|
111
117
|
}),
|
|
112
|
-
]
|
|
118
|
+
],
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
return {
|
|
116
122
|
minimize: false,
|
|
117
|
-
minimizer: []
|
|
123
|
+
minimizer: [],
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
126
|
/**
|
|
@@ -123,6 +129,7 @@ function getMinimizeConfig(mode) {
|
|
|
123
129
|
* @param entry Точка входа, любой валидный вход для webpack
|
|
124
130
|
* @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
|
|
125
131
|
*/
|
|
132
|
+
// eslint-disable-next-line complexity
|
|
126
133
|
const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.assign(Object.assign({}, (configName ? { name: configName } : {})), { target: 'web', mode: mode === 'dev' ? 'development' : 'production', devtool: mode === 'dev' ? app_configs_1.default.devSourceMaps : 'source-map', entry: (0, get_entry_1.default)(entry, getSingleEntry, mode),
|
|
127
134
|
// in production mode we need to fail on first error
|
|
128
135
|
bail: mode === 'prod', context: app_configs_1.default.cwd, output: {
|
|
@@ -136,22 +143,20 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
136
143
|
? `${configName ? `${configName}-` : ''}[name].js`
|
|
137
144
|
: `${configName ? `${configName}-` : ''}[name].[chunkhash:8].chunk.js`,
|
|
138
145
|
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
139
|
-
devtoolModuleFilenameTemplate: (info) => path_1.default
|
|
140
|
-
.relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
|
|
141
|
-
.replace(/\\/g, '/'),
|
|
146
|
+
devtoolModuleFilenameTemplate: (info) => path_1.default.relative(app_configs_1.default.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'),
|
|
142
147
|
}, optimization: Object.assign(Object.assign({}, getMinimizeConfig(mode)), { splitChunks: mode === 'prod'
|
|
143
148
|
? {
|
|
144
|
-
chunks:
|
|
149
|
+
chunks: 'all',
|
|
145
150
|
cacheGroups: {
|
|
146
151
|
commons: {
|
|
147
|
-
chunks:
|
|
152
|
+
chunks: 'initial',
|
|
148
153
|
minChunks: 2,
|
|
149
154
|
maxInitialRequests: 5,
|
|
150
|
-
minSize: 0 // This is example is too small to create commons chunks
|
|
155
|
+
minSize: 0, // This is example is too small to create commons chunks
|
|
151
156
|
},
|
|
152
157
|
vendor: {
|
|
153
158
|
test: /node_modules/,
|
|
154
|
-
chunks:
|
|
159
|
+
chunks: 'initial',
|
|
155
160
|
name: (_, chunks, cacheGroupKey) => {
|
|
156
161
|
if (!configName) {
|
|
157
162
|
return 'vendor';
|
|
@@ -161,9 +166,9 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
161
166
|
return `${cacheGroupKey}-${allChunksNames}`;
|
|
162
167
|
},
|
|
163
168
|
priority: 10,
|
|
164
|
-
enforce: true
|
|
165
|
-
}
|
|
166
|
-
}
|
|
169
|
+
enforce: true,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
167
172
|
}
|
|
168
173
|
: false, nodeEnv: mode === 'prod' ? 'production' : false,
|
|
169
174
|
// Оптимизации времени билда, см https://webpack.js.org/guides/build-performance/
|
|
@@ -180,16 +185,24 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
180
185
|
// `web` extension prefixes have been added for better support
|
|
181
186
|
// for React Native Web.
|
|
182
187
|
extensions: ['.web.js', '.mjs', '.cjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
183
|
-
plugins: ([
|
|
184
|
-
(app_configs_1.default.tsconfig && new tsconfig_paths_webpack_plugin_1.default({
|
|
185
|
-
configFile: app_configs_1.default.tsconfig,
|
|
186
|
-
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx']
|
|
187
|
-
})),
|
|
188
|
-
].filter(Boolean)),
|
|
189
|
-
}, resolveLoader: {
|
|
190
188
|
plugins: [
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
app_configs_1.default.tsconfig &&
|
|
190
|
+
new tsconfig_paths_webpack_plugin_1.default({
|
|
191
|
+
configFile: app_configs_1.default.tsconfig,
|
|
192
|
+
extensions: [
|
|
193
|
+
'.web.js',
|
|
194
|
+
'.mjs',
|
|
195
|
+
'.js',
|
|
196
|
+
'.json',
|
|
197
|
+
'.web.jsx',
|
|
198
|
+
'.jsx',
|
|
199
|
+
'.ts',
|
|
200
|
+
'.tsx',
|
|
201
|
+
],
|
|
202
|
+
}),
|
|
203
|
+
].filter(Boolean),
|
|
204
|
+
}, resolveLoader: {
|
|
205
|
+
plugins: [PnpWebpackPlugin.moduleLoader(module)],
|
|
193
206
|
}, cache: mode === 'dev'
|
|
194
207
|
? {
|
|
195
208
|
type: 'filesystem',
|
|
@@ -206,27 +219,39 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
206
219
|
// "oneOf" will traverse all following loaders until one will
|
|
207
220
|
// match the requirements. When no loader matches it will fall
|
|
208
221
|
// back to the "file" loader at the end of the loader list.
|
|
209
|
-
oneOf:
|
|
222
|
+
oneOf: [
|
|
210
223
|
// Process JS with Babel.
|
|
211
224
|
{
|
|
212
|
-
test: app_configs_1.default.useTscLoader
|
|
225
|
+
test: app_configs_1.default.useTscLoader
|
|
226
|
+
? /\.(js|jsx|mjs|cjs)$/
|
|
227
|
+
: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
213
228
|
include: app_configs_1.default.appSrc,
|
|
214
229
|
loader: require.resolve('babel-loader'),
|
|
215
230
|
options: Object.assign(Object.assign({}, babel_client_1.default), { cacheDirectory: mode === 'dev', cacheCompression: false, plugins: [
|
|
216
231
|
...babel_client_1.default.plugins,
|
|
217
|
-
mode === 'dev'
|
|
232
|
+
mode === 'dev'
|
|
233
|
+
? [
|
|
234
|
+
require.resolve('react-refresh/babel'),
|
|
235
|
+
{ skipEnvCheck: true },
|
|
236
|
+
]
|
|
237
|
+
: undefined,
|
|
218
238
|
].filter(Boolean) }),
|
|
219
239
|
},
|
|
220
|
-
|
|
240
|
+
app_configs_1.default.tsconfig &&
|
|
241
|
+
app_configs_1.default.useTscLoader && {
|
|
221
242
|
test: /\.tsx?$/,
|
|
222
243
|
use: [
|
|
223
244
|
{
|
|
224
245
|
loader: require.resolve('babel-loader'),
|
|
225
|
-
options: Object.assign({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
plugins: mode === 'dev'
|
|
229
|
-
|
|
246
|
+
options: Object.assign({ cacheDirectory: mode === 'dev', cacheCompression: false,
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
248
|
+
// @ts-ignore
|
|
249
|
+
plugins: mode === 'dev'
|
|
250
|
+
? [
|
|
251
|
+
require.resolve('react-refresh/babel'),
|
|
252
|
+
{ skipEnvCheck: true },
|
|
253
|
+
]
|
|
254
|
+
: undefined }, babel_client_1.default),
|
|
230
255
|
},
|
|
231
256
|
{
|
|
232
257
|
loader: require.resolve('ts-loader'),
|
|
@@ -237,10 +262,10 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
237
262
|
onlyCompileBundledFiles: true,
|
|
238
263
|
transpileOnly: true,
|
|
239
264
|
happyPackMode: true,
|
|
240
|
-
configFile: app_configs_1.default.tsconfig
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
]
|
|
265
|
+
configFile: app_configs_1.default.tsconfig,
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
],
|
|
244
269
|
},
|
|
245
270
|
// Process any JS outside of the app with Babel.
|
|
246
271
|
// Unlike the application JS, we only compile the standard ES features.
|
|
@@ -257,7 +282,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
257
282
|
use: [
|
|
258
283
|
{
|
|
259
284
|
loader: mini_css_extract_plugin_1.default.loader,
|
|
260
|
-
options: { publicPath: './' }
|
|
285
|
+
options: { publicPath: './' },
|
|
261
286
|
},
|
|
262
287
|
{
|
|
263
288
|
loader: require.resolve('css-loader'),
|
|
@@ -271,7 +296,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
271
296
|
options: {
|
|
272
297
|
postcssOptions: {
|
|
273
298
|
plugins: postcss_1.default,
|
|
274
|
-
}
|
|
299
|
+
},
|
|
275
300
|
},
|
|
276
301
|
},
|
|
277
302
|
],
|
|
@@ -282,7 +307,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
282
307
|
use: [
|
|
283
308
|
{
|
|
284
309
|
loader: mini_css_extract_plugin_1.default.loader,
|
|
285
|
-
options: { publicPath: './' }
|
|
310
|
+
options: { publicPath: './' },
|
|
286
311
|
},
|
|
287
312
|
{
|
|
288
313
|
loader: require.resolve('css-loader'),
|
|
@@ -290,7 +315,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
290
315
|
importLoaders: 1,
|
|
291
316
|
sourceMap: mode === 'dev',
|
|
292
317
|
modules: {
|
|
293
|
-
getLocalIdent: getCSSModuleLocalIdent_1.default
|
|
318
|
+
getLocalIdent: getCSSModuleLocalIdent_1.default,
|
|
294
319
|
},
|
|
295
320
|
},
|
|
296
321
|
},
|
|
@@ -299,7 +324,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
299
324
|
options: {
|
|
300
325
|
postcssOptions: {
|
|
301
326
|
plugins: postcss_1.default,
|
|
302
|
-
}
|
|
327
|
+
},
|
|
303
328
|
},
|
|
304
329
|
},
|
|
305
330
|
],
|
|
@@ -308,29 +333,29 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
308
333
|
test: /\.svg/,
|
|
309
334
|
type: 'asset',
|
|
310
335
|
generator: {
|
|
311
|
-
dataUrl: (content) => (0, mini_svg_data_uri_1.default)(content.toString())
|
|
336
|
+
dataUrl: (content) => (0, mini_svg_data_uri_1.default)(content.toString()),
|
|
312
337
|
},
|
|
313
338
|
parser: {
|
|
314
339
|
dataUrlCondition: {
|
|
315
|
-
maxSize: app_configs_1.default.dataUrlMaxSize
|
|
316
|
-
}
|
|
317
|
-
}
|
|
340
|
+
maxSize: app_configs_1.default.dataUrlMaxSize,
|
|
341
|
+
},
|
|
342
|
+
},
|
|
318
343
|
},
|
|
319
344
|
{
|
|
320
345
|
exclude: [/\.(js|jsx|mjs|cjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
|
|
321
346
|
type: 'asset',
|
|
322
347
|
parser: {
|
|
323
348
|
dataUrlCondition: {
|
|
324
|
-
maxSize: app_configs_1.default.dataUrlMaxSize
|
|
325
|
-
}
|
|
326
|
-
}
|
|
349
|
+
maxSize: app_configs_1.default.dataUrlMaxSize,
|
|
350
|
+
},
|
|
351
|
+
},
|
|
327
352
|
},
|
|
328
|
-
].filter(Boolean)
|
|
353
|
+
].filter(Boolean),
|
|
329
354
|
},
|
|
330
355
|
// ** STOP ** Are you adding a new loader?
|
|
331
356
|
// Make sure to add the new loader(s) before asset modules
|
|
332
357
|
],
|
|
333
|
-
}, plugins:
|
|
358
|
+
}, plugins: [
|
|
334
359
|
assetsPlugin,
|
|
335
360
|
clientAssetsPlugin,
|
|
336
361
|
new webpack_1.default.DefinePlugin(Object.assign({
|
|
@@ -343,7 +368,9 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
343
368
|
filename: mode === 'dev' ? '[name].css' : '[name].[contenthash:8].css',
|
|
344
369
|
chunkFilename: mode === 'dev' ? '[id].css' : '[name].[contenthash:8].chunk.css',
|
|
345
370
|
}),
|
|
346
|
-
(mode ===
|
|
371
|
+
(mode === 'prod' || !app_configs_1.default.disableDevWebpackTypecheck) &&
|
|
372
|
+
app_configs_1.default.tsconfig !== null &&
|
|
373
|
+
new fork_ts_checker_webpack_plugin_1.default(),
|
|
347
374
|
// moment.js очень большая библиотека, которая включает в себя массу локализаций, которые мы не используем.
|
|
348
375
|
// Поэтому мы их просто игнорируем, чтобы не включать в сборку.
|
|
349
376
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
@@ -356,42 +383,51 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
356
383
|
// например проект зависит от lodash@1, библиотеки A и B зависят от lodash@2. Тогда lodash@2 будет включен в сборку
|
|
357
384
|
// дважды, что приведет к увеличению размера бандла (и это не лечится дедубликацией в yarn/npm).
|
|
358
385
|
// Сама реализация плагина зависит от yarn.lock, поэтому если мы используем npm, то плагин не будет работать.
|
|
359
|
-
app_configs_1.default.useYarn &&
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
386
|
+
app_configs_1.default.useYarn &&
|
|
387
|
+
new webpack_deduplication_plugin_1.WebpackDeduplicationPlugin({
|
|
388
|
+
cacheDir: path_1.default.join(app_configs_1.default.cwd, 'node_modules/.cache/deduplication-webpack-plugin/'),
|
|
389
|
+
rootPath: app_configs_1.default.cwd,
|
|
390
|
+
}),
|
|
363
391
|
// dev plugins:
|
|
364
|
-
mode === 'dev' &&
|
|
365
|
-
|
|
366
|
-
|
|
392
|
+
mode === 'dev' &&
|
|
393
|
+
new react_refresh_webpack_plugin_1.default({
|
|
394
|
+
overlay: false,
|
|
395
|
+
}),
|
|
367
396
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
368
397
|
// a plugin that prints an error when you attempt to do this.
|
|
369
398
|
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
370
399
|
mode === 'dev' && new case_sensitive_paths_webpack_plugin_1.default(),
|
|
371
400
|
// production plugins:
|
|
372
401
|
mode === 'prod' && new webpack_manifest_plugin_1.WebpackManifestPlugin(),
|
|
373
|
-
mode === 'prod' &&
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
402
|
+
mode === 'prod' &&
|
|
403
|
+
new compression_webpack_plugin_1.default({
|
|
404
|
+
filename: '[file].gz',
|
|
405
|
+
algorithm: 'gzip',
|
|
406
|
+
test: /\.js$|\.css$|\.png$|\.svg$/,
|
|
407
|
+
threshold: 10240,
|
|
408
|
+
minRatio: 0.8,
|
|
409
|
+
}),
|
|
410
|
+
mode === 'prod' &&
|
|
411
|
+
(0, check_node_version_1.default)(10) &&
|
|
412
|
+
new compression_webpack_plugin_1.default({
|
|
413
|
+
filename: '[file].br',
|
|
414
|
+
algorithm: 'brotliCompress',
|
|
415
|
+
test: /\.(js|css|html|svg)$/,
|
|
416
|
+
compressionOptions: {
|
|
417
|
+
level: 11,
|
|
418
|
+
},
|
|
419
|
+
threshold: 10240,
|
|
420
|
+
minRatio: 0.8,
|
|
421
|
+
}),
|
|
390
422
|
// Ignore prop-types packages in production mode
|
|
391
423
|
// This should works fine, since proptypes usage should be eliminated in production mode
|
|
392
|
-
mode === 'prod' &&
|
|
393
|
-
|
|
394
|
-
|
|
424
|
+
mode === 'prod' &&
|
|
425
|
+
!app_configs_1.default.keepPropTypes &&
|
|
426
|
+
new webpack_1.default.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
|
|
427
|
+
mode === 'prod' &&
|
|
428
|
+
!app_configs_1.default.keepPropTypes &&
|
|
429
|
+
new webpack_1.default.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath),
|
|
430
|
+
].filter(Boolean), experiments: {
|
|
395
431
|
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
396
432
|
},
|
|
397
433
|
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|