arui-scripts 15.8.2 → 15.10.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/.eslintrc.js CHANGED
@@ -9,5 +9,7 @@ module.exports = {
9
9
  rules: {
10
10
  'import/no-default-export': 'warn',
11
11
  'import/no-named-as-default': 'warn',
12
+ // чтобы могли использовать for и генераторы
13
+ 'no-restricted-syntax': 'off',
12
14
  },
13
15
  };
@@ -175,22 +175,27 @@
175
175
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/supporting-browsers.ts
176
176
  8:8 warning Prefer named exports import/no-default-export
177
177
 
178
+ /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/__tests__/find-plugin.tests.ts
179
+ 6:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
180
+ 8:26 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
181
+ 12:43 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
182
+
178
183
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/__tests__/get-polyfills.tests.ts
179
184
  41:83 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
180
185
  53:83 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
181
186
 
182
187
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/apply-overrides.ts
183
188
  5:8 warning Using exported name 'appConfigs' as identifier for default export import/no-named-as-default
184
- 24:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
185
- 25:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
189
+ 25:12 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
186
190
  26:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
187
- 27:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
188
- 29:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
189
- 40:38 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
190
- 88:9 warning Unexpected console statement no-console
191
- 89:9 warning Unexpected console statement no-console
192
- 107:48 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
193
- 130:8 warning Prefer named exports import/no-default-export
191
+ 27:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
192
+ 28:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
193
+ 30:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
194
+ 41:38 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
195
+ 97:9 warning Unexpected console statement no-console
196
+ 98:9 warning Unexpected console statement no-console
197
+ 116:48 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
198
+ 139:8 warning Prefer named exports import/no-default-export
194
199
 
195
200
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/check-node-version.ts
196
201
  7:8 warning Prefer named exports import/no-default-export
@@ -199,6 +204,9 @@
199
204
  9:24 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
200
205
  9:24 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
201
206
 
207
+ /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/find-plugin.ts
208
+ 112:39 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
209
+
202
210
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/util/get-entry.ts
203
211
  32:8 warning Prefer named exports import/no-default-export
204
212
 
@@ -209,21 +217,23 @@
209
217
  24:9 warning Unexpected console statement no-console
210
218
 
211
219
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.client.dev.ts
212
- 14:8 warning Prefer named exports import/no-default-export
220
+ 16:8 warning Prefer named exports import/no-default-export
213
221
 
214
222
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.client.prod.ts
215
- 14:8 warning Prefer named exports import/no-default-export
223
+ 16:8 warning Prefer named exports import/no-default-export
216
224
 
217
225
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.client.ts
226
+ 4:1 warning Run autofix to sort these imports! simple-import-sort/imports
218
227
  24:8 warning Using exported name 'configs' as identifier for default export import/no-named-as-default
219
- 162:47 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
220
- 181:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
228
+ 163:47 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
229
+ 182:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
230
+ 425:52 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
221
231
 
222
232
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.server.dev.ts
223
- 11:8 warning Prefer named exports import/no-default-export
233
+ 12:8 warning Prefer named exports import/no-default-export
224
234
 
225
235
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.server.prod.ts
226
- 11:8 warning Prefer named exports import/no-default-export
236
+ 12:8 warning Prefer named exports import/no-default-export
227
237
 
228
238
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.server.ts
229
239
  14:8 warning Using exported name 'configs' as identifier for default export import/no-named-as-default
@@ -256,5 +266,6 @@
256
266
  /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/types.d.ts
257
267
  4:12 warning Prefer named exports import/no-default-export
258
268
 
259
- ✖ 143 problems (0 errors, 143 warnings)
269
+ ✖ 149 problems (0 errors, 149 warnings)
270
+ 0 errors and 1 warning potentially fixable with the `--fix` option.
260
271
 
@@ -1,4 +1,9 @@
1
- PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (38.47 s)
1
+ Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
2
+ Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
3
+ Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
4
+ Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
5
+ PASS src/configs/util/__tests__/find-plugin.tests.ts (50.963 s)
6
+ PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts
2
7
  PASS src/configs/util/__tests__/get-polyfills.tests.ts
