arui-scripts 14.1.0 → 14.1.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/CHANGELOG.md +7 -0
- package/build/configs/util/get-entry.d.ts +2 -1
- package/build/configs/util/get-entry.js +5 -4
- package/build/configs/webpack.client.d.ts +2 -0
- package/build/configs/webpack.client.dev.d.ts +2 -3
- package/build/configs/webpack.client.dev.js +3 -293
- package/build/configs/webpack.client.js +365 -0
- package/build/configs/webpack.client.prod.d.ts +1 -2
- package/build/configs/webpack.client.prod.js +2 -334
- package/build/configs/webpack.server.d.ts +2 -0
- package/build/configs/webpack.server.dev.d.ts +2 -3
- package/build/configs/webpack.server.dev.js +3 -228
- package/build/configs/webpack.server.js +239 -0
- package/build/configs/webpack.server.prod.d.ts +1 -2
- package/build/configs/webpack.server.prod.js +2 -192
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,365 @@
|
|
|
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.createClientWebpackConfig = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
9
|
+
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
10
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
11
|
+
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
|
+
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
16
|
+
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
17
|
+
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
18
|
+
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
19
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
20
|
+
const babel_client_1 = __importDefault(require("./babel-client"));
|
|
21
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
22
|
+
const check_node_version_1 = __importDefault(require("./util/check-node-version"));
|
|
23
|
+
const babel_dependencies_1 = require("./babel-dependencies");
|
|
24
|
+
const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
|
|
25
|
+
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
26
|
+
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
27
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
28
|
+
const noopPath = require.resolve('./util/noop');
|
|
29
|
+
function getSingleEntry(entryPoint, mode) {
|
|
30
|
+
return [
|
|
31
|
+
...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
|
|
32
|
+
mode === 'dev' ? require.resolve('webpack/hot/dev-server') : false,
|
|
33
|
+
...entryPoint
|
|
34
|
+
].filter(Boolean);
|
|
35
|
+
}
|
|
36
|
+
// This is the production configuration.
|
|
37
|
+
const createClientWebpackConfig = (mode) => ({
|
|
38
|
+
target: 'web',
|
|
39
|
+
mode: mode === 'dev' ? 'development' : 'production',
|
|
40
|
+
devtool: mode === 'dev' ? app_configs_1.default.devSourceMaps : 'source-map',
|
|
41
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry, mode),
|
|
42
|
+
// in production mode we need to fail on first error
|
|
43
|
+
bail: mode === 'prod',
|
|
44
|
+
context: app_configs_1.default.cwd,
|
|
45
|
+
output: {
|
|
46
|
+
// Add /* filename */ comments to generated require()s in the output.
|
|
47
|
+
pathinfo: mode === 'dev',
|
|
48
|
+
path: app_configs_1.default.clientOutputPath,
|
|
49
|
+
publicPath: app_configs_1.default.publicPath,
|
|
50
|
+
filename: mode === 'dev' ? '[name].js' : '[name].[chunkhash:8].js',
|
|
51
|
+
chunkFilename: mode === 'dev' ? '[name].js' : '[name].[chunkhash:8].chunk.js',
|
|
52
|
+
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
53
|
+
devtoolModuleFilenameTemplate: (info) => path_1.default
|
|
54
|
+
.relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
|
|
55
|
+
.replace(/\\/g, '/'),
|
|
56
|
+
},
|
|
57
|
+
optimization: {
|
|
58
|
+
splitChunks: mode === 'prod'
|
|
59
|
+
? {
|
|
60
|
+
chunks: "all",
|
|
61
|
+
cacheGroups: {
|
|
62
|
+
commons: {
|
|
63
|
+
chunks: "initial",
|
|
64
|
+
minChunks: 2,
|
|
65
|
+
maxInitialRequests: 5,
|
|
66
|
+
minSize: 0 // This is example is too small to create commons chunks
|
|
67
|
+
},
|
|
68
|
+
vendor: {
|
|
69
|
+
test: /node_modules/,
|
|
70
|
+
chunks: "initial",
|
|
71
|
+
name: "vendor",
|
|
72
|
+
priority: 10,
|
|
73
|
+
enforce: true
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
: false,
|
|
78
|
+
minimize: mode === 'prod',
|
|
79
|
+
minimizer: [
|
|
80
|
+
// This is only used in production mode
|
|
81
|
+
new terser_webpack_plugin_1.default({
|
|
82
|
+
terserOptions: {
|
|
83
|
+
parse: {
|
|
84
|
+
// we want terser to parse ecma 8 code. However, we don't want it
|
|
85
|
+
// to apply any minfication steps that turns valid ecma 5 code
|
|
86
|
+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
87
|
+
// sections only apply transformations that are ecma 5 safe
|
|
88
|
+
// https://github.com/facebook/create-react-app/pull/4234
|
|
89
|
+
ecma: 2017,
|
|
90
|
+
},
|
|
91
|
+
compress: {
|
|
92
|
+
ecma: 5,
|
|
93
|
+
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
94
|
+
// https://github.com/facebook/create-react-app/issues/2376
|
|
95
|
+
// Pending further investigation:
|
|
96
|
+
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
97
|
+
comparisons: false,
|
|
98
|
+
// Disabled because of an issue with Terser breaking valid code:
|
|
99
|
+
// https://github.com/facebook/create-react-app/issues/5250
|
|
100
|
+
// Pending futher investigation:
|
|
101
|
+
// https://github.com/terser-js/terser/issues/120
|
|
102
|
+
inline: 2,
|
|
103
|
+
},
|
|
104
|
+
mangle: {
|
|
105
|
+
safari10: true,
|
|
106
|
+
},
|
|
107
|
+
output: {
|
|
108
|
+
ecma: 5,
|
|
109
|
+
comments: false,
|
|
110
|
+
// Turned on because emoji and regex is not minified properly using default
|
|
111
|
+
// https://github.com/facebook/create-react-app/issues/2488
|
|
112
|
+
ascii_only: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
// Use multi-process parallel running to improve the build speed
|
|
116
|
+
// Default number of concurrent runs: os.cpus().length - 1
|
|
117
|
+
parallel: true,
|
|
118
|
+
}),
|
|
119
|
+
new CssMinimizerPlugin()
|
|
120
|
+
],
|
|
121
|
+
nodeEnv: mode === 'prod' ? 'production' : false,
|
|
122
|
+
// Оптимизации времени билда, см https://webpack.js.org/guides/build-performance/
|
|
123
|
+
removeAvailableModules: mode !== 'dev',
|
|
124
|
+
removeEmptyChunks: mode !== 'dev',
|
|
125
|
+
},
|
|
126
|
+
resolve: {
|
|
127
|
+
// This allows you to set a fallback for where Webpack should look for modules.
|
|
128
|
+
// We placed these paths second because we want `node_modules` to "win"
|
|
129
|
+
// if there are any conflicts. This matches Node resolution mechanism.
|
|
130
|
+
// https://github.com/facebookincubator/create-react-app/issues/253
|
|
131
|
+
modules: ['node_modules', app_configs_1.default.appNodeModules],
|
|
132
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
133
|
+
// We also include JSX as a common component filename extension to support
|
|
134
|
+
// some tools, although we do not recommend using it, see:
|
|
135
|
+
// https://github.com/facebookincubator/create-react-app/issues/290
|
|
136
|
+
// `web` extension prefixes have been added for better support
|
|
137
|
+
// for React Native Web.
|
|
138
|
+
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
139
|
+
plugins: ([
|
|
140
|
+
(app_configs_1.default.tsconfig && new tsconfig_paths_webpack_plugin_1.default({
|
|
141
|
+
configFile: app_configs_1.default.tsconfig,
|
|
142
|
+
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx']
|
|
143
|
+
})),
|
|
144
|
+
].filter(Boolean)),
|
|
145
|
+
},
|
|
146
|
+
resolveLoader: {
|
|
147
|
+
plugins: [
|
|
148
|
+
PnpWebpackPlugin.moduleLoader(module),
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
cache: mode === 'dev'
|
|
152
|
+
? {
|
|
153
|
+
type: 'filesystem',
|
|
154
|
+
buildDependencies: {
|
|
155
|
+
config: [__filename],
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
: false,
|
|
159
|
+
module: {
|
|
160
|
+
// typescript interface will be removed from modules, and we will get an error on correct code
|
|
161
|
+
// see https://github.com/webpack/webpack/issues/7378
|
|
162
|
+
strictExportPresence: !app_configs_1.default.tsconfig,
|
|
163
|
+
rules: [
|
|
164
|
+
{
|
|
165
|
+
// "oneOf" will traverse all following loaders until one will
|
|
166
|
+
// match the requirements. When no loader matches it will fall
|
|
167
|
+
// back to the "file" loader at the end of the loader list.
|
|
168
|
+
oneOf: ([
|
|
169
|
+
{
|
|
170
|
+
test: [/\.svg$/],
|
|
171
|
+
loader: require.resolve('svg-url-loader'),
|
|
172
|
+
options: {
|
|
173
|
+
limit: 10000,
|
|
174
|
+
iesafe: true,
|
|
175
|
+
name: '[name].[hash:8].[ext]',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
// "url" loader works like "file" loader except that it embeds assets
|
|
179
|
+
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
180
|
+
// A missing `test` is equivalent to a match.
|
|
181
|
+
{
|
|
182
|
+
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
183
|
+
loader: require.resolve('url-loader'),
|
|
184
|
+
options: {
|
|
185
|
+
limit: 10000,
|
|
186
|
+
name: '[name].[hash:8].[ext]',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
// Process JS with Babel.
|
|
190
|
+
{
|
|
191
|
+
test: app_configs_1.default.useTscLoader ? /\.(js|jsx|mjs|cjs)$/ : /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
192
|
+
include: app_configs_1.default.appSrc,
|
|
193
|
+
loader: require.resolve('babel-loader'),
|
|
194
|
+
options: Object.assign(Object.assign({}, babel_client_1.default), { cacheDirectory: mode === 'dev', cacheCompression: false, plugins: mode === 'dev' ? require.resolve('react-refresh/babel') : undefined }),
|
|
195
|
+
},
|
|
196
|
+
(app_configs_1.default.tsconfig && app_configs_1.default.useTscLoader) && {
|
|
197
|
+
test: /\.tsx?$/,
|
|
198
|
+
use: [
|
|
199
|
+
{
|
|
200
|
+
loader: require.resolve('babel-loader'),
|
|
201
|
+
options: Object.assign({
|
|
202
|
+
cacheDirectory: mode === 'dev',
|
|
203
|
+
cacheCompression: false,
|
|
204
|
+
plugins: mode === 'dev' ? require.resolve('react-refresh/babel') : undefined,
|
|
205
|
+
}, babel_client_1.default)
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
loader: require.resolve('ts-loader'),
|
|
209
|
+
options: {
|
|
210
|
+
getCustomTransformers: () => ({
|
|
211
|
+
before: mode === 'dev' ? [(0, react_refresh_typescript_1.default)()] : [],
|
|
212
|
+
}),
|
|
213
|
+
onlyCompileBundledFiles: true,
|
|
214
|
+
transpileOnly: true,
|
|
215
|
+
happyPackMode: true,
|
|
216
|
+
configFile: app_configs_1.default.tsconfig
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
// Process any JS outside of the app with Babel.
|
|
222
|
+
// Unlike the application JS, we only compile the standard ES features.
|
|
223
|
+
{
|
|
224
|
+
test: /\.(js|mjs)$/,
|
|
225
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
226
|
+
loader: require.resolve('babel-loader'),
|
|
227
|
+
options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: mode === 'dev', cacheCompression: false }),
|
|
228
|
+
},
|
|
229
|
+
// process simple css files with postcss loader and css loader
|
|
230
|
+
{
|
|
231
|
+
test: /\.css$/,
|
|
232
|
+
exclude: /\.module\.css$/,
|
|
233
|
+
use: [
|
|
234
|
+
{
|
|
235
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
236
|
+
options: { publicPath: './' }
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
loader: require.resolve('css-loader'),
|
|
240
|
+
options: {
|
|
241
|
+
importLoaders: 1,
|
|
242
|
+
sourceMap: mode === 'dev',
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
loader: require.resolve('postcss-loader'),
|
|
247
|
+
options: {
|
|
248
|
+
// Necessary for external CSS imports to work
|
|
249
|
+
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
250
|
+
ident: 'postcss',
|
|
251
|
+
plugins: () => postcss_1.default,
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
// process all *.module.css files with postcss loader and css loader
|
|
257
|
+
{
|
|
258
|
+
test: /\.module\.css$/,
|
|
259
|
+
use: [
|
|
260
|
+
{
|
|
261
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
262
|
+
options: { publicPath: './' }
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
loader: require.resolve('css-loader'),
|
|
266
|
+
options: {
|
|
267
|
+
importLoaders: 1,
|
|
268
|
+
sourceMap: mode === 'dev',
|
|
269
|
+
modules: {
|
|
270
|
+
getLocalIdent: getCSSModuleLocalIdent_1.default
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
loader: require.resolve('postcss-loader'),
|
|
276
|
+
options: {
|
|
277
|
+
// Necessary for external CSS imports to work
|
|
278
|
+
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
279
|
+
ident: 'postcss',
|
|
280
|
+
plugins: () => postcss_1.default,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
286
|
+
// When you `import` an asset, you get its (virtual) filename.
|
|
287
|
+
// In production, they would get copied to the `build` folder.
|
|
288
|
+
// This loader doesn't use a "test" so it will catch all modules
|
|
289
|
+
// that fall through the other loaders.
|
|
290
|
+
{
|
|
291
|
+
// Exclude `js` files to keep "css" loader working as it injects
|
|
292
|
+
// its runtime that would otherwise processed through "file" loader.
|
|
293
|
+
// Also exclude `html` and `json` extensions so they get processed
|
|
294
|
+
// by webpacks internal loaders.
|
|
295
|
+
exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
|
|
296
|
+
loader: require.resolve('file-loader'),
|
|
297
|
+
options: {
|
|
298
|
+
name: 'static/media/[name].[hash:8].[ext]',
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
].filter(Boolean)),
|
|
302
|
+
},
|
|
303
|
+
// ** STOP ** Are you adding a new loader?
|
|
304
|
+
// Make sure to add the new loader(s) before the "file" loader.
|
|
305
|
+
],
|
|
306
|
+
},
|
|
307
|
+
plugins: ([
|
|
308
|
+
new assets_webpack_plugin_1.default({ path: app_configs_1.default.serverOutputPath }),
|
|
309
|
+
new webpack_1.default.DefinePlugin({
|
|
310
|
+
// Tell Webpack to provide empty mocks for process.env.
|
|
311
|
+
'process.env': '{}'
|
|
312
|
+
}),
|
|
313
|
+
new mini_css_extract_plugin_1.default({
|
|
314
|
+
filename: '[name].[contenthash:8].css',
|
|
315
|
+
chunkFilename: '[name].[contenthash:8].chunk.css',
|
|
316
|
+
}),
|
|
317
|
+
app_configs_1.default.tsconfig !== null && new fork_ts_checker_webpack_plugin_1.default(),
|
|
318
|
+
// dev plugins:
|
|
319
|
+
mode === 'dev' && new react_refresh_webpack_plugin_1.default({
|
|
320
|
+
overlay: false,
|
|
321
|
+
}),
|
|
322
|
+
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
323
|
+
// a plugin that prints an error when you attempt to do this.
|
|
324
|
+
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
325
|
+
mode === 'dev' && new case_sensitive_paths_webpack_plugin_1.default(),
|
|
326
|
+
// production plugins:
|
|
327
|
+
mode === 'prod' && new webpack_manifest_plugin_1.WebpackManifestPlugin(),
|
|
328
|
+
mode === 'prod' && new compression_webpack_plugin_1.default({
|
|
329
|
+
filename: '[file].gz',
|
|
330
|
+
algorithm: 'gzip',
|
|
331
|
+
test: /\.js$|\.css$|\.png$|\.svg$/,
|
|
332
|
+
threshold: 10240,
|
|
333
|
+
minRatio: 0.8
|
|
334
|
+
}),
|
|
335
|
+
mode === 'prod' && (0, check_node_version_1.default)(10) && new compression_webpack_plugin_1.default({
|
|
336
|
+
filename: '[file].br',
|
|
337
|
+
algorithm: 'brotliCompress',
|
|
338
|
+
test: /\.(js|css|html|svg)$/,
|
|
339
|
+
compressionOptions: {
|
|
340
|
+
level: 11,
|
|
341
|
+
},
|
|
342
|
+
threshold: 10240,
|
|
343
|
+
minRatio: 0.8,
|
|
344
|
+
}),
|
|
345
|
+
// Ignore prop-types packages in production mode
|
|
346
|
+
// This should works fine, since proptypes usage should be eliminated in production mode
|
|
347
|
+
mode === 'prod' && !app_configs_1.default.keepPropTypes && new webpack_1.default.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
|
|
348
|
+
mode === 'prod' && !app_configs_1.default.keepPropTypes && new webpack_1.default.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath)
|
|
349
|
+
].filter(Boolean)),
|
|
350
|
+
experiments: {
|
|
351
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
352
|
+
},
|
|
353
|
+
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
354
|
+
watchOptions: {
|
|
355
|
+
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
356
|
+
aggregateTimeout: 100,
|
|
357
|
+
},
|
|
358
|
+
// Turn off performance hints during development because we don't do any
|
|
359
|
+
// splitting or minification in interest of speed. These warnings become
|
|
360
|
+
// cumbersome.
|
|
361
|
+
performance: {
|
|
362
|
+
hints: mode === 'dev' ? false : 'warning',
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
exports.createClientWebpackConfig = createClientWebpackConfig;
|