arui-scripts 0.0.0-client-only-envs-20250408153713
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/.browserslistrc +5 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +17 -0
- package/.turbo/turbo-build.log +0 -0
- package/.turbo/turbo-test.log +23 -0
- package/CHANGELOG.md +1571 -0
- package/README.md +47 -0
- package/bin/build.sh +2 -0
- package/build/bin/index.d.ts +3 -0
- package/build/bin/index.js +29 -0
- package/build/commands/archive-build/index.d.ts +1 -0
- package/build/commands/archive-build/index.js +80 -0
- package/build/commands/build/build-wrapper.d.ts +8 -0
- package/build/commands/build/build-wrapper.js +42 -0
- package/build/commands/build/client.d.ts +1 -0
- package/build/commands/build/client.js +41 -0
- package/build/commands/build/index.d.ts +1 -0
- package/build/commands/build/index.js +15 -0
- package/build/commands/build/server.d.ts +1 -0
- package/build/commands/build/server.js +29 -0
- package/build/commands/bundle-analyze/index.d.ts +1 -0
- package/build/commands/bundle-analyze/index.js +40 -0
- package/build/commands/changelog/index.d.ts +5 -0
- package/build/commands/changelog/index.js +113 -0
- package/build/commands/docker-build/index.d.ts +1 -0
- package/build/commands/docker-build/index.js +73 -0
- package/build/commands/docker-build-compiled/index.d.ts +1 -0
- package/build/commands/docker-build-compiled/index.js +54 -0
- package/build/commands/ensure-yarn/index.d.ts +0 -0
- package/build/commands/ensure-yarn/index.js +8 -0
- package/build/commands/start/client.d.ts +1 -0
- package/build/commands/start/client.js +8 -0
- package/build/commands/start/index.d.ts +1 -0
- package/build/commands/start/index.js +17 -0
- package/build/commands/start/print-compiler-output.d.ts +1 -0
- package/build/commands/start/print-compiler-output.js +16 -0
- package/build/commands/start/server.d.ts +1 -0
- package/build/commands/start/server.js +8 -0
- package/build/commands/start-prod/client.d.ts +1 -0
- package/build/commands/start-prod/client.js +8 -0
- package/build/commands/start-prod/index.d.ts +1 -0
- package/build/commands/start-prod/index.js +17 -0
- package/build/commands/start-prod/server.d.ts +1 -0
- package/build/commands/start-prod/server.js +8 -0
- package/build/commands/test/get-config.d.ts +1 -0
- package/build/commands/test/get-config.js +104 -0
- package/build/commands/test/index.d.ts +1 -0
- package/build/commands/test/index.js +60 -0
- package/build/commands/util/client-assets-sizes.d.ts +26 -0
- package/build/commands/util/client-assets-sizes.js +82 -0
- package/build/commands/util/docker-build.d.ts +23 -0
- package/build/commands/util/docker-build.js +127 -0
- package/build/commands/util/exec.d.ts +2 -0
- package/build/commands/util/exec.js +20 -0
- package/build/commands/util/format-webpack-messages.d.ts +11 -0
- package/build/commands/util/format-webpack-messages.js +95 -0
- package/build/commands/util/make-tmp-dir.d.ts +6 -0
- package/build/commands/util/make-tmp-dir.js +29 -0
- package/build/commands/util/run-client-dev-server.d.ts +2 -0
- package/build/commands/util/run-client-dev-server.js +46 -0
- package/build/commands/util/run-compilers.d.ts +1 -0
- package/build/commands/util/run-compilers.js +37 -0
- package/build/commands/util/run-server-watch-compiler.d.ts +2 -0
- package/build/commands/util/run-server-watch-compiler.js +19 -0
- package/build/commands/util/tsc.d.ts +1 -0
- package/build/commands/util/tsc.js +13 -0
- package/build/commands/util/yarn.d.ts +5 -0
- package/build/commands/util/yarn.js +55 -0
- package/build/configs/app-configs/calculate-dependent-config.d.ts +9 -0
- package/build/configs/app-configs/calculate-dependent-config.js +38 -0
- package/build/configs/app-configs/get-defaults.d.ts +5 -0
- package/build/configs/app-configs/get-defaults.js +139 -0
- package/build/configs/app-configs/index.d.ts +6 -0
- package/build/configs/app-configs/index.js +24 -0
- package/build/configs/app-configs/read-config-file.d.ts +2 -0
- package/build/configs/app-configs/read-config-file.js +28 -0
- package/build/configs/app-configs/types.d.ts +126 -0
- package/build/configs/app-configs/types.js +2 -0
- package/build/configs/app-configs/update-with-config-file.d.ts +2 -0
- package/build/configs/app-configs/update-with-config-file.js +17 -0
- package/build/configs/app-configs/update-with-env.d.ts +2 -0
- package/build/configs/app-configs/update-with-env.js +23 -0
- package/build/configs/app-configs/update-with-package.d.ts +2 -0
- package/build/configs/app-configs/update-with-package.js +13 -0
- package/build/configs/app-configs/update-with-presets.d.ts +3 -0
- package/build/configs/app-configs/update-with-presets.js +41 -0
- package/build/configs/app-configs/validate-settings-keys.d.ts +4 -0
- package/build/configs/app-configs/validate-settings-keys.js +13 -0
- package/build/configs/app-configs/warn-about-deprecations.d.ts +2 -0
- package/build/configs/app-configs/warn-about-deprecations.js +20 -0
- package/build/configs/babel-client.d.ts +32 -0
- package/build/configs/babel-client.js +72 -0
- package/build/configs/babel-dependencies.d.ts +14 -0
- package/build/configs/babel-dependencies.js +39 -0
- package/build/configs/babel-server.d.ts +27 -0
- package/build/configs/babel-server.js +48 -0
- package/build/configs/client-env-config/add-env-to-html-template.d.ts +1 -0
- package/build/configs/client-env-config/add-env-to-html-template.js +7 -0
- package/build/configs/client-env-config/client-config-plugin.d.ts +5 -0
- package/build/configs/client-env-config/client-config-plugin.js +26 -0
- package/build/configs/client-env-config/constants.d.ts +1 -0
- package/build/configs/client-env-config/constants.js +4 -0
- package/build/configs/client-env-config/get-env-config.d.ts +2 -0
- package/build/configs/client-env-config/get-env-config.js +28 -0
- package/build/configs/client-env-config/index.d.ts +3 -0
- package/build/configs/client-env-config/index.js +9 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +28 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +65 -0
- package/build/configs/config-extras/minimizers/imagemin/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/imagemin/index.js +17 -0
- package/build/configs/config-extras/minimizers/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/index.js +17 -0
- package/build/configs/dev-server.d.ts +2 -0
- package/build/configs/dev-server.js +73 -0
- package/build/configs/jest/babel-transform.d.ts +2 -0
- package/build/configs/jest/babel-transform.js +6 -0
- package/build/configs/jest/css-mock.d.ts +1 -0
- package/build/configs/jest/css-mock.js +2 -0
- package/build/configs/jest/file-transform.d.ts +3 -0
- package/build/configs/jest/file-transform.js +11 -0
- package/build/configs/jest/settings.d.ts +21 -0
- package/build/configs/jest/settings.js +58 -0
- package/build/configs/modules.d.ts +16 -0
- package/build/configs/modules.js +149 -0
- package/build/configs/mq.css +22 -0
- package/build/configs/postcss.config.d.ts +36 -0
- package/build/configs/postcss.config.js +71 -0
- package/build/configs/postcss.d.ts +2 -0
- package/build/configs/postcss.js +11 -0
- package/build/configs/process-assets-plugin-output.d.ts +2 -0
- package/build/configs/process-assets-plugin-output.js +45 -0
- package/build/configs/server-externals-exemptions.d.ts +1 -0
- package/build/configs/server-externals-exemptions.js +21 -0
- package/build/configs/stats-options.d.ts +3 -0
- package/build/configs/stats-options.js +49 -0
- package/build/configs/supporting-browsers.d.ts +2 -0
- package/build/configs/supporting-browsers.js +8 -0
- package/build/configs/swc.d.ts +4 -0
- package/build/configs/swc.js +35 -0
- package/build/configs/util/apply-overrides.d.ts +76 -0
- package/build/configs/util/apply-overrides.js +52 -0
- package/build/configs/util/check-node-version.d.ts +2 -0
- package/build/configs/util/check-node-version.js +7 -0
- package/build/configs/util/find-loader.d.ts +2 -0
- package/build/configs/util/find-loader.js +24 -0
- package/build/configs/util/find-plugin.d.ts +85 -0
- package/build/configs/util/find-plugin.js +22 -0
- package/build/configs/util/get-entry.d.ts +9 -0
- package/build/configs/util/get-entry.js +22 -0
- package/build/configs/util/get-polyfills.d.ts +2 -0
- package/build/configs/util/get-polyfills.js +26 -0
- package/build/configs/util/get-webpack-cache-dependencies.d.ts +1 -0
- package/build/configs/util/get-webpack-cache-dependencies.js +18 -0
- package/build/configs/util/install-sourcemap-support.d.ts +1 -0
- package/build/configs/util/install-sourcemap-support.js +11 -0
- package/build/configs/util/node-assets-ignore.d.ts +0 -0
- package/build/configs/util/node-assets-ignore.js +33 -0
- package/build/configs/util/noop.d.ts +1 -0
- package/build/configs/util/noop.js +2 -0
- package/build/configs/util/register-ts-node.d.ts +0 -0
- package/build/configs/util/register-ts-node.js +18 -0
- package/build/configs/util/resolve.d.ts +12 -0
- package/build/configs/util/resolve.js +29 -0
- package/build/configs/webpack.client.d.ts +10 -0
- package/build/configs/webpack.client.dev.d.ts +2 -0
- package/build/configs/webpack.client.dev.js +15 -0
- package/build/configs/webpack.client.js +475 -0
- package/build/configs/webpack.client.prod.d.ts +2 -0
- package/build/configs/webpack.client.prod.js +15 -0
- package/build/configs/webpack.server.d.ts +2 -0
- package/build/configs/webpack.server.dev.d.ts +2 -0
- package/build/configs/webpack.server.dev.js +11 -0
- package/build/configs/webpack.server.js +256 -0
- package/build/configs/webpack.server.prod.d.ts +2 -0
- package/build/configs/webpack.server.prod.js +11 -0
- package/build/index.d.ts +5 -0
- package/build/index.js +9 -0
- package/build/plugins/arui-runtime/arui-runtime-module.d.ts +7 -0
- package/build/plugins/arui-runtime/arui-runtime-module.js +20 -0
- package/build/plugins/arui-runtime/index.d.ts +11 -0
- package/build/plugins/arui-runtime/index.js +47 -0
- package/build/plugins/postcss-global-variables/postcss-global-variables.d.ts +6 -0
- package/build/plugins/postcss-global-variables/postcss-global-variables.js +38 -0
- package/build/plugins/postcss-global-variables/utils/utils.d.ts +7 -0
- package/build/plugins/postcss-global-variables/utils/utils.js +91 -0
- package/build/plugins/postcss-prefix-selector.d.ts +6 -0
- package/build/plugins/postcss-prefix-selector.js +62 -0
- package/build/plugins/reload-server-plugin.d.ts +10 -0
- package/build/plugins/reload-server-plugin.js +44 -0
- package/build/plugins/turn-off-split-remote-entry.d.ts +11 -0
- package/build/plugins/turn-off-split-remote-entry.js +71 -0
- package/build/plugins/watch-missing-node-modules-plugin.d.ts +6 -0
- package/build/plugins/watch-missing-node-modules-plugin.js +20 -0
- package/build/templates/base-nginx.conf.template.d.ts +2 -0
- package/build/templates/base-nginx.conf.template.js +61 -0
- package/build/templates/dockerfile-compiled.template.d.ts +2 -0
- package/build/templates/dockerfile-compiled.template.js +52 -0
- package/build/templates/dockerfile.template.d.ts +2 -0
- package/build/templates/dockerfile.template.js +41 -0
- package/build/templates/html.template.d.ts +1 -0
- package/build/templates/html.template.js +25 -0
- package/build/templates/nginx.conf.template.d.ts +2 -0
- package/build/templates/nginx.conf.template.js +39 -0
- package/build/templates/start.template.d.ts +2 -0
- package/build/templates/start.template.js +69 -0
- package/build/tsconfig-local.tsbuildinfo +1 -0
- package/docs/artifact.md +58 -0
- package/docs/caveats.md +41 -0
- package/docs/client-only.md +77 -0
- package/docs/commands.md +125 -0
- package/docs/compilers.md +18 -0
- package/docs/examples.md +100 -0
- package/docs/modules.md +780 -0
- package/docs/overrides.md +167 -0
- package/docs/presets.md +65 -0
- package/docs/settings.md +287 -0
- package/jest-preset.js +5 -0
- package/package.json +180 -0
- package/stylelint.config.js +11 -0
- package/tsconfig-local.json +16 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +71 -0
|
@@ -0,0 +1,256 @@
|
|
|
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.createServerConfig = void 0;
|
|
7
|
+
// TODO: remove eslint-disable
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
12
|
+
const core_1 = require("@rspack/core");
|
|
13
|
+
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
14
|
+
const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
|
|
15
|
+
const run_script_webpack_plugin_1 = require("run-script-webpack-plugin");
|
|
16
|
+
const webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
|
|
17
|
+
const reload_server_plugin_1 = require("../plugins/reload-server-plugin");
|
|
18
|
+
const watch_missing_node_modules_plugin_1 = require("../plugins/watch-missing-node-modules-plugin");
|
|
19
|
+
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
20
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
21
|
+
const babel_dependencies_1 = require("./babel-dependencies");
|
|
22
|
+
const babel_server_1 = __importDefault(require("./babel-server"));
|
|
23
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
24
|
+
const server_externals_exemptions_1 = require("./server-externals-exemptions");
|
|
25
|
+
const swc_1 = require("./swc");
|
|
26
|
+
const assetsIgnoreBanner = fs_1.default.readFileSync(require.resolve('./util/node-assets-ignore'), 'utf8');
|
|
27
|
+
const sourceMapSupportBanner = fs_1.default.readFileSync(require.resolve('./util/install-sourcemap-support'), 'utf8');
|
|
28
|
+
// style files regexes
|
|
29
|
+
const cssRegex = /\.css$/;
|
|
30
|
+
const cssModuleRegex = /\.module\.css$/;
|
|
31
|
+
function getSingleEntry(entryPoint, mode) {
|
|
32
|
+
const prefix = mode === 'dev' && app_configs_1.default.useServerHMR
|
|
33
|
+
? [`${require.resolve('@rspack/core/hot/poll')}?1000`]
|
|
34
|
+
: [];
|
|
35
|
+
return [...prefix, ...entryPoint];
|
|
36
|
+
}
|
|
37
|
+
// This is a function that wil return webpack configuration to build a server
|
|
38
|
+
const createServerConfig = (mode) => ({
|
|
39
|
+
mode: mode === 'dev' ? 'development' : 'production',
|
|
40
|
+
// fail on first error in production mode
|
|
41
|
+
bail: mode === 'prod',
|
|
42
|
+
devtool: mode === 'dev' ? app_configs_1.default.devSourceMaps : 'source-map',
|
|
43
|
+
target: 'node',
|
|
44
|
+
node: {
|
|
45
|
+
__filename: true,
|
|
46
|
+
__dirname: true,
|
|
47
|
+
},
|
|
48
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.serverEntry, getSingleEntry, mode),
|
|
49
|
+
context: app_configs_1.default.cwd,
|
|
50
|
+
output: {
|
|
51
|
+
assetModuleFilename: `${app_configs_1.default.assetsPath}/static/media/[name].[hash:8][ext]`,
|
|
52
|
+
// Add /* filename */ comments to generated require()s in the output.
|
|
53
|
+
pathinfo: true,
|
|
54
|
+
path: app_configs_1.default.serverOutputPath,
|
|
55
|
+
publicPath: app_configs_1.default.publicPath,
|
|
56
|
+
filename: app_configs_1.default.serverOutput,
|
|
57
|
+
chunkFilename: '[name].js',
|
|
58
|
+
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
59
|
+
devtoolModuleFilenameTemplate: (info) => path_1.default.relative(app_configs_1.default.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'),
|
|
60
|
+
},
|
|
61
|
+
cache: mode === 'dev',
|
|
62
|
+
externalsPresets: { node: true },
|
|
63
|
+
externals: [
|
|
64
|
+
(0, webpack_node_externals_1.default)({
|
|
65
|
+
allowlist: server_externals_exemptions_1.serverExternalsExemptions,
|
|
66
|
+
// we cannot determine node_modules location before arui-scripts installation, so just load
|
|
67
|
+
// dependencies list from package.json
|
|
68
|
+
modulesFromFile: true,
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
optimization: {
|
|
72
|
+
minimize: false,
|
|
73
|
+
nodeEnv: mode === 'dev' ? false : 'production',
|
|
74
|
+
},
|
|
75
|
+
resolve: {
|
|
76
|
+
// This allows you to set a fallback for where Webpack should look for modules.
|
|
77
|
+
// We placed these paths second because we want `node_modules` to "win"
|
|
78
|
+
// if there are any conflicts. This matches Node resolution mechanism.
|
|
79
|
+
// https://github.com/facebookincubator/create-react-app/issues/253
|
|
80
|
+
modules: ['node_modules', app_configs_1.default.appNodeModules],
|
|
81
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
82
|
+
// We also include JSX as a common component filename extension to support
|
|
83
|
+
// some tools, although we do not recommend using it, see:
|
|
84
|
+
// https://github.com/facebookincubator/create-react-app/issues/290
|
|
85
|
+
// `web` extension prefixes have been added for better support
|
|
86
|
+
// for React Native Web.
|
|
87
|
+
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
88
|
+
tsConfig: app_configs_1.default.tsconfig ? { configFile: app_configs_1.default.tsconfig } : undefined,
|
|
89
|
+
},
|
|
90
|
+
module: {
|
|
91
|
+
rules: [
|
|
92
|
+
{
|
|
93
|
+
oneOf: [
|
|
94
|
+
// Обработка основного кода приложения
|
|
95
|
+
getCodeLoader(mode),
|
|
96
|
+
// обработка ts кода если codeLoader = tsc
|
|
97
|
+
getTsLoaderIfEnabled(mode),
|
|
98
|
+
// Обработка внешнего для приложения кода (node_modules)
|
|
99
|
+
getExternalCodeLoader(mode),
|
|
100
|
+
// replace css imports with empty files
|
|
101
|
+
{
|
|
102
|
+
test: cssRegex,
|
|
103
|
+
exclude: cssModuleRegex,
|
|
104
|
+
loader: require.resolve('null-loader'),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
test: cssModuleRegex,
|
|
108
|
+
use: [
|
|
109
|
+
{
|
|
110
|
+
loader: require.resolve('css-loader'),
|
|
111
|
+
options: {
|
|
112
|
+
modules: {
|
|
113
|
+
exportOnlyLocals: true,
|
|
114
|
+
getLocalIdent: getCSSModuleLocalIdent_1.default,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
loader: require.resolve('postcss-loader'),
|
|
120
|
+
options: {
|
|
121
|
+
postcssOptions: {
|
|
122
|
+
plugins: postcss_1.default,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
test: /\.svg/,
|
|
130
|
+
type: 'asset',
|
|
131
|
+
generator: {
|
|
132
|
+
dataUrl: (file) => (0, mini_svg_data_uri_1.default)(file.content.toString()),
|
|
133
|
+
publicPath: ''
|
|
134
|
+
},
|
|
135
|
+
parser: {
|
|
136
|
+
dataUrlCondition: {
|
|
137
|
+
maxSize: app_configs_1.default.dataUrlMaxSize,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/, /\.svg$/],
|
|
143
|
+
type: 'asset/resource',
|
|
144
|
+
generator: {
|
|
145
|
+
publicPath: ''
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
].filter(Boolean),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
plugins: [
|
|
153
|
+
new core_1.BannerPlugin({
|
|
154
|
+
banner: assetsIgnoreBanner,
|
|
155
|
+
raw: true,
|
|
156
|
+
entryOnly: false,
|
|
157
|
+
}),
|
|
158
|
+
app_configs_1.default.installServerSourceMaps &&
|
|
159
|
+
new core_1.BannerPlugin({
|
|
160
|
+
banner: sourceMapSupportBanner,
|
|
161
|
+
raw: true,
|
|
162
|
+
entryOnly: false,
|
|
163
|
+
}),
|
|
164
|
+
// dev plugins:
|
|
165
|
+
mode === 'dev' &&
|
|
166
|
+
(app_configs_1.default.useServerHMR
|
|
167
|
+
? new run_script_webpack_plugin_1.RunScriptWebpackPlugin({
|
|
168
|
+
name: app_configs_1.default.serverOutput,
|
|
169
|
+
})
|
|
170
|
+
: new reload_server_plugin_1.ReloadServerPlugin({
|
|
171
|
+
script: path_1.default.join(app_configs_1.default.serverOutputPath, app_configs_1.default.serverOutput),
|
|
172
|
+
})),
|
|
173
|
+
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
174
|
+
// a plugin that prints an error when you attempt to do this.
|
|
175
|
+
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
176
|
+
mode === 'dev' && new case_sensitive_paths_webpack_plugin_1.default(),
|
|
177
|
+
// If you require a missing module and then `npm install` it, you still have
|
|
178
|
+
// to restart the development server for Webpack to discover it. This plugin
|
|
179
|
+
// makes the discovery automatic so you don't have to restart.
|
|
180
|
+
// See https://github.com/facebookincubator/create-react-app/issues/186
|
|
181
|
+
mode === 'dev' && new watch_missing_node_modules_plugin_1.WatchMissingNodeModulesPlugin(app_configs_1.default.appNodeModules),
|
|
182
|
+
mode === 'dev' && app_configs_1.default.useServerHMR && new core_1.HotModuleReplacementPlugin(),
|
|
183
|
+
].filter(Boolean),
|
|
184
|
+
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
185
|
+
watchOptions: {
|
|
186
|
+
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
187
|
+
aggregateTimeout: 100,
|
|
188
|
+
},
|
|
189
|
+
performance: {
|
|
190
|
+
// we don't really care about bundle size for server
|
|
191
|
+
hints: false,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
exports.createServerConfig = createServerConfig;
|
|
195
|
+
function getCodeLoader(mode) {
|
|
196
|
+
if (app_configs_1.default.codeLoader === 'swc') {
|
|
197
|
+
return {
|
|
198
|
+
test: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
199
|
+
include: app_configs_1.default.appSrc,
|
|
200
|
+
loader: 'builtin:swc-loader',
|
|
201
|
+
options: swc_1.swcServerConfig,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
test: app_configs_1.default.codeLoader === 'tsc'
|
|
206
|
+
? /\.(js|jsx|mjs|cjs)$/
|
|
207
|
+
: /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
208
|
+
include: app_configs_1.default.appSrc,
|
|
209
|
+
loader: require.resolve('babel-loader'),
|
|
210
|
+
options: Object.assign(Object.assign({}, babel_server_1.default), {
|
|
211
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
212
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
213
|
+
// directory for faster rebuilds.
|
|
214
|
+
cacheDirectory: mode === 'dev' }),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function getTsLoaderIfEnabled(mode) {
|
|
218
|
+
if (app_configs_1.default.codeLoader !== 'tsc' || !app_configs_1.default.tsconfig) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
test: /\.tsx?$/,
|
|
223
|
+
use: [
|
|
224
|
+
{
|
|
225
|
+
loader: require.resolve('babel-loader'),
|
|
226
|
+
options: Object.assign({
|
|
227
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
228
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
229
|
+
// directory for faster rebuilds.
|
|
230
|
+
cacheDirectory: mode === 'dev' }, babel_server_1.default),
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
loader: require.resolve('ts-loader'),
|
|
234
|
+
options: {
|
|
235
|
+
onlyCompileBundledFiles: true,
|
|
236
|
+
transpileOnly: true,
|
|
237
|
+
happyPackMode: true,
|
|
238
|
+
configFile: app_configs_1.default.tsconfig,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function getExternalCodeLoader(mode) {
|
|
245
|
+
const baseLoaderConfig = {
|
|
246
|
+
test: /\.(js|mjs|cjs)$/,
|
|
247
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
248
|
+
resolve: {
|
|
249
|
+
fullySpecified: false,
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
if (app_configs_1.default.codeLoader === 'swc') {
|
|
253
|
+
return Object.assign(Object.assign({}, baseLoaderConfig), { loader: 'builtin:swc-loader' });
|
|
254
|
+
}
|
|
255
|
+
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 }) });
|
|
256
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
|
+
const find_loader_1 = require("./util/find-loader");
|
|
8
|
+
const find_plugin_1 = require("./util/find-plugin");
|
|
9
|
+
const webpack_server_1 = require("./webpack.server");
|
|
10
|
+
const config = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackProd', 'webpackServerProd'], (0, webpack_server_1.createServerConfig)('prod'), { findLoader: find_loader_1.findLoader, findPlugin: (0, find_plugin_1.findPlugin)() });
|
|
11
|
+
exports.default = config;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { OverrideFile } from './configs/util/apply-overrides';
|
|
2
|
+
export type { AppConfigs, PackageSettings } from './configs/app-configs/types';
|
|
3
|
+
export { prepareFilesForDocker } from './commands/util/docker-build';
|
|
4
|
+
export { getBuildParamsFromArgs } from './commands/util/docker-build';
|
|
5
|
+
export { getDockerBuildCommand } from './commands/util/docker-build';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDockerBuildCommand = exports.getBuildParamsFromArgs = exports.prepareFilesForDocker = void 0;
|
|
4
|
+
var docker_build_1 = require("./commands/util/docker-build");
|
|
5
|
+
Object.defineProperty(exports, "prepareFilesForDocker", { enumerable: true, get: function () { return docker_build_1.prepareFilesForDocker; } });
|
|
6
|
+
var docker_build_2 = require("./commands/util/docker-build");
|
|
7
|
+
Object.defineProperty(exports, "getBuildParamsFromArgs", { enumerable: true, get: function () { return docker_build_2.getBuildParamsFromArgs; } });
|
|
8
|
+
var docker_build_3 = require("./commands/util/docker-build");
|
|
9
|
+
Object.defineProperty(exports, "getDockerBuildCommand", { enumerable: true, get: function () { return docker_build_3.getDockerBuildCommand; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RuntimeModule as RsPackRuntimeModule } from '@rspack/core';
|
|
2
|
+
export declare const ARUI_RUNTIME_VARIABLE_NAME = "$ARUI";
|
|
3
|
+
export declare const FULL_ARUI_RUNTIME_PATH: string;
|
|
4
|
+
export declare class RuntimeModule extends RsPackRuntimeModule {
|
|
5
|
+
constructor();
|
|
6
|
+
generate(): string;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeModule = exports.FULL_ARUI_RUNTIME_PATH = exports.ARUI_RUNTIME_VARIABLE_NAME = void 0;
|
|
4
|
+
const core_1 = require("@rspack/core");
|
|
5
|
+
exports.ARUI_RUNTIME_VARIABLE_NAME = '$ARUI';
|
|
6
|
+
exports.FULL_ARUI_RUNTIME_PATH = `${core_1.RuntimeGlobals.require}.${exports.ARUI_RUNTIME_VARIABLE_NAME}`;
|
|
7
|
+
class RuntimeModule extends core_1.RuntimeModule {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('AruiRuntimeModule', core_1.RuntimeModule.STAGE_BASIC);
|
|
10
|
+
}
|
|
11
|
+
// eslint-disable-next-line class-methods-use-this
|
|
12
|
+
generate() {
|
|
13
|
+
return core_1.Template.asString([
|
|
14
|
+
"if (typeof __webpack_modules__ !== 'undefined' && typeof document !== 'undefined') {", // По какой-то причине вебпак пытается выполнить этот код не только в браузере, но и при сборке.
|
|
15
|
+
`${exports.FULL_ARUI_RUNTIME_PATH} = { scriptSource: document.currentScript };`,
|
|
16
|
+
'}',
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RuntimeModule = RuntimeModule;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Compiler } from '@rspack/core';
|
|
2
|
+
export declare class AruiRuntimePlugin {
|
|
3
|
+
apply(compiler: Compiler): void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Метод для вставки runtime чанков css в документ. Нужен для того, чтобы модули могли использовать shadow-dom.
|
|
7
|
+
* Функция, которую возвращает этот метод - НЕ прогоняется через babel, поэтому он должен быть написан на чистом js,
|
|
8
|
+
* без использования синтаксиса, который не поддерживается браузерами.
|
|
9
|
+
* Более того, мы не можем использовать импорты или require внутри, это так же сломает сборку.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getInsertCssRuntimeMethod(): (linkTag: HTMLLinkElement) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AruiRuntimePlugin = void 0;
|
|
4
|
+
exports.getInsertCssRuntimeMethod = getInsertCssRuntimeMethod;
|
|
5
|
+
const core_1 = require("@rspack/core");
|
|
6
|
+
const arui_runtime_module_1 = require("./arui-runtime-module");
|
|
7
|
+
class AruiRuntimePlugin {
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
10
|
+
compilation.hooks.runtimeRequirementInTree
|
|
11
|
+
.for(core_1.RuntimeGlobals.require)
|
|
12
|
+
.tap(this.constructor.name, (chunk) => {
|
|
13
|
+
compilation.addRuntimeModule(chunk, new arui_runtime_module_1.RuntimeModule());
|
|
14
|
+
return true;
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AruiRuntimePlugin = AruiRuntimePlugin;
|
|
20
|
+
/**
|
|
21
|
+
* Метод для вставки runtime чанков css в документ. Нужен для того, чтобы модули могли использовать shadow-dom.
|
|
22
|
+
* Функция, которую возвращает этот метод - НЕ прогоняется через babel, поэтому он должен быть написан на чистом js,
|
|
23
|
+
* без использования синтаксиса, который не поддерживается браузерами.
|
|
24
|
+
* Более того, мы не можем использовать импорты или require внутри, это так же сломает сборку.
|
|
25
|
+
*/
|
|
26
|
+
function getInsertCssRuntimeMethod() {
|
|
27
|
+
/* eslint-disable */
|
|
28
|
+
return function insertCssRuntime(linkTag) {
|
|
29
|
+
if (__webpack_require__ && __webpack_require__.$ARUI.scriptSource) {
|
|
30
|
+
var scriptSource = __webpack_require__.$ARUI.scriptSource;
|
|
31
|
+
var targetElementSelector = scriptSource.getAttribute('data-resources-target-selector');
|
|
32
|
+
if (targetElementSelector) {
|
|
33
|
+
var targetElement = document.querySelector(targetElementSelector);
|
|
34
|
+
if (targetElement) {
|
|
35
|
+
if (targetElement.shadowRoot) {
|
|
36
|
+
targetElement.shadowRoot.appendChild(linkTag);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
targetElement.appendChild(linkTag);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
document.head.appendChild(linkTag);
|
|
45
|
+
};
|
|
46
|
+
/* eslint-enable */
|
|
47
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postCssGlobalVariables = void 0;
|
|
4
|
+
const utils_1 = require("./utils/utils");
|
|
5
|
+
const postCssGlobalVariables = (opts) => {
|
|
6
|
+
const options = Object.assign({ files: [] }, opts);
|
|
7
|
+
const parsedVariables = {};
|
|
8
|
+
const parsedCustomMedia = {};
|
|
9
|
+
let rulesSelectors = new Set();
|
|
10
|
+
return {
|
|
11
|
+
postcssPlugin: '@alfalab/postcss-global-variables',
|
|
12
|
+
prepare() {
|
|
13
|
+
return {
|
|
14
|
+
postcssPlugin: '@alfalab/postcss-global-variables',
|
|
15
|
+
Once(root, postcssHelpers) {
|
|
16
|
+
if (!Object.keys(parsedVariables).length) {
|
|
17
|
+
options.files.forEach((filePath) => {
|
|
18
|
+
const importedCss = (0, utils_1.parseImport)(root, postcssHelpers, filePath);
|
|
19
|
+
(0, utils_1.parseVariables)(importedCss, parsedVariables);
|
|
20
|
+
(0, utils_1.parseMediaQuery)(importedCss, parsedCustomMedia);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const rootRule = (0, utils_1.insertParsedCss)(root, parsedVariables, parsedCustomMedia);
|
|
24
|
+
root.append(rootRule);
|
|
25
|
+
rulesSelectors.add(rootRule);
|
|
26
|
+
},
|
|
27
|
+
OnceExit() {
|
|
28
|
+
rulesSelectors.forEach((rule) => {
|
|
29
|
+
rule.remove();
|
|
30
|
+
});
|
|
31
|
+
rulesSelectors = new Set();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.postCssGlobalVariables = postCssGlobalVariables;
|
|
38
|
+
postCssGlobalVariables.postcss = true;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AtRule, Helpers, Root, Rule } from 'postcss';
|
|
2
|
+
export declare const getMediaQueryName: (rule: AtRule) => string;
|
|
3
|
+
export declare function parseImport(root: Root, postcssHelpers: Helpers, filePath: string): Root;
|
|
4
|
+
export declare const parseVariables: (importedFile: Root, parsedVariables: Record<string, string>) => void;
|
|
5
|
+
export declare const parseMediaQuery: (importedFile: Root, parsedCustomMedia: Record<string, AtRule>) => void;
|
|
6
|
+
export declare function addGlobalVariable(cssValue: string, rootSelector: Rule, parsedVariables: Record<string, string>): void;
|
|
7
|
+
export declare const insertParsedCss: (root: Root, parsedVariables: Record<string, string>, parsedCustomMedia: Record<string, AtRule>) => Rule;
|
|
@@ -0,0 +1,91 @@
|
|
|
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.insertParsedCss = exports.parseMediaQuery = exports.parseVariables = exports.getMediaQueryName = void 0;
|
|
7
|
+
exports.parseImport = parseImport;
|
|
8
|
+
exports.addGlobalVariable = addGlobalVariable;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const postcss_1 = require("postcss");
|
|
12
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
+
const postcss_media_query_parser_1 = __importDefault(require("postcss-media-query-parser"));
|
|
14
|
+
const getMediaQueryName = (rule) => rule.params.split(' ')[0];
|
|
15
|
+
exports.getMediaQueryName = getMediaQueryName;
|
|
16
|
+
function parseImport(root, postcssHelpers, filePath) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
let resolvedPath = '';
|
|
19
|
+
try {
|
|
20
|
+
resolvedPath = path_1.default.resolve(filePath);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
throw new Error(`Failed to read ${filePath} with error ${(err instanceof Error) ? err.message : err}`);
|
|
24
|
+
}
|
|
25
|
+
postcssHelpers.result.messages.push({
|
|
26
|
+
type: 'dependency',
|
|
27
|
+
plugin: 'postcss-global-environments',
|
|
28
|
+
file: resolvedPath,
|
|
29
|
+
parent: (_b = (_a = root.source) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.file,
|
|
30
|
+
});
|
|
31
|
+
const fileContents = fs_1.default.readFileSync(resolvedPath, 'utf8');
|
|
32
|
+
return postcssHelpers.postcss.parse(fileContents, { from: resolvedPath });
|
|
33
|
+
}
|
|
34
|
+
const parseVariables = (importedFile, parsedVariables) => {
|
|
35
|
+
importedFile.walkDecls((decl) => {
|
|
36
|
+
// eslint-disable-next-line no-param-reassign
|
|
37
|
+
parsedVariables[decl.prop] = decl.value;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.parseVariables = parseVariables;
|
|
41
|
+
const parseMediaQuery = (importedFile, parsedCustomMedia) => {
|
|
42
|
+
importedFile.walkAtRules('custom-media', (mediaRule) => {
|
|
43
|
+
const mediaName = (0, exports.getMediaQueryName)(mediaRule);
|
|
44
|
+
// eslint-disable-next-line no-param-reassign
|
|
45
|
+
parsedCustomMedia[mediaName] = mediaRule;
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
exports.parseMediaQuery = parseMediaQuery;
|
|
49
|
+
function addGlobalVariable(cssValue, rootSelector, parsedVariables) {
|
|
50
|
+
const variableMatches = cssValue.match(/var\(\s*--([^)]+)\s*\)/g);
|
|
51
|
+
if (variableMatches) {
|
|
52
|
+
variableMatches.forEach((match) => {
|
|
53
|
+
// var(--gap-24) => --gap-24
|
|
54
|
+
const variableName = match.slice(4, -1).trim();
|
|
55
|
+
if (parsedVariables[variableName]) {
|
|
56
|
+
rootSelector.append(new postcss_1.Declaration({ prop: variableName, value: parsedVariables[variableName] }));
|
|
57
|
+
// Рекурсивно проходимся по значениям css, там тоже могут использоваться переменные
|
|
58
|
+
addGlobalVariable(parsedVariables[variableName], rootSelector, parsedVariables);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const insertParsedCss = (root, parsedVariables, parsedCustomMedia) => {
|
|
64
|
+
const rootRule = new postcss_1.Rule({ selector: ':root' });
|
|
65
|
+
root.walkDecls((decl) => {
|
|
66
|
+
addGlobalVariable(decl.value, rootRule, parsedVariables);
|
|
67
|
+
});
|
|
68
|
+
root.walkAtRules('media', (rule) => {
|
|
69
|
+
var _a;
|
|
70
|
+
// парсим параметры
|
|
71
|
+
const mediaParsed = (0, postcss_media_query_parser_1.default)(rule.params);
|
|
72
|
+
// регулярка для (--desktop), (--mobile), (--desktop-m) и тд
|
|
73
|
+
const parseRule = /--\w+-?\w+/gi;
|
|
74
|
+
(_a = mediaParsed.nodes) === null || _a === void 0 ? void 0 : _a.forEach(({ value }) => {
|
|
75
|
+
// value приходит в виде (--desktop); not screen and (--mobile) и тд
|
|
76
|
+
if (parseRule.test(value)) {
|
|
77
|
+
// берем все вхождения --desktop, --mobile
|
|
78
|
+
const mediaName = value.match(parseRule);
|
|
79
|
+
// итерируемся по [--desktop, --mobile]
|
|
80
|
+
mediaName === null || mediaName === void 0 ? void 0 : mediaName.forEach((rule) => {
|
|
81
|
+
// подставляем значения если у нас есть под это custom-media
|
|
82
|
+
if (parsedCustomMedia[rule]) {
|
|
83
|
+
root.append(parsedCustomMedia[rule]);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
return rootRule;
|
|
90
|
+
};
|
|
91
|
+
exports.insertParsedCss = insertParsedCss;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postCssPrefix = void 0;
|
|
4
|
+
const VisitedRule = Symbol('VisitedRule');
|
|
5
|
+
const ROOT_SELECTOR = ':root';
|
|
6
|
+
const KEYFRAME_RULES = ['keyframes', '-webkit-keyframes', '-moz-keyframes', '-o-keyframes'];
|
|
7
|
+
const postCssPrefix = (options) => {
|
|
8
|
+
const prefix = (options === null || options === void 0 ? void 0 : options.prefix) || '.prefix ';
|
|
9
|
+
return {
|
|
10
|
+
postcssPlugin: '@alfalab/postcss-prefix-selector',
|
|
11
|
+
RootExit(root) {
|
|
12
|
+
if (root[VisitedRule]) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
root[VisitedRule] = true;
|
|
16
|
+
root.walkRules((rule) => {
|
|
17
|
+
const hasParent = !!rule.parent;
|
|
18
|
+
const parentIsAtRule = rule.parent && rule.parent.type === 'atrule';
|
|
19
|
+
const parentIsKeyframe = parentIsAtRule && KEYFRAME_RULES.includes(rule.parent.name);
|
|
20
|
+
if (hasParent && parentIsKeyframe) {
|
|
21
|
+
// Нам не нужно добавлять префиксы для keyframes и элементов внутри них
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
rule[VisitedRule] = true;
|
|
25
|
+
if (isAnyParentVisited(rule)) {
|
|
26
|
+
// если хотя бы один из родителей (кроме root) был посещен, то не добавляем префикс
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
rule.selectors = rule.selectors.map((selector) => {
|
|
30
|
+
/**
|
|
31
|
+
* Оборачивам только самим префиксом без :root.
|
|
32
|
+
* Позволяет инкапсулировать css переменные под классом.
|
|
33
|
+
* В таком случае они будут доступны в модулях приложений после использования флага keepCssVars.
|
|
34
|
+
*/
|
|
35
|
+
if (selector === ROOT_SELECTOR) {
|
|
36
|
+
return prefix;
|
|
37
|
+
}
|
|
38
|
+
return `${prefix}${selector}`;
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.postCssPrefix = postCssPrefix;
|
|
45
|
+
/**
|
|
46
|
+
* Проверяет, что хотя бы один из родителей был посещен. Если посещен Root элемент, то возвращает false
|
|
47
|
+
* @param rule
|
|
48
|
+
*/
|
|
49
|
+
function isAnyParentVisited(rule) {
|
|
50
|
+
let { parent } = rule;
|
|
51
|
+
while (parent) {
|
|
52
|
+
if (!parent.parent) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (parent[VisitedRule]) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
parent = parent.parent;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
postCssPrefix.postcss = 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;
|