3
8
  PASS src/configs/util/__tests__/apply-overrides.tests.ts
4
9
  PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
@@ -84,8 +89,8 @@ PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
84
89
  at Object.<anonymous> (src/configs/app-configs/__tests__/validate-settings-keys.tests.ts:15:29)
85
90
 
86
91
 
87
- Test Suites: 6 passed, 6 total
88
- Tests: 17 passed, 17 total
92
+ Test Suites: 7 passed, 7 total
93
+ Tests: 21 passed, 21 total
89
94
  Snapshots: 0 total
90
- Time: 45.078 s
95
+ Time: 54.855 s
91
96
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # [15.3.0](https://github.com/core-ds/arui-scripts/compare/v15.2.0...v15.3.0) (2023-06-30)
2
2
 
3
+ ## 15.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#142](https://github.com/core-ds/arui-scripts/pull/142) [`473ab9f`](https://github.com/core-ds/arui-scripts/commit/473ab9f0482c740741c7ed7ae6e926d5ae06feca) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Runtime css чанки теперь могут подключаться в определяемую из вне ноду
8
+
9
+ ## 15.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#143](https://github.com/core-ds/arui-scripts/pull/143) [`1d94d1f`](https://github.com/core-ds/arui-scripts/commit/1d94d1fd57c1899966624b497c3506e0c818410e) Thanks [@Echzio](https://github.com/Echzio)! - добавление findPlugin хелпера для overrides-файла
14
+
3
15
  ## 15.8.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -10,7 +10,7 @@ ARUI-scripts
10
10
 
11
11
  Зависимость | Версия
12
12
  -- | --
13
- `nodejs` | `14.0.0+`
13
+ `nodejs` | `14.21.3, 16.20.2, 18.0.0+`
14
14
  `react` | `16.13.0+`
15
15
  `react-dom` | `16.13.0+`
16
16
 
@@ -3,6 +3,7 @@ import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev
3
3
  import { AppContextWithConfigs } from '../app-configs/types';
4
4
  import { createSingleClientWebpackConfig } from '../webpack.client';
5
5
  import { findLoader } from './find-loader';
