arui-scripts 18.7.0 → 19.0.0
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/.turbo/turbo-test.log +6 -10
- package/CHANGELOG.md +25 -0
- package/build/commands/build/build-wrapper.d.ts +3 -3
- package/build/commands/build/build-wrapper.js +2 -2
- package/build/commands/bundle-analyze/index.js +5 -3
- package/build/commands/util/client-assets-sizes.d.ts +1 -1
- package/build/commands/util/run-client-dev-server.d.ts +1 -1
- package/build/commands/util/run-client-dev-server.js +6 -6
- package/build/commands/util/run-server-watch-compiler.d.ts +2 -2
- package/build/commands/util/run-server-watch-compiler.js +2 -2
- package/build/configs/app-configs/calculate-dependent-config.js +1 -1
- package/build/configs/app-configs/get-defaults.js +4 -7
- package/build/configs/app-configs/types.d.ts +4 -17
- package/build/configs/app-configs/warn-about-deprecations.js +14 -5
- package/build/configs/babel-client.js +1 -1
- package/build/configs/babel-server.js +1 -1
- package/build/configs/client-env-config/client-config-plugin.d.ts +1 -1
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +27 -1
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +55 -41
- package/build/configs/dev-server.js +39 -30
- package/build/configs/modules.d.ts +3 -3
- package/build/configs/modules.js +25 -2
- package/build/configs/stats-options.d.ts +2 -2
- package/build/configs/util/apply-overrides.d.ts +11 -11
- package/build/configs/util/find-loader.d.ts +2 -2
- package/build/configs/util/find-plugin.d.ts +9 -6
- package/build/configs/webpack.client.d.ts +2 -2
- package/build/configs/webpack.client.dev.d.ts +1 -1
- package/build/configs/webpack.client.js +23 -55
- package/build/configs/webpack.client.prod.d.ts +1 -1
- package/build/configs/webpack.server.d.ts +1 -1
- package/build/configs/webpack.server.dev.d.ts +1 -1
- package/build/configs/webpack.server.js +13 -43
- package/build/configs/webpack.server.prod.d.ts +1 -1
- package/build/plugins/arui-runtime/arui-runtime-module.d.ts +2 -2
- package/build/plugins/arui-runtime/arui-runtime-module.js +5 -8
- package/build/plugins/arui-runtime/index.d.ts +2 -2
- package/build/plugins/arui-runtime/index.js +2 -5
- package/build/plugins/reload-server-plugin.d.ts +10 -0
- package/build/plugins/reload-server-plugin.js +44 -0
- package/build/plugins/watch-missing-node-modules-plugin.d.ts +5 -5
- package/build/plugins/watch-missing-node-modules-plugin.js +3 -1
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/docs/commands.md +1 -1
- package/docs/settings.md +10 -33
- package/package.json +8 -6
- package/build/plugins/reload-server-webpack-plugin.d.ts +0 -9
- package/build/plugins/reload-server-webpack-plugin.js +0 -44
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import type * as rspack from '@rspack/core';
|
|
1
2
|
import type { Options as SwcOptions } from '@swc/core';
|
|
2
|
-
import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
|
|
3
3
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
4
4
|
import { AppContextWithConfigs } from '../app-configs/types';
|
|
5
5
|
import { createSingleClientWebpackConfig } from '../webpack.client';
|
|
6
6
|
import { findLoader } from './find-loader';
|
|
7
7
|
import { findPlugin } from './find-plugin';
|
|
8
8
|
type Overrides = {
|
|
9
|
-
webpack:
|
|
10
|
-
webpackClient:
|
|
11
|
-
webpackDev:
|
|
12
|
-
webpackClientDev:
|
|
13
|
-
webpackServer:
|
|
14
|
-
webpackServerDev:
|
|
15
|
-
webpackProd:
|
|
16
|
-
webpackClientProd:
|
|
17
|
-
webpackServerProd:
|
|
9
|
+
webpack: rspack.Configuration | rspack.Configuration[];
|
|
10
|
+
webpackClient: rspack.Configuration | rspack.Configuration[];
|
|
11
|
+
webpackDev: rspack.Configuration | rspack.Configuration[];
|
|
12
|
+
webpackClientDev: rspack.Configuration | rspack.Configuration[];
|
|
13
|
+
webpackServer: rspack.Configuration;
|
|
14
|
+
webpackServerDev: rspack.Configuration;
|
|
15
|
+
webpackProd: rspack.Configuration;
|
|
16
|
+
webpackClientProd: rspack.Configuration | rspack.Configuration[];
|
|
17
|
+
webpackServerProd: rspack.Configuration;
|
|
18
18
|
devServer: WebpackDevServerConfiguration;
|
|
19
|
-
stats:
|
|
19
|
+
stats: rspack.RspackOptionsNormalized['stats'];
|
|
20
20
|
babel: any;
|
|
21
21
|
babelClient: any;
|
|
22
22
|
babelServer: any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function findLoader(config:
|
|
1
|
+
import type { Configuration, RuleSetRule } from '@rspack/core';
|
|
2
|
+
export declare function findLoader(config: Configuration, testRule: string): RuleSetRule | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Cluster } from 'cluster';
|
|
2
2
|
import { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
|
|
3
|
+
import { type CssExtractRspackPluginOptions, Configuration, DefinePlugin, NormalModuleReplacementPlugin } from '@rspack/core';
|
|
4
|
+
import { BannerPluginOptions } from '@rspack/core/dist/builtin-plugin/BannerPlugin';
|
|
3
5
|
import AssetsPlugin from 'assets-webpack-plugin';
|
|
4
6
|
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
|
|
5
7
|
import CompressionPlugin from 'compression-webpack-plugin';
|
|
6
8
|
import { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions';
|
|
7
9
|
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
8
10
|
import { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';
|
|
9
|
-
import webpack from 'webpack';
|
|
10
11
|
import { WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin';
|
|
11
12
|
import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
|
|
12
13
|
type PluginsListClient = {
|
|
@@ -14,7 +15,10 @@ type PluginsListClient = {
|
|
|
14
15
|
options: AssetsPlugin.Options;
|
|
15
16
|
};
|
|
16
17
|
DefinePlugin: {
|
|
17
|
-
definitions: ConstructorParameters<typeof
|
|
18
|
+
definitions: ConstructorParameters<typeof DefinePlugin>[number];
|
|
19
|
+
};
|
|
20
|
+
CssExtractRspackPlugin: {
|
|
21
|
+
options: CssExtractRspackPluginOptions;
|
|
18
22
|
};
|
|
19
23
|
MiniCssExtractPlugin: {
|
|
20
24
|
options: MiniCssExtractPlugin.PluginOptions;
|
|
@@ -30,7 +34,6 @@ type PluginsListClient = {
|
|
|
30
34
|
} | {
|
|
31
35
|
checkResource: (resource: string, context: string) => boolean;
|
|
32
36
|
};
|
|
33
|
-
checkIgnore: (resolveData: webpack.ResolveData) => undefined | false;
|
|
34
37
|
};
|
|
35
38
|
WebpackDeduplicationPlugin: WebpackDeduplicationPlugin;
|
|
36
39
|
ReactRefreshPlugin: {
|
|
@@ -48,11 +51,11 @@ type PluginsListClient = {
|
|
|
48
51
|
CompressionPlugin: {
|
|
49
52
|
options: ConstructorParameters<typeof CompressionPlugin>[number];
|
|
50
53
|
};
|
|
51
|
-
NormalModuleReplacementPlugin:
|
|
54
|
+
NormalModuleReplacementPlugin: NormalModuleReplacementPlugin;
|
|
52
55
|
};
|
|
53
56
|
type PluginsListServer = {
|
|
54
57
|
BannerPlugin: {
|
|
55
|
-
options:
|
|
58
|
+
options: BannerPluginOptions;
|
|
56
59
|
};
|
|
57
60
|
RunScriptWebpackPlugin: {
|
|
58
61
|
options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];
|
|
@@ -78,5 +81,5 @@ type SelectedPluginsList<Type extends 'client' | 'server'> = Type extends 'clien
|
|
|
78
81
|
* @param pluginName имя плагина
|
|
79
82
|
* @returns плагин или плагины, которые подошли под условие из testRule
|
|
80
83
|
*/
|
|
81
|
-
export declare function findPlugin<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config:
|
|
84
|
+
export declare function findPlugin<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config: Configuration, pluginName: PluginName) => SelectedPluginsList<Type>[PluginName][];
|
|
82
85
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
2
|
import { Entry } from './util/get-entry';
|
|
3
3
|
/**
|
|
4
4
|
* Создает конфигурацию для сборки клиентского кода. Может быть использована для создания дополнительных конфигураций.
|
|
@@ -7,4 +7,4 @@ import { Entry } from './util/get-entry';
|
|
|
7
7
|
* @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
|
|
8
8
|
*/
|
|
9
9
|
export declare const createSingleClientWebpackConfig: (mode: "dev" | "prod", entry: Entry, configName?: string) => Configuration;
|
|
10
|
-
export declare const createClientWebpackConfig: (mode: "dev" | "prod") =>
|
|
10
|
+
export declare const createClientWebpackConfig: (mode: "dev" | "prod") => import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const config: import("
|
|
1
|
+
declare const config: import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
|
|
2
2
|
export default config;
|
|
@@ -10,25 +10,22 @@ exports.createClientWebpackConfig = exports.createSingleClientWebpackConfig = vo
|
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
12
12
|
const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@rspack/core");
|
|
14
|
+
const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
|
|
14
15
|
const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
|
|
15
16
|
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
16
17
|
const compression_webpack_plugin_1 = __importDefault(require("compression-webpack-plugin"));
|
|
17
18
|
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
18
19
|
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
19
|
-
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
20
20
|
const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
|
|
21
|
+
const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
|
|
21
22
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
22
|
-
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
23
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
24
23
|
const webpack_deduplication_plugin_1 = require("webpack-deduplication-plugin");
|
|
25
|
-
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
26
24
|
const arui_runtime_1 = require("../plugins/arui-runtime");
|
|
27
25
|
const html_template_1 = require("../templates/html.template");
|
|
28
26
|
const minimizers_1 = require("./config-extras/minimizers");
|
|
29
27
|
const check_node_version_1 = __importDefault(require("./util/check-node-version"));
|
|
30
28
|
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
31
|
-
const get_webpack_cache_dependencies_1 = require("./util/get-webpack-cache-dependencies");
|
|
32
29
|
const app_configs_1 = require("./app-configs");
|
|
33
30
|
const babel_client_1 = __importDefault(require("./babel-client"));
|
|
34
31
|
const babel_dependencies_1 = require("./babel-dependencies");
|
|
@@ -37,7 +34,6 @@ const modules_1 = require("./modules");
|
|
|
37
34
|
const postcss_1 = __importDefault(require("./postcss"));
|
|
38
35
|
const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
|
|
39
36
|
const swc_1 = require("./swc");
|
|
40
|
-
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
41
37
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
42
38
|
const noopPath = require.resolve('./util/noop');
|
|
43
39
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -65,7 +61,6 @@ function getMinimizeConfig(mode) {
|
|
|
65
61
|
return {
|
|
66
62
|
minimize: true,
|
|
67
63
|
minimizer: [
|
|
68
|
-
...(0, minimizers_1.getImageMin)(),
|
|
69
64
|
new terser_webpack_plugin_1.default({
|
|
70
65
|
terserOptions: {
|
|
71
66
|
parse: {
|
|
@@ -138,7 +133,9 @@ function getMinimizeConfig(mode) {
|
|
|
138
133
|
// eslint-disable-next-line complexity
|
|
139
134
|
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.configs.devSourceMaps : 'source-map', entry: (0, get_entry_1.default)(entry, getSingleEntry, mode),
|
|
140
135
|
// in production mode we need to fail on first error
|
|
141
|
-
bail: mode === 'prod', context: app_configs_1.configs.cwd,
|
|
136
|
+
bail: mode === 'prod', context: app_configs_1.configs.cwd, experiments: {
|
|
137
|
+
css: false,
|
|
138
|
+
}, output: {
|
|
142
139
|
assetModuleFilename: 'static/media/[name].[hash:8][ext]',
|
|
143
140
|
// Add /* filename */ comments to generated require()s in the output.
|
|
144
141
|
pathinfo: mode === 'dev',
|
|
@@ -157,20 +154,20 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
157
154
|
commons: {
|
|
158
155
|
chunks: 'initial',
|
|
159
156
|
minChunks: 2,
|
|
160
|
-
maxInitialRequests: 5, // The default limit is too small to showcase the effect
|
|
161
157
|
minSize: 0, // This is example is too small to create commons chunks
|
|
162
158
|
},
|
|
163
159
|
vendor: {
|
|
164
160
|
test: /node_modules/,
|
|
165
161
|
chunks: 'initial',
|
|
166
|
-
|
|
162
|
+
// Почему то rspack предоставляет некорректные типы для этой функции.
|
|
163
|
+
name: ((_, chunks, cacheGroupKey) => {
|
|
167
164
|
if (!configName) {
|
|
168
165
|
return 'vendor';
|
|
169
166
|
}
|
|
170
167
|
// Нам нужно сделать так, чтобы у разных конфигураций были разные имена чанков
|
|
171
168
|
const allChunksNames = chunks.map((item) => item.name).join('~');
|
|
172
169
|
return `${cacheGroupKey}-${allChunksNames}`;
|
|
173
|
-
},
|
|
170
|
+
}), // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
174
171
|
priority: 10,
|
|
175
172
|
enforce: true,
|
|
176
173
|
},
|
|
@@ -191,33 +188,8 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
191
188
|
// `web` extension prefixes have been added for better support
|
|
192
189
|
// for React Native Web.
|
|
193
190
|
extensions: ['.web.js', '.mjs', '.cjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
new tsconfig_paths_webpack_plugin_1.default({
|
|
197
|
-
configFile: app_configs_1.configs.tsconfig,
|
|
198
|
-
extensions: [
|
|
199
|
-
'.web.js',
|
|
200
|
-
'.mjs',
|
|
201
|
-
'.js',
|
|
202
|
-
'.json',
|
|
203
|
-
'.web.jsx',
|
|
204
|
-
'.jsx',
|
|
205
|
-
'.ts',
|
|
206
|
-
'.tsx',
|
|
207
|
-
],
|
|
208
|
-
}),
|
|
209
|
-
].filter(Boolean),
|
|
210
|
-
}, resolveLoader: {
|
|
211
|
-
plugins: [PnpWebpackPlugin.moduleLoader(module)],
|
|
212
|
-
}, cache: mode === 'dev'
|
|
213
|
-
? {
|
|
214
|
-
type: 'filesystem',
|
|
215
|
-
buildDependencies: Object.assign({ config: [__filename] }, (0, get_webpack_cache_dependencies_1.getWebpackCacheDependencies)()),
|
|
216
|
-
}
|
|
217
|
-
: false, module: {
|
|
218
|
-
// typescript interface will be removed from modules, and we will get an error on correct code
|
|
219
|
-
// see https://github.com/webpack/webpack/issues/7378
|
|
220
|
-
strictExportPresence: !app_configs_1.configs.tsconfig,
|
|
191
|
+
tsConfig: app_configs_1.configs.tsconfig ? { configFile: app_configs_1.configs.tsconfig } : undefined,
|
|
192
|
+
}, resolveLoader: {}, cache: mode === 'dev', module: {
|
|
221
193
|
rules: [
|
|
222
194
|
{
|
|
223
195
|
// "oneOf" will traverse all following loaders until one will
|
|
@@ -236,7 +208,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
236
208
|
exclude: /\.module\.css$/,
|
|
237
209
|
use: [
|
|
238
210
|
{
|
|
239
|
-
loader:
|
|
211
|
+
loader: core_1.CssExtractRspackPlugin.loader,
|
|
240
212
|
options: { publicPath: './' },
|
|
241
213
|
},
|
|
242
214
|
{
|
|
@@ -261,7 +233,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
261
233
|
test: /\.module\.css$/,
|
|
262
234
|
use: [
|
|
263
235
|
{
|
|
264
|
-
loader:
|
|
236
|
+
loader: core_1.CssExtractRspackPlugin.loader,
|
|
265
237
|
options: { publicPath: './' },
|
|
266
238
|
},
|
|
267
239
|
{
|
|
@@ -296,6 +268,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
296
268
|
},
|
|
297
269
|
},
|
|
298
270
|
},
|
|
271
|
+
mode === 'prod' && (0, minimizers_1.getImageMinLoader)(),
|
|
299
272
|
{
|
|
300
273
|
exclude: [/\.(js|jsx|mjs|cjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
|
|
301
274
|
type: 'asset',
|
|
@@ -313,12 +286,12 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
313
286
|
}, plugins: [
|
|
314
287
|
assetsPlugin,
|
|
315
288
|
clientAssetsPlugin,
|
|
316
|
-
new
|
|
289
|
+
new core_1.DefinePlugin(Object.assign({
|
|
317
290
|
// Tell Webpack to provide empty mocks for process.env.
|
|
318
291
|
'process.env': '{}' }, (mode === 'dev'
|
|
319
292
|
? { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) }
|
|
320
293
|
: {}))),
|
|
321
|
-
new
|
|
294
|
+
new core_1.CssExtractRspackPlugin((() => {
|
|
322
295
|
const prefix = `${configName ? `${configName}-` : ''}`;
|
|
323
296
|
return {
|
|
324
297
|
ignoreOrder: true,
|
|
@@ -338,7 +311,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
338
311
|
// moment.js очень большая библиотека, которая включает в себя массу локализаций, которые мы не используем.
|
|
339
312
|
// Поэтому мы их просто игнорируем, чтобы не включать в сборку.
|
|
340
313
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
341
|
-
new
|
|
314
|
+
new core_1.IgnorePlugin({
|
|
342
315
|
resourceRegExp: /^\.\/locale$/,
|
|
343
316
|
contextRegExp: /moment$/,
|
|
344
317
|
}),
|
|
@@ -353,10 +326,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
353
326
|
rootPath: app_configs_1.configs.cwd,
|
|
354
327
|
}),
|
|
355
328
|
// dev plugins:
|
|
356
|
-
mode === 'dev' &&
|
|
357
|
-
new react_refresh_webpack_plugin_1.default({
|
|
358
|
-
overlay: false,
|
|
359
|
-
}),
|
|
329
|
+
mode === 'dev' && new plugin_react_refresh_1.default(),
|
|
360
330
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
361
331
|
// a plugin that prints an error when you attempt to do this.
|
|
362
332
|
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
@@ -371,7 +341,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
371
341
|
}),
|
|
372
342
|
mode === 'dev' && app_configs_1.configs.clientOnly && new client_env_config_1.ClientConfigPlugin(),
|
|
373
343
|
// production plugins:
|
|
374
|
-
mode === 'prod' && new
|
|
344
|
+
mode === 'prod' && new rspack_manifest_plugin_1.RspackManifestPlugin({}),
|
|
375
345
|
mode === 'prod' &&
|
|
376
346
|
new compression_webpack_plugin_1.default({
|
|
377
347
|
filename: '[file].gz',
|
|
@@ -396,13 +366,11 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
396
366
|
// This should works fine, since proptypes usage should be eliminated in production mode
|
|
397
367
|
mode === 'prod' &&
|
|
398
368
|
!app_configs_1.configs.keepPropTypes &&
|
|
399
|
-
new
|
|
369
|
+
new core_1.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
|
|
400
370
|
mode === 'prod' &&
|
|
401
371
|
!app_configs_1.configs.keepPropTypes &&
|
|
402
|
-
new
|
|
403
|
-
].filter(Boolean),
|
|
404
|
-
backCompat: app_configs_1.configs.webpack4Compatibility,
|
|
405
|
-
},
|
|
372
|
+
new core_1.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath),
|
|
373
|
+
].filter(Boolean),
|
|
406
374
|
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
407
375
|
watchOptions: {
|
|
408
376
|
ignored: new RegExp(app_configs_1.configs.watchIgnorePath.join('|')),
|
|
@@ -437,7 +405,7 @@ function getCodeLoader(mode) {
|
|
|
437
405
|
return {
|
|
438
406
|
test: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
439
407
|
include: app_configs_1.configs.appSrc,
|
|
440
|
-
loader:
|
|
408
|
+
loader: 'builtin:swc-loader',
|
|
441
409
|
options: Object.assign(Object.assign({ cacheDirectory: mode === 'dev', cacheCompression: false }, swc_1.swcClientConfig), { jsc: Object.assign(Object.assign({}, swc_1.swcClientConfig.jsc), { transform: Object.assign(Object.assign({}, (_a = swc_1.swcClientConfig.jsc) === null || _a === void 0 ? void 0 : _a.transform), { react: Object.assign(Object.assign({}, (_c = (_b = swc_1.swcClientConfig.jsc) === null || _b === void 0 ? void 0 : _b.transform) === null || _c === void 0 ? void 0 : _c.react), { refresh: mode === 'dev' }) }) }) }),
|
|
442
410
|
};
|
|
443
411
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const config: import("
|
|
1
|
+
declare const config: import("@rspack/core").RspackOptions | import("@rspack/core").RspackOptions[];
|
|
2
2
|
export default config;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Configuration } from '
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
2
|
export declare const createServerConfig: (mode: "dev" | "prod") => Configuration;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const config: import("
|
|
1
|
+
declare const config: import("@rspack/core").RspackOptions;
|
|
2
2
|
export default config;
|
|
@@ -9,21 +9,19 @@ exports.createServerConfig = void 0;
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
12
|
+
const core_1 = require("@rspack/core");
|
|
12
13
|
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
13
14
|
const run_script_webpack_plugin_1 = require("run-script-webpack-plugin");
|
|
14
|
-
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
15
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
16
15
|
const webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
|
|
16
|
+
const reload_server_plugin_1 = require("../plugins/reload-server-plugin");
|
|
17
|
+
const watch_missing_node_modules_plugin_1 = require("../plugins/watch-missing-node-modules-plugin");
|
|
17
18
|
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
18
|
-
const get_webpack_cache_dependencies_1 = require("./util/get-webpack-cache-dependencies");
|
|
19
19
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
20
20
|
const babel_dependencies_1 = require("./babel-dependencies");
|
|
21
21
|
const babel_server_1 = __importDefault(require("./babel-server"));
|
|
22
22
|
const postcss_1 = __importDefault(require("./postcss"));
|
|
23
23
|
const server_externals_exemptions_1 = require("./server-externals-exemptions");
|
|
24
24
|
const swc_1 = require("./swc");
|
|
25
|
-
const ReloadServerPlugin = require('../plugins/reload-server-webpack-plugin');
|
|
26
|
-
const WatchMissingNodeModulesPlugin = require('../plugins/watch-missing-node-modules-plugin');
|
|
27
25
|
const assetsIgnoreBanner = fs_1.default.readFileSync(require.resolve('./util/node-assets-ignore'), 'utf8');
|
|
28
26
|
const sourceMapSupportBanner = fs_1.default.readFileSync(require.resolve('./util/install-sourcemap-support'), 'utf8');
|
|
29
27
|
// style files regexes
|
|
@@ -31,7 +29,7 @@ const cssRegex = /\.css$/;
|
|
|
31
29
|
const cssModuleRegex = /\.module\.css$/;
|
|
32
30
|
function getSingleEntry(entryPoint, mode) {
|
|
33
31
|
const prefix = mode === 'dev' && app_configs_1.default.useServerHMR
|
|
34
|
-
? [`${require.resolve('
|
|
32
|
+
? [`${require.resolve('@rspack/core/hot/poll')}?1000`]
|
|
35
33
|
: [];
|
|
36
34
|
return [...prefix, ...entryPoint];
|
|
37
35
|
}
|
|
@@ -59,13 +57,7 @@ const createServerConfig = (mode) => ({
|
|
|
59
57
|
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
60
58
|
devtoolModuleFilenameTemplate: (info) => path_1.default.relative(app_configs_1.default.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'),
|
|
61
59
|
},
|
|
62
|
-
cache: mode === 'dev'
|
|
63
|
-
? {
|
|
64
|
-
type: 'filesystem',
|
|
65
|
-
name: 'server',
|
|
66
|
-
buildDependencies: Object.assign({ config: [__filename] }, (0, get_webpack_cache_dependencies_1.getWebpackCacheDependencies)()),
|
|
67
|
-
}
|
|
68
|
-
: false,
|
|
60
|
+
cache: mode === 'dev',
|
|
69
61
|
externalsPresets: { node: true },
|
|
70
62
|
externals: [
|
|
71
63
|
(0, webpack_node_externals_1.default)({
|
|
@@ -92,27 +84,9 @@ const createServerConfig = (mode) => ({
|
|
|
92
84
|
// `web` extension prefixes have been added for better support
|
|
93
85
|
// for React Native Web.
|
|
94
86
|
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
95
|
-
|
|
96
|
-
app_configs_1.default.tsconfig &&
|
|
97
|
-
new tsconfig_paths_webpack_plugin_1.default({
|
|
98
|
-
configFile: app_configs_1.default.tsconfig,
|
|
99
|
-
extensions: [
|
|
100
|
-
'.web.js',
|
|
101
|
-
'.mjs',
|
|
102
|
-
'.js',
|
|
103
|
-
'.json',
|
|
104
|
-
'.web.jsx',
|
|
105
|
-
'.jsx',
|
|
106
|
-
'.ts',
|
|
107
|
-
'.tsx',
|
|
108
|
-
],
|
|
109
|
-
}),
|
|
110
|
-
].filter(Boolean),
|
|
87
|
+
tsConfig: app_configs_1.default.tsconfig ? { configFile: app_configs_1.default.tsconfig } : undefined,
|
|
111
88
|
},
|
|
112
89
|
module: {
|
|
113
|
-
// typescript interface will be removed from modules, and we will get an error on correct code
|
|
114
|
-
// see https://github.com/webpack/webpack/issues/7378
|
|
115
|
-
strictExportPresence: !app_configs_1.default.tsconfig,
|
|
116
90
|
rules: [
|
|
117
91
|
{
|
|
118
92
|
oneOf: [
|
|
@@ -163,13 +137,13 @@ const createServerConfig = (mode) => ({
|
|
|
163
137
|
],
|
|
164
138
|
},
|
|
165
139
|
plugins: [
|
|
166
|
-
new
|
|
140
|
+
new core_1.BannerPlugin({
|
|
167
141
|
banner: assetsIgnoreBanner,
|
|
168
142
|
raw: true,
|
|
169
143
|
entryOnly: false,
|
|
170
144
|
}),
|
|
171
145
|
app_configs_1.default.installServerSourceMaps &&
|
|
172
|
-
new
|
|
146
|
+
new core_1.BannerPlugin({
|
|
173
147
|
banner: sourceMapSupportBanner,
|
|
174
148
|
raw: true,
|
|
175
149
|
entryOnly: false,
|
|
@@ -180,10 +154,9 @@ const createServerConfig = (mode) => ({
|
|
|
180
154
|
? new run_script_webpack_plugin_1.RunScriptWebpackPlugin({
|
|
181
155
|
name: app_configs_1.default.serverOutput,
|
|
182
156
|
})
|
|
183
|
-
: new ReloadServerPlugin({
|
|
157
|
+
: new reload_server_plugin_1.ReloadServerPlugin({
|
|
184
158
|
script: path_1.default.join(app_configs_1.default.serverOutputPath, app_configs_1.default.serverOutput),
|
|
185
159
|
})),
|
|
186
|
-
mode === 'dev' && new webpack_1.default.NoEmitOnErrorsPlugin(),
|
|
187
160
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
188
161
|
// a plugin that prints an error when you attempt to do this.
|
|
189
162
|
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
@@ -192,12 +165,9 @@ const createServerConfig = (mode) => ({
|
|
|
192
165
|
// to restart the development server for Webpack to discover it. This plugin
|
|
193
166
|
// makes the discovery automatic so you don't have to restart.
|
|
194
167
|
// See https://github.com/facebookincubator/create-react-app/issues/186
|
|
195
|
-
mode === 'dev' && new WatchMissingNodeModulesPlugin(app_configs_1.default.appNodeModules),
|
|
196
|
-
mode === 'dev' && app_configs_1.default.useServerHMR && new
|
|
168
|
+
mode === 'dev' && new watch_missing_node_modules_plugin_1.WatchMissingNodeModulesPlugin(app_configs_1.default.appNodeModules),
|
|
169
|
+
mode === 'dev' && app_configs_1.default.useServerHMR && new core_1.HotModuleReplacementPlugin(),
|
|
197
170
|
].filter(Boolean),
|
|
198
|
-
experiments: {
|
|
199
|
-
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
200
|
-
},
|
|
201
171
|
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
202
172
|
watchOptions: {
|
|
203
173
|
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
@@ -214,7 +184,7 @@ function getCodeLoader(mode) {
|
|
|
214
184
|
return {
|
|
215
185
|
test: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
216
186
|
include: app_configs_1.default.appSrc,
|
|
217
|
-
loader:
|
|
187
|
+
loader: 'builtin:swc-loader',
|
|
218
188
|
options: swc_1.swcServerConfig,
|
|
219
189
|
};
|
|
220
190
|
}
|
|
@@ -267,7 +237,7 @@ function getExternalCodeLoader(mode) {
|
|
|
267
237
|
},
|
|
268
238
|
};
|
|
269
239
|
if (app_configs_1.default.codeLoader === 'swc') {
|
|
270
|
-
return Object.assign(Object.assign({}, baseLoaderConfig), { loader:
|
|
240
|
+
return Object.assign(Object.assign({}, baseLoaderConfig), { loader: 'builtin:swc-loader' });
|
|
271
241
|
}
|
|
272
242
|
return Object.assign(Object.assign({}, baseLoaderConfig), { loader: require.resolve('babel-loader'), options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: mode === 'dev', cacheCompression: false }) });
|
|
273
243
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const config: import("
|
|
1
|
+
declare const config: import("@rspack/core").RspackOptions;
|
|
2
2
|
export default config;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RuntimeModule as RsPackRuntimeModule } from '@rspack/core';
|
|
2
2
|
export declare const ARUI_RUNTIME_VARIABLE_NAME = "$ARUI";
|
|
3
3
|
export declare const FULL_ARUI_RUNTIME_PATH: string;
|
|
4
|
-
export declare class RuntimeModule extends
|
|
4
|
+
export declare class RuntimeModule extends RsPackRuntimeModule {
|
|
5
5
|
constructor();
|
|
6
6
|
generate(): string;
|
|
7
7
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.RuntimeModule = exports.FULL_ARUI_RUNTIME_PATH = exports.ARUI_RUNTIME_VARIABLE_NAME = void 0;
|
|
7
|
-
const
|
|
4
|
+
const core_1 = require("@rspack/core");
|
|
8
5
|
exports.ARUI_RUNTIME_VARIABLE_NAME = '$ARUI';
|
|
9
|
-
exports.FULL_ARUI_RUNTIME_PATH = `${
|
|
10
|
-
class RuntimeModule extends
|
|
6
|
+
exports.FULL_ARUI_RUNTIME_PATH = `${core_1.RuntimeGlobals.require}.${exports.ARUI_RUNTIME_VARIABLE_NAME}`;
|
|
7
|
+
class RuntimeModule extends core_1.RuntimeModule {
|
|
11
8
|
constructor() {
|
|
12
|
-
super('AruiRuntimeModule',
|
|
9
|
+
super('AruiRuntimeModule', core_1.RuntimeModule.STAGE_BASIC);
|
|
13
10
|
}
|
|
14
11
|
// eslint-disable-next-line class-methods-use-this
|
|
15
12
|
generate() {
|
|
16
|
-
return
|
|
13
|
+
return core_1.Template.asString([
|
|
17
14
|
"if (typeof __webpack_modules__ !== 'undefined' && typeof document !== 'undefined') {", // По какой-то причине вебпак пытается выполнить этот код не только в браузере, но и при сборке.
|
|
18
15
|
`${exports.FULL_ARUI_RUNTIME_PATH} = { scriptSource: document.currentScript };`,
|
|
19
16
|
'}',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Compiler } from '@rspack/core';
|
|
2
2
|
export declare class AruiRuntimePlugin {
|
|
3
|
-
apply(compiler:
|
|
3
|
+
apply(compiler: Compiler): void;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Метод для вставки runtime чанков css в документ. Нужен для того, чтобы модули могли использовать shadow-dom.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.AruiRuntimePlugin = void 0;
|
|
7
4
|
exports.getInsertCssRuntimeMethod = getInsertCssRuntimeMethod;
|
|
8
|
-
const
|
|
5
|
+
const core_1 = require("@rspack/core");
|
|
9
6
|
const arui_runtime_module_1 = require("./arui-runtime-module");
|
|
10
7
|
class AruiRuntimePlugin {
|
|
11
8
|
apply(compiler) {
|
|
12
9
|
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
13
10
|
compilation.hooks.runtimeRequirementInTree
|
|
14
|
-
.for(
|
|
11
|
+
.for(core_1.RuntimeGlobals.require)
|
|
15
12
|
.tap(this.constructor.name, (chunk) => {
|
|
16
13
|
compilation.addRuntimeModule(chunk, new arui_runtime_module_1.RuntimeModule());
|
|
17
14
|
return true;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import cluster from 'cluster';
|
|
2
|
+
import { type Compiler } from 'webpack';
|
|
3
|
+
export declare class ReloadServerPlugin {
|
|
4
|
+
workers: cluster.Worker[];
|
|
5
|
+
done: null | (() => void);
|
|
6
|
+
constructor({ script }?: {
|
|
7
|
+
script: string;
|
|
8
|
+
});
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.ReloadServerPlugin = void 0;
|
|
7
|
+
const cluster_1 = __importDefault(require("cluster"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
script: 'server.js',
|
|
11
|
+
};
|
|
12
|
+
class ReloadServerPlugin {
|
|
13
|
+
constructor({ script } = defaultOptions) {
|
|
14
|
+
this.workers = [];
|
|
15
|
+
this.done = null;
|
|
16
|
+
this.done = null;
|
|
17
|
+
this.workers = [];
|
|
18
|
+
cluster_1.default.setupMaster({
|
|
19
|
+
exec: path_1.default.resolve(process.cwd(), script),
|
|
20
|
+
});
|
|
21
|
+
cluster_1.default.on('online', (worker) => {
|
|
22
|
+
this.workers.push(worker);
|
|
23
|
+
if (this.done) {
|
|
24
|
+
this.done();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
apply(compiler) {
|
|
29
|
+
compiler.hooks.afterEmit.tapAsync('ReloadServerPlugin', (compilation, callback) => {
|
|
30
|
+
this.done = callback;
|
|
31
|
+
this.workers.forEach((worker) => {
|
|
32
|
+
try {
|
|
33
|
+
process.kill(worker.process.pid, 'SIGTERM');
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
console.warn(`Unable to kill process #${worker.process.pid}`);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.workers = [];
|
|
40
|
+
cluster_1.default.fork();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ReloadServerPlugin = ReloadServerPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
declare class WatchMissingNodeModulesPlugin {
|
|
3
|
-
|
|
4
|
-
nodeModulesPath:
|
|
5
|
-
apply(compiler:
|
|
1
|
+
import { type Compiler } from 'webpack';
|
|
2
|
+
export declare class WatchMissingNodeModulesPlugin {
|
|
3
|
+
nodeModulesPath: string;
|
|
4
|
+
constructor(nodeModulesPath: string);
|
|
5
|
+
apply(compiler: Compiler): void;
|
|
6
6
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WatchMissingNodeModulesPlugin = void 0;
|
|
2
4
|
class WatchMissingNodeModulesPlugin {
|
|
3
5
|
constructor(nodeModulesPath) {
|
|
4
6
|
this.nodeModulesPath = nodeModulesPath;
|
|
@@ -15,4 +17,4 @@ class WatchMissingNodeModulesPlugin {
|
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
exports.WatchMissingNodeModulesPlugin = WatchMissingNodeModulesPlugin;
|