6
+ import { findPlugin } from './find-plugin';
6
7
  type Overrides = {
7
8
  webpack: WebpackConfiguration | WebpackConfiguration[];
8
9
  webpackClient: WebpackConfiguration | WebpackConfiguration[];
@@ -33,6 +34,11 @@ type BoundCreateSingleClientWebpackConfig = OmitFirstArg<typeof createSingleClie
33
34
  type ClientWebpackAdditionalArgs = {
34
35
  createSingleClientWebpackConfig: BoundCreateSingleClientWebpackConfig;
35
36
  findLoader: typeof findLoader;
37
+ findPlugin: ReturnType<typeof findPlugin<'client'>>;
38
+ };
39
+ type ServerWebpackAdditionalArgs = {
40
+ findLoader: typeof findLoader;
41
+ findPlugin: ReturnType<typeof findPlugin<'server'>>;
36
42
  };
37
43
  /**
38
44
  * Дополнительные аргументы, которые будут переданы в функцию оверрайда
@@ -42,6 +48,8 @@ type OverridesAdditionalArgs = {
42
48
  webpackClient: ClientWebpackAdditionalArgs;
43
49
  webpackDev: ClientWebpackAdditionalArgs;
44
50
  webpackClientDev: ClientWebpackAdditionalArgs;
51
+ webpackServer: ServerWebpackAdditionalArgs;
52
+ webpackServerDev: ServerWebpackAdditionalArgs;
45
53
  };
46
54
  type OverrideFunction<K extends keyof Overrides, AdditionalArgs = K extends keyof OverridesAdditionalArgs ? OverridesAdditionalArgs[K] : undefined> = (config: Overrides[K], appConfig: AppContextWithConfigs, additionalArgs: AdditionalArgs) => Overrides[K];
47
55
  export type OverrideFile = {
@@ -0,0 +1,83 @@
1
+ /// <reference types="node" />
2
+ import { Cluster } from 'cluster';
3
+ import { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
4
+ import AssetsPlugin from 'assets-webpack-plugin';
5
+ import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
6
+ import CompressionPlugin from 'compression-webpack-plugin';
7
+ import { ForkTsCheckerWebpackPluginOptions } from 'fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPluginOptions';
8
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
9
+ import { RunScriptWebpackPlugin } from 'run-script-webpack-plugin';
10
+ import webpack from 'webpack';
11
+ import { WebpackDeduplicationPlugin } from 'webpack-deduplication-plugin';
12
+ import { WebpackManifestPlugin } from 'webpack-manifest-plugin';
13
+ type PluginsListClient = {
14
+ AssetsWebpackPlugin: {
15
+ options: AssetsPlugin.Options;
16
+ };
17
+ DefinePlugin: {
18
+ definitions: ConstructorParameters<typeof webpack.DefinePlugin>[number];
19
+ };
20
+ MiniCssExtractPlugin: {
21
+ options: MiniCssExtractPlugin.PluginOptions;
22
+ runtimeOptions: MiniCssExtractPlugin.RuntimeOptions;
23
+ };
24
+ ForkTsCheckerWebpackPlugin: {
25
+ options: ForkTsCheckerWebpackPluginOptions;
26
+ };
27
+ IgnorePlugin: {
28
+ options: {
29
+ contextRegExp?: RegExp;
30
+ resourceRegExp: RegExp;
31
+ } | {
32
+ checkResource: (resource: string, context: string) => boolean;
33
+ };
34
+ checkIgnore: (resolveData: webpack.ResolveData) => undefined | false;
35
+ };
36
+ WebpackDeduplicationPlugin: WebpackDeduplicationPlugin;
37
+ ReactRefreshPlugin: {
38
+ options: ReactRefreshPluginOptions;
39
+ };
40
+ CaseSensitivePathsPlugin: {
41
+ options: CaseSensitivePathsPlugin.Options;
42
+ logger: {
43
+ [K in keyof Console]: Console[K];
44
+ };
45
+ };
46
+ WebpackManifestPlugin: {
47
+ options: ConstructorParameters<typeof WebpackManifestPlugin>[number];
48
+ };
49
+ CompressionPlugin: {
50
+ options: ConstructorParameters<typeof CompressionPlugin>[number];
51
+ };
52
+ NormalModuleReplacementPlugin: webpack.NormalModuleReplacementPlugin;
53
+ };
54
+ type PluginsListServer = {
55
+ BannerPlugin: {
56
+ options: webpack.BannerPlugin['options'];
57
+ };
58
+ RunScriptWebpackPlugin: {
59
+ options: ConstructorParameters<typeof RunScriptWebpackPlugin>[number];
60
+ };
61
+ ReloadServerPlugin: {
62
+ done: (...props: unknown[]) => unknown | null;
63
+ workers: Array<Cluster['Worker']>;
64
+ };
65
+ CaseSensitivePathsPlugin: {
66
+ options: CaseSensitivePathsPlugin.Options;
67
+ logger: {
68
+ [K in keyof Console]: Console[K];
69
+ };
70
+ };
71
+ WatchMissingNodeModulesPlugin: {
72
+ nodeModulesPath: string;
73
+ };
74
+ };
75
+ type SelectedPluginsList<Type extends 'client' | 'server'> = Type extends 'client' ? PluginsListClient : PluginsListServer;
76
+ /**
77
+ *
78
+ * @param config конфигурация webpack
79
+ * @param pluginName имя плагина
80
+ * @returns плагин или плагины, которые подошли под условие из testRule
81
+ */
82
+ export declare function findPlugin<Type extends 'client' | 'server'>(): <PluginName extends keyof SelectedPluginsList<Type>>(config: webpack.Configuration, pluginName: PluginName) => SelectedPluginsList<Type>[PluginName][];
83
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findPlugin = void 0;
4
+ /**
5
+ *
6
+ * @param config конфигурация webpack
7
+ * @param pluginName имя плагина
8
+ * @returns плагин или плагины, которые подошли под условие из testRule
9
+ */
10
+ function findPlugin() {
11
+ return (config, pluginName) => {
12
+ if (!config.plugins || !pluginName)
13
+ return [];
14
+ const result = [];
15
+ for (const plugin of config.plugins) {
16
+ if ((plugin === null || plugin === void 0 ? void 0 : plugin.constructor.name) === pluginName) {
17
+ result.push(plugin);
18
+ }
19
+ }
20
+ return result;
21
+ };
22
+ }
23
+ exports.findPlugin = findPlugin;
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
7
7
  const find_loader_1 = require("./util/find-loader");
8
+ const find_plugin_1 = require("./util/find-plugin");
8
9
  const webpack_client_1 = require("./webpack.client");
9
10
  const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], (0, webpack_client_1.createClientWebpackConfig)('dev'), {
10
11
  createSingleClientWebpackConfig: webpack_client_1.createSingleClientWebpackConfig.bind(null, 'dev'),
11
12
  findLoader: find_loader_1.findLoader,
13
+ findPlugin: (0, find_plugin_1.findPlugin)(),
12
14
  });
13
15
  exports.default = config;
@@ -31,6 +31,7 @@ const babel_dependencies_1 = require("./babel-dependencies");
31
31
  const modules_1 = require("./modules");
32
32
  const postcss_1 = __importDefault(require("./postcss"));
33
33
  const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
34
+ const arui_runtime_1 = require("../plugins/arui-runtime");
34
35
  const PnpWebpackPlugin = require('pnp-webpack-plugin');
35
36
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
36
37
  const noopPath = require.resolve('./util/noop');
@@ -367,6 +368,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
367
368
  ignoreOrder: true,
368
369
  filename: mode === 'dev' ? '[name].css' : '[name].[contenthash:8].css',
369
370
  chunkFilename: mode === 'dev' ? '[id].css' : '[name].[contenthash:8].chunk.css',
371
+ insert: (0, arui_runtime_1.getInsertCssRuntimeMethod)(),
370
372
  }),
371
373
  (mode === 'prod' || !app_configs_1.default.disableDevWebpackTypecheck) &&
372
374
  app_configs_1.default.tsconfig !== null &&
@@ -397,6 +399,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
397
399
  // a plugin that prints an error when you attempt to do this.
398
400
  // See https://github.com/facebookincubator/create-react-app/issues/240
399
401
  mode === 'dev' && new case_sensitive_paths_webpack_plugin_1.default(),
402
+ new arui_runtime_1.AruiRuntimePlugin(),
400
403
  // production plugins:
401
404
  mode === 'prod' && new webpack_manifest_plugin_1.WebpackManifestPlugin(),
402
405
  mode === 'prod' &&
@@ -5,9 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
7
7
  const find_loader_1 = require("./util/find-loader");
8
+ const find_plugin_1 = require("./util/find-plugin");
8
9
  const webpack_client_1 = require("./webpack.client");
9
10
  const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackProd', 'webpackClientProd'], (0, webpack_client_1.createClientWebpackConfig)('prod'), {
10
11
  createSingleClientWebpackConfig: webpack_client_1.createSingleClientWebpackConfig.bind(null, 'prod'),
11
12
  findLoader: find_loader_1.findLoader,
13
+ findPlugin: (0, find_plugin_1.findPlugin)(),
12
14
  });
13
15
  exports.default = config;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
7
7
  const find_loader_1 = require("./util/find-loader");
8
+ const find_plugin_1 = require("./util/find-plugin");
8
9
  const webpack_server_1 = require("./webpack.server");
9
- const config = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackDev', 'webpackServerDev'], (0, webpack_server_1.createServerConfig)('dev'), { findLoader: find_loader_1.findLoader });
10
+ const config = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackDev', 'webpackServerDev'], (0, webpack_server_1.createServerConfig)('dev'), { findLoader: find_loader_1.findLoader, findPlugin: (0, find_plugin_1.findPlugin)() });
10
11
  exports.default = config;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
7
7
  const find_loader_1 = require("./util/find-loader");
8
+ const find_plugin_1 = require("./util/find-plugin");
8
9
  const webpack_server_1 = require("./webpack.server");
9
- const config = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackProd', 'webpackServerProd'], (0, webpack_server_1.createServerConfig)('prod'), { findLoader: find_loader_1.findLoader });
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)() });
10
11
  exports.default = config;
@@ -0,0 +1,7 @@
1
+ import webpack from 'webpack';
2
+ export declare const ARUI_RUNTIME_VARIABLE_NAME = "$ARUI";
3
+ export declare const FULL_ARUI_RUNTIME_PATH: string;
4
+ export declare class RuntimeModule extends webpack.RuntimeModule {
5
+ constructor();
6
+ generate(): string;
7
+ }
@@ -0,0 +1,23 @@
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.RuntimeModule = exports.FULL_ARUI_RUNTIME_PATH = exports.ARUI_RUNTIME_VARIABLE_NAME = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ exports.ARUI_RUNTIME_VARIABLE_NAME = '$ARUI';
9
+ exports.FULL_ARUI_RUNTIME_PATH = `${webpack_1.default.RuntimeGlobals.require}.${exports.ARUI_RUNTIME_VARIABLE_NAME}`;
10
+ class RuntimeModule extends webpack_1.default.RuntimeModule {
11
+ constructor() {
12
+ super('AruiRuntimeModule', webpack_1.default.RuntimeModule.STAGE_BASIC);
13
+ }
14
+ // eslint-disable-next-line class-methods-use-this
15
+ generate() {
16
+ return webpack_1.default.Template.asString([
17
+ "if (typeof __webpack_modules__ !== 'undefined') {",
18
+ `${exports.FULL_ARUI_RUNTIME_PATH} = { scriptSource: document.currentScript };`,
19
+ '}',
20
+ ]);
21
+ }
22
+ }
23
+ exports.RuntimeModule = RuntimeModule;
@@ -0,0 +1,11 @@
1
+ import webpack from 'webpack';
2
+ export declare class AruiRuntimePlugin {
3
+ apply(compiler: webpack.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,50 @@
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.getInsertCssRuntimeMethod = exports.AruiRuntimePlugin = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const arui_runtime_module_1 = require("./arui-runtime-module");
9
+ class AruiRuntimePlugin {
10
+ apply(compiler) {
11
+ compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
12
+ compilation.hooks.runtimeRequirementInTree
13
+ .for(webpack_1.default.RuntimeGlobals.require)
14
+ .tap(this.constructor.name, (chunk) => {
15
+ compilation.addRuntimeModule(chunk, new arui_runtime_module_1.RuntimeModule());
16
+ return true;
17
+ });
18
+ });
19
+ }
20
+ }
21
+ exports.AruiRuntimePlugin = AruiRuntimePlugin;
22
+ /**
23
+ * Метод для вставки runtime чанков css в документ. Нужен для того, чтобы модули могли использовать shadow-dom.
24
+ * Функция, которую возвращает этот метод - НЕ прогоняется через babel, поэтому он должен быть написан на чистом js,
25
+ * без использования синтаксиса, который не поддерживается браузерами.
26
+ * Более того, мы не можем использовать импорты или require внутри, это так же сломает сборку.
27
+ */
28
+ function getInsertCssRuntimeMethod() {
29
+ /* eslint-disable */
30
+ return function insertCssRuntime(linkTag) {
31
+ if (__webpack_require__ && __webpack_require__.$ARUI.scriptSource) {
32
+ var scriptSource = __webpack_require__.$ARUI.scriptSource;
33
+ var targetElementSelector = scriptSource.getAttribute('data-resources-target-selector');
34
+ if (targetElementSelector) {
35
+ var targetElement = document.querySelector(targetElementSelector);
36
+ if (targetElement) {
37
+ if (targetElement.shadowRoot) {
38
+ targetElement.shadowRoot.appendChild(linkTag);
39
+ return;
40
+ }
41
+ targetElement.appendChild(linkTag);
42
+ return;
43
+ }
44
+ }
45
+ }
46
+ document.head.appendChild(linkTag);
47
+ };
48
+ /* eslint-enable */
49
+ }
50
+ exports.getInsertCssRuntimeMethod = getInsertCssRuntimeMethod;