arui-scripts 15.3.0 → 15.4.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +0 -0
  2. package/.turbo/turbo-test.log +91 -0
  3. package/CHANGELOG.md +270 -656
  4. package/README.md +27 -1
  5. package/bin/build.sh +2 -1
  6. package/build/commands/build/build-wrapper.d.ts +2 -2
  7. package/build/commands/build/client.js +3 -3
  8. package/build/commands/bundle-analyze/index.js +15 -15
  9. package/build/commands/changelog/index.js +2 -2
  10. package/build/commands/util/make-tmp-dir.d.ts +1 -1
  11. package/build/commands/util/make-tmp-dir.js +2 -2
  12. package/build/commands/util/run-client-dev-server.d.ts +1 -1
  13. package/build/commands/util/run-client-dev-server.js +1 -4
  14. package/build/configs/app-configs/calculate-dependent-config.d.ts +54 -8
  15. package/build/configs/app-configs/calculate-dependent-config.js +11 -13
  16. package/build/configs/app-configs/get-defaults.d.ts +3 -2
  17. package/build/configs/app-configs/get-defaults.js +69 -55
  18. package/build/configs/app-configs/index.d.ts +5 -3
  19. package/build/configs/app-configs/index.js +13 -7
  20. package/build/configs/app-configs/types.d.ts +51 -38
  21. package/build/configs/app-configs/update-with-config-file.d.ts +2 -2
  22. package/build/configs/app-configs/update-with-config-file.js +5 -7
  23. package/build/configs/app-configs/update-with-env.js +3 -8
  24. package/build/configs/app-configs/update-with-package.d.ts +2 -2
  25. package/build/configs/app-configs/update-with-package.js +5 -10
  26. package/build/configs/app-configs/update-with-presets.d.ts +2 -2
  27. package/build/configs/app-configs/update-with-presets.js +8 -15
  28. package/build/configs/app-configs/validate-settings-keys.d.ts +2 -5
  29. package/build/configs/app-configs/validate-settings-keys.js +6 -7
  30. package/build/configs/babel-client.d.ts +33 -1
  31. package/build/configs/babel-dependencies.d.ts +14 -1
  32. package/build/configs/babel-server.d.ts +26 -1
  33. package/build/configs/dev-server.d.ts +15 -1
  34. package/build/configs/jest/index.d.ts +33 -1
  35. package/build/configs/postcss.config.d.ts +1 -1
  36. package/build/configs/postcss.d.ts +1 -1
  37. package/build/configs/process-assets-plugin-output.d.ts +2 -0
  38. package/build/configs/process-assets-plugin-output.js +32 -0
  39. package/build/configs/server-externals-exemptions.d.ts +1 -1
  40. package/build/configs/util/apply-overrides.d.ts +23 -7
  41. package/build/configs/util/apply-overrides.js +3 -2
  42. package/build/configs/util/get-entry.d.ts +2 -1
  43. package/build/configs/webpack.client.d.ts +10 -2
  44. package/build/configs/webpack.client.dev.js +1 -1
  45. package/build/configs/webpack.client.js +42 -13
  46. package/build/configs/webpack.client.prod.js +1 -1
  47. package/build/index.d.ts +1 -1
  48. package/build/tsconfig-local.tsbuildinfo +1 -1
  49. package/package.json +1 -1
  50. package/build/configs/app-configs/available-package-settings.d.ts +0 -8
  51. package/build/configs/app-configs/available-package-settings.js +0 -34
@@ -1,12 +1,7 @@
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.updateWithEnv = void 0;
7
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
- const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
9
- const available_package_settings_1 = require("./available-package-settings");
4
+ const validate_settings_keys_1 = require("./validate-settings-keys");
10
5
  function updateWithEnv(config) {
11
6
  if (!process.env.ARUI_SCRIPTS_CONFIG) {
12
7
  return config;
@@ -14,8 +9,8 @@ function updateWithEnv(config) {
14
9
  try {
15
10
  console.warn('Используйте ARUI_SCRIPTS_CONFIG только для отладки');
16
11
  const envSettings = JSON.parse(process.env.ARUI_SCRIPTS_CONFIG);
17
- (0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, envSettings);
18
- return (0, lodash_merge_1.default)(config, envSettings);
12
+ (0, validate_settings_keys_1.validateSettingsKeys)(config, envSettings, 'ENV');
13
+ return Object.assign(Object.assign({}, config), envSettings);
19
14
  }
20
15
  catch (e) {
21
16
  console.error(e);
@@ -1,2 +1,2 @@
1
- import { AppConfigs } from './types';
2
- export declare function updateWithPackage(config: AppConfigs): any;
1
+ import { AppConfigs, AppContext } from './types';
2
+ export declare function updateWithPackage(config: AppConfigs, context: AppContext): any;
@@ -1,15 +1,10 @@
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.updateWithPackage = void 0;
7
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
- const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
9
- const available_package_settings_1 = require("./available-package-settings");
10
- function updateWithPackage(config) {
11
- const packageSettings = config.appPackage.aruiScripts || {};
12
- (0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, packageSettings);
13
- return (0, lodash_merge_1.default)(config, packageSettings);
4
+ const validate_settings_keys_1 = require("./validate-settings-keys");
5
+ function updateWithPackage(config, context) {
6
+ const packageSettings = context.appPackage.aruiScripts || {};
7
+ (0, validate_settings_keys_1.validateSettingsKeys)(config, packageSettings, 'package.json');
8
+ return Object.assign(Object.assign({}, config), packageSettings);
14
9
  }
15
10
  exports.updateWithPackage = updateWithPackage;
@@ -1,2 +1,2 @@
1
- import { AppConfigs } from './types';
2
- export declare function updateWithPresets(config: AppConfigs): AppConfigs;
1
+ import { AppConfigs, AppContext } from './types';
2
+ export declare function updateWithPresets(config: AppConfigs, context: AppContext): AppConfigs;
@@ -1,33 +1,26 @@
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.updateWithPresets = void 0;
7
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
4
  const resolve_1 = require("../util/resolve");
9
- const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
10
- const available_package_settings_1 = require("./available-package-settings");
11
- function updateWithPresets(config) {
12
- const packageSettings = config.appPackage.aruiScripts || {};
13
- if (!packageSettings.presets) {
5
+ const validate_settings_keys_1 = require("./validate-settings-keys");
6
+ function updateWithPresets(config, context) {
7
+ if (!config.presets) {
14
8
  return config;
15
9
  }
16
- const presetsConfigPath = (0, resolve_1.tryResolve)(`${packageSettings.presets}/arui-scripts.config`, { paths: [config.cwd] });
17
- const presetsOverridesPath = (0, resolve_1.tryResolve)(`${packageSettings.presets}/arui-scripts.overrides`, { paths: [config.cwd] });
10
+ const presetsConfigPath = (0, resolve_1.tryResolve)(`${config.presets}/arui-scripts.config`, { paths: [context.cwd] });
11
+ const presetsOverridesPath = (0, resolve_1.tryResolve)(`${config.presets}/arui-scripts.overrides`, { paths: [context.cwd] });
18
12
  if (presetsConfigPath) {
19
13
  let presetsSettings = require(presetsConfigPath);
20
14
  if (presetsSettings.__esModule) {
21
15
  // ts-node импортирует esModules, из них надо вытягивать default именно так
22
16
  presetsSettings = presetsSettings.default;
23
17
  }
24
- (0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, presetsSettings);
25
- config = (0, lodash_merge_1.default)(config, presetsSettings);
18
+ (0, validate_settings_keys_1.validateSettingsKeys)(config, presetsSettings, presetsConfigPath);
19
+ config = Object.assign(Object.assign({}, config), presetsSettings);
26
20
  }
27
21
  if (presetsOverridesPath) {
28
- config.overridesPath.unshift(presetsOverridesPath);
22
+ context.overridesPath.unshift(presetsOverridesPath);
29
23
  }
30
- delete packageSettings.presets;
31
24
  return config;
32
25
  }
33
26
  exports.updateWithPresets = updateWithPresets;
@@ -1,7 +1,4 @@
1
1
  /**
2
- * Функция проверяет что все ключи объекта settingsObject есть в массиве availableKeys
3
- * @param {string[]} availableKeys Массив допустимых настроек
4
- * @param settingsObject Объект с настройками
2
+ * Функция проверяет что все ключи объекта settingsObject есть в уже существующей конфигурации
5
3
  */
6
- declare function validateSettingsKeys(availableKeys: ReadonlyArray<string>, settingsObject: Record<string, unknown>): void;
7
- export default validateSettingsKeys;
4
+ export declare function validateSettingsKeys(existingConfig: Record<string, unknown>, settingsObject: Record<string, unknown>, source?: string): void;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSettingsKeys = void 0;
3
4
  /**
4
- * Функция проверяет что все ключи объекта settingsObject есть в массиве availableKeys
5
- * @param {string[]} availableKeys Массив допустимых настроек
6
- * @param settingsObject Объект с настройками
5
+ * Функция проверяет что все ключи объекта settingsObject есть в уже существующей конфигурации
7
6
  */
8
- function validateSettingsKeys(availableKeys, settingsObject) {
7
+ function validateSettingsKeys(existingConfig, settingsObject, source) {
9
8
  Object.keys(settingsObject).forEach((setting) => {
10
- if (!availableKeys.includes(setting)) {
11
- console.warn('\x1b[33m', `Setting`, '\x1b[31m', setting, '\x1b[33m', 'is not supported!');
9
+ if (typeof existingConfig[setting] === 'undefined') {
10
+ console.warn(`Неизвестная настройка "${setting}" в ${source || 'конфигурации'}`);
12
11
  }
13
12
  });
14
13
  }
15
- exports.default = validateSettingsKeys;
14
+ exports.validateSettingsKeys = validateSettingsKeys;
@@ -1,2 +1,34 @@
1
- declare const babelClientConfig: any;
1
+ declare const babelClientConfig: {
2
+ presets: (string | false | (string | {
3
+ targets: {
4
+ browsers: string[];
5
+ };
6
+ loose: boolean;
7
+ useBuiltIns: string;
8
+ corejs: number;
9
+ exclude: string[];
10
+ })[])[];
11
+ plugins: (string | (string | {
12
+ legacy: boolean;
13
+ })[] | (string | {
14
+ loose: boolean;
15
+ })[] | (string | {
16
+ useBuiltIns: boolean;
17
+ })[] | (string | {
18
+ corejs: boolean;
19
+ helpers: boolean;
20
+ version: string;
21
+ regenerator: boolean;
22
+ })[])[];
23
+ env: {
24
+ production: {
25
+ plugins: (string | (string | {
26
+ removeImport: boolean;
27
+ })[])[];
28
+ };
29
+ test: {
30
+ plugins: string[];
31
+ };
32
+ };
33
+ };
2
34
  export default babelClientConfig;
@@ -1 +1,14 @@
1
- export declare const babelDependencies: any;
1
+ export declare const babelDependencies: {
2
+ sourceType: string;
3
+ presets: (string | {
4
+ useBuiltIns: string;
5
+ corejs: number;
6
+ exclude: string[];
7
+ })[][];
8
+ plugins: (string | {
9
+ corejs: boolean;
10
+ helpers: boolean;
11
+ version: string;
12
+ regenerator: boolean;
13
+ })[][];
14
+ };
@@ -1,2 +1,27 @@
1
- declare const config: any;
1
+ declare const config: {
2
+ presets: (string | false | (string | {
3
+ modules: boolean;
4
+ targets: {
5
+ node: string;
6
+ };
7
+ loose: boolean;
8
+ })[])[];
9
+ plugins: (string | (string | {
10
+ legacy: boolean;
11
+ })[] | (string | {
12
+ loose: boolean;
13
+ })[] | (string | {
14
+ useBuiltIns: boolean;
15
+ })[] | (string | {
16
+ helpers: boolean;
17
+ })[])[];
18
+ env: {
19
+ production: {
20
+ plugins: string[];
21
+ };
22
+ test: {
23
+ plugins: string[];
24
+ };
25
+ };
26
+ };
2
27
  export default config;
@@ -1,2 +1,16 @@
1
- declare const devServerConfig: import("webpack-dev-server").Configuration;
1
+ declare const devServerConfig: {
2
+ port: number;
3
+ liveReload: boolean;
4
+ client: {
5
+ overlay: {
6
+ errors: boolean;
7
+ warnings: boolean;
8
+ };
9
+ };
10
+ devMiddleware: {
11
+ publicPath: string;
12
+ };
13
+ static: string[];
14
+ proxy: any;
15
+ };
2
16
  export default devServerConfig;
@@ -13,6 +13,38 @@ export const snapshotSerializers: string[];
13
13
  export const globals: {
14
14
  'ts-jest': {
15
15
  tsconfig: string | null;
16
- babelConfig: any;
16
+ babelConfig: {
17
+ presets: (string | false | (string | {
18
+ targets: {
19
+ browsers: string[];
20
+ };
21
+ loose: boolean;
22
+ useBuiltIns: string;
23
+ corejs: number;
24
+ exclude: string[];
25
+ })[])[];
26
+ plugins: (string | (string | {
27
+ legacy: boolean;
28
+ })[] | (string | {
29
+ loose: boolean;
30
+ })[] | (string | {
31
+ useBuiltIns: boolean;
32
+ })[] | (string | {
33
+ corejs: boolean;
34
+ helpers: boolean;
35
+ version: string;
36
+ regenerator: boolean;
37
+ })[])[];
38
+ env: {
39
+ production: {
40
+ plugins: (string | (string | {
41
+ removeImport: boolean;
42
+ })[])[];
43
+ };
44
+ test: {
45
+ plugins: string[];
46
+ };
47
+ };
48
+ };
17
49
  };
18
50
  };
@@ -4,7 +4,7 @@
4
4
  * @param {Object} options коллекция конфигураций плагинов, где ключ - название плагина, а значение - аргумент для инициализации
5
5
  * @returns {*}
6
6
  */
7
- export declare function createPostcssConfig(plugins: string[], options: Record<string, unknown>): (string | unknown[])[];
7
+ export declare function createPostcssConfig(plugins: string[], options: Record<string, unknown>): string[] | unknown[];
8
8
  export declare const postcssPlugins: string[];
9
9
  export declare const postcssPluginsOptions: {
10
10
  'postcss-import': {
@@ -1,2 +1,2 @@
1
- declare const postcssConfig: any[];
1
+ declare const postcssConfig: string[] | unknown[];
2
2
  export default postcssConfig;
@@ -0,0 +1,2 @@
1
+ import { Assets } from 'assets-webpack-plugin';
2
+ export declare function processAssetsPluginOutput(assets: Assets): string;
@@ -0,0 +1,32 @@
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.processAssetsPluginOutput = void 0;
7
+ const app_configs_1 = __importDefault(require("./app-configs"));
8
+ function processAssetsPluginOutput(assets) {
9
+ let adjustedAssets = assets;
10
+ Object.keys(adjustedAssets).forEach((key) => {
11
+ // заменяем путь к файлам на корректный в случае если в нем есть 'auto/'
12
+ adjustedAssets[key] = {
13
+ css: replaceAutoPath(adjustedAssets[key].css),
14
+ js: replaceAutoPath(adjustedAssets[key].js),
15
+ };
16
+ });
17
+ const result = Object.assign(Object.assign({}, adjustedAssets), { __metadata__: {
18
+ version: app_configs_1.default.version,
19
+ name: app_configs_1.default.normalizedName,
20
+ } });
21
+ return JSON.stringify(result);
22
+ }
23
+ exports.processAssetsPluginOutput = processAssetsPluginOutput;
24
+ function replaceAutoPath(assets) {
25
+ if (!assets) {
26
+ return assets;
27
+ }
28
+ if (Array.isArray(assets)) {
29
+ return assets.map((asset) => asset.replace(/^auto\//, app_configs_1.default.publicPath));
30
+ }
31
+ return assets.replace(/^auto\//, app_configs_1.default.publicPath);
32
+ }
@@ -1 +1 @@
1
- export declare const serverExternalsExemptions: (string | RegExp)[];
1
+ export declare const serverExternalsExemptions: RegExp[];
@@ -1,15 +1,16 @@
1
1
  import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
2
2
  import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
3
3
  import { AppConfigs } from '../app-configs/types';
4
+ import { createSingleClientWebpackConfig } from "../webpack.client";
4
5
  type Overrides = {
5
- webpack: WebpackConfiguration;
6
- webpackClient: WebpackConfiguration;
7
- webpackDev: WebpackConfiguration;
8
- webpackClientDev: WebpackConfiguration;
6
+ webpack: WebpackConfiguration | WebpackConfiguration[];
7
+ webpackClient: WebpackConfiguration | WebpackConfiguration[];
8
+ webpackDev: WebpackConfiguration | WebpackConfiguration[];
9
+ webpackClientDev: WebpackConfiguration | WebpackConfiguration[];
9
10
  webpackServer: WebpackConfiguration;
10
11
  webpackServerDev: WebpackConfiguration;
11
12
  webpackProd: WebpackConfiguration;
12
- webpackClientProd: WebpackConfiguration;
13
+ webpackClientProd: WebpackConfiguration | WebpackConfiguration[];
13
14
  webpackServerProd: WebpackConfiguration;
14
15
  devServer: WebpackDevServerConfiguration;
15
16
  stats: WebpackOptionsNormalized['stats'];
@@ -26,7 +27,21 @@ type Overrides = {
26
27
  'start.sh': string;
27
28
  serverExternalsExemptions: Array<string | RegExp>;
28
29
  };
29
- type OverrideFunction<K extends keyof Overrides> = (config: Overrides[K], appConfig: AppConfigs) => Overrides[K];
30
+ type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
31
+ type BoundCreateSingleClientWebpackConfig = OmitFirstArg<typeof createSingleClientWebpackConfig>;
32
+ type ClientWebpackAdditionalArgs = {
33
+ createSingleClientWebpackConfig: BoundCreateSingleClientWebpackConfig;
34
+ };
35
+ /**
36
+ * Дополнительные аргументы, которые будут переданы в функцию оверрайда
37
+ */
38
+ type OverridesAdditionalArgs = {
39
+ webpack: ClientWebpackAdditionalArgs;
40
+ webpackClient: ClientWebpackAdditionalArgs;
41
+ webpackDev: ClientWebpackAdditionalArgs;
42
+ webpackClientDev: ClientWebpackAdditionalArgs;
43
+ };
44
+ type OverrideFunction<K extends keyof Overrides, AdditionalArgs = K extends keyof OverridesAdditionalArgs ? OverridesAdditionalArgs[K] : undefined> = (config: Overrides[K], appConfig: AppConfigs, additionalArgs: AdditionalArgs) => Overrides[K];
30
45
  export type OverrideFile = {
31
46
  [K in keyof Overrides]?: OverrideFunction<K>;
32
47
  };
@@ -34,7 +49,8 @@ export type OverrideFile = {
34
49
  *
35
50
  * @param {String|String[]} overridesKey Ключи оверрайда
36
51
  * @param {Object} config Конфиг, к которому нужно применить оверрайды
52
+ * @param args Дополнительные аргументы, которые будут переданы в функцию оверрайда
37
53
  * @returns {*}
38
54
  */
39
- declare function applyOverrides<Key extends keyof Overrides>(overridesKey: Key | Key[], config: Overrides[Key]): Overrides[Key];
55
+ declare function applyOverrides<T extends Overrides[Key], Key extends keyof Overrides, Args = Key extends keyof OverridesAdditionalArgs ? OverridesAdditionalArgs[Key] : undefined>(overridesKey: Key | Key[], config: T, args?: any): T;
40
56
  export default applyOverrides;
@@ -24,9 +24,10 @@ overrides = app_configs_1.default.overridesPath.map(path => {
24
24
  *
25
25
  * @param {String|String[]} overridesKey Ключи оверрайда
26
26
  * @param {Object} config Конфиг, к которому нужно применить оверрайды
27
+ * @param args Дополнительные аргументы, которые будут переданы в функцию оверрайда
27
28
  * @returns {*}
28
29
  */
29
- function applyOverrides(overridesKey, config) {
30
+ function applyOverrides(overridesKey, config, args) {
30
31
  if (typeof overridesKey === 'string') {
31
32
  overridesKey = [overridesKey];
32
33
  }
@@ -37,7 +38,7 @@ function applyOverrides(overridesKey, config) {
37
38
  if (typeof overrideFn !== 'function') {
38
39
  throw new TypeError(`Override ${key} must be a function`);
39
40
  }
40
- config = overrideFn(config, app_configs_1.default);
41
+ config = overrideFn(config, app_configs_1.default, args);
41
42
  }
42
43
  });
43
44
  });
@@ -1,8 +1,9 @@
1
+ export type Entry = string | string[] | Record<string, string | string[]>;
1
2
  /**
2
3
  * @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
3
4
  * @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
4
5
  * @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
5
6
  * @returns {*}
6
7
  */
7
- declare function getEntry<AdditionalArgs extends unknown[]>(entryPoint: string | string[] | Record<string, string | string[]>, getSingleEntry: (entry: string[], ...args: AdditionalArgs) => string[], ...args: AdditionalArgs): string[] | Record<string, string | string[]>;
8
+ declare function getEntry<AdditionalArgs extends unknown[]>(entryPoint: Entry, getSingleEntry: (entry: string[], ...args: AdditionalArgs) => string[], ...args: AdditionalArgs): string[] | Record<string, string | string[]>;
8
9
  export default getEntry;
@@ -1,2 +1,10 @@
1
- import { Configuration } from 'webpack';
2
- export declare const createClientWebpackConfig: (mode: 'dev' | 'prod') => Configuration;
1
+ import webpack, { Configuration } from 'webpack';
2
+ import { Entry } from './util/get-entry';
3
+ /**
4
+ * Создает конфигурацию для сборки клиентского кода. Может быть использована для создания дополнительных конфигураций.
5
+ * @param mode Режим сборки (dev или prod)
6
+ * @param entry Точка входа, любой валидный вход для webpack
7
+ * @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
8
+ */
9
+ export declare const createSingleClientWebpackConfig: (mode: 'dev' | 'prod', entry: Entry, configName?: string) => Configuration;
10
+ export declare const createClientWebpackConfig: (mode: 'dev' | 'prod') => webpack.Configuration;
@@ -5,5 +5,5 @@ 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 webpack_client_1 = require("./webpack.client");
8
- const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], (0, webpack_client_1.createClientWebpackConfig)('dev'));
8
+ const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], (0, webpack_client_1.createClientWebpackConfig)('dev'), { createSingleClientWebpackConfig: webpack_client_1.createSingleClientWebpackConfig.bind(null, 'dev') });
9
9
  exports.default = config;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createClientWebpackConfig = void 0;
6
+ exports.createClientWebpackConfig = exports.createSingleClientWebpackConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const webpack_1 = __importDefault(require("webpack"));
9
9
  const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
@@ -14,7 +14,6 @@ const compression_webpack_plugin_1 = __importDefault(require("compression-webpac
14
14
  const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
15
15
  const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
16
16
  const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
17
- const PnpWebpackPlugin = require('pnp-webpack-plugin');
18
17
  const get_entry_1 = __importDefault(require("./util/get-entry"));
19
18
  const app_configs_1 = __importDefault(require("./app-configs"));
20
19
  const babel_client_1 = __importDefault(require("./babel-client"));
@@ -27,24 +26,42 @@ const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sens
27
26
  const webpack_deduplication_plugin_1 = require("webpack-deduplication-plugin");
28
27
  const minimizers_1 = require("./config-extras/minimizers");
29
28
  const mini_svg_data_uri_1 = __importDefault(require("mini-svg-data-uri"));
29
+ const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
30
+ const PnpWebpackPlugin = require('pnp-webpack-plugin');
30
31
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
31
32
  const noopPath = require.resolve('./util/noop');
32
33
  function getSingleEntry(entryPoint, mode) {
33
34
  return [
34
35
  ...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
35
- mode === 'dev' ? require.resolve('webpack/hot/dev-server') : false,
36
36
  ...entryPoint
37
37
  ].filter(Boolean);
38
38
  }
39
- // This is the production configuration.
40
- const createClientWebpackConfig = (mode) => ({
39
+ // Нам важно шарить assets plugin между разными сборками, чтобы файл не перезаписывался
40
+ const assetsPlugin = new assets_webpack_plugin_1.default({
41
+ path: app_configs_1.default.serverOutputPath,
42
+ processOutput: process_assets_plugin_output_1.processAssetsPluginOutput,
43
+ });
44
+ // Этот плагин нужен для того, чтобы клиентский код так же могу получить информацию о сборке.
45
+ // Это позволяет нам использовать данные о сборки на клиенте.
46
+ const clientAssetsPlugin = new assets_webpack_plugin_1.default({
47
+ path: app_configs_1.default.clientOutputPath,
48
+ processOutput: process_assets_plugin_output_1.processAssetsPluginOutput,
49
+ });
50
+ /**
51
+ * Создает конфигурацию для сборки клиентского кода. Может быть использована для создания дополнительных конфигураций.
52
+ * @param mode Режим сборки (dev или prod)
53
+ * @param entry Точка входа, любой валидный вход для webpack
54
+ * @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
55
+ */
56
+ const createSingleClientWebpackConfig = (mode, entry, configName) => ({
41
57
  target: 'web',
42
58
  mode: mode === 'dev' ? 'development' : 'production',
43
59
  devtool: mode === 'dev' ? app_configs_1.default.devSourceMaps : 'source-map',
44
- entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry, mode),
60
+ entry: (0, get_entry_1.default)(entry, getSingleEntry, mode),
45
61
  // in production mode we need to fail on first error
46
62
  bail: mode === 'prod',
47
63
  context: app_configs_1.default.cwd,
64
+ name: configName,
48
65
  output: {
49
66
  assetModuleFilename: 'static/media/[name].[hash:8][ext]',
50
67
  // Add /* filename */ comments to generated require()s in the output.
@@ -52,7 +69,9 @@ const createClientWebpackConfig = (mode) => ({
52
69
  path: app_configs_1.default.clientOutputPath,
53
70
  publicPath: app_configs_1.default.publicPath,
54
71
  filename: mode === 'dev' ? '[name].js' : '[name].[chunkhash:8].js',
55
- chunkFilename: mode === 'dev' ? '[name].js' : '[name].[chunkhash:8].chunk.js',
72
+ chunkFilename: mode === 'dev'
73
+ ? `${configName ? `${configName}-` : ''}[name].js`
74
+ : `${configName ? `${configName}-` : ''}[name].[chunkhash:8].chunk.js`,
56
75
  // Point sourcemap entries to original disk location (format as URL on Windows)
57
76
  devtoolModuleFilenameTemplate: (info) => path_1.default
58
77
  .relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
@@ -72,7 +91,14 @@ const createClientWebpackConfig = (mode) => ({
72
91
  vendor: {
73
92
  test: /node_modules/,
74
93
  chunks: "initial",
75
- name: "vendor",
94
+ name: (_, chunks, cacheGroupKey) => {
95
+ if (!configName) {
96
+ return 'vendor';
97
+ }
98
+ // Нам нужно сделать так, чтобы у разных конфигураций были разные имена чанков
99
+ const allChunksNames = chunks.map((item) => item.name).join('~');
100
+ return `${cacheGroupKey}-${allChunksNames}`;
101
+ },
76
102
  priority: 10,
77
103
  enforce: true
78
104
  }
@@ -296,7 +322,8 @@ const createClientWebpackConfig = (mode) => ({
296
322
  ],
297
323
  },
298
324
  plugins: ([
299
- new assets_webpack_plugin_1.default({ path: app_configs_1.default.serverOutputPath }),
325
+ assetsPlugin,
326
+ clientAssetsPlugin,
300
327
  new webpack_1.default.DefinePlugin(Object.assign({
301
328
  // Tell Webpack to provide empty mocks for process.env.
302
329
  'process.env': '{}' }, (mode === 'dev'
@@ -363,11 +390,13 @@ const createClientWebpackConfig = (mode) => ({
363
390
  ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
364
391
  aggregateTimeout: 100,
365
392
  },
366
- // Turn off performance hints during development because we don't do any
367
- // splitting or minification in interest of speed. These warnings become
368
- // cumbersome.
393
+ // Выключаем performance hints, т.к. размеры бандлов контролируются не в рамках arui-scripts
369
394
  performance: {
370
- hints: mode === 'dev' ? false : 'warning',
395
+ hints: false,
371
396
  },
372
397
  });
398
+ exports.createSingleClientWebpackConfig = createSingleClientWebpackConfig;
399
+ const createClientWebpackConfig = (mode) => {
400
+ return (0, exports.createSingleClientWebpackConfig)(mode, app_configs_1.default.clientEntry);
401
+ };
373
402
  exports.createClientWebpackConfig = createClientWebpackConfig;
@@ -5,5 +5,5 @@ 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 webpack_client_1 = require("./webpack.client");
8
- const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackProd', 'webpackClientProd'], (0, webpack_client_1.createClientWebpackConfig)('prod'));
8
+ const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackProd', 'webpackClientProd'], (0, webpack_client_1.createClientWebpackConfig)('prod'), { createSingleClientWebpackConfig: webpack_client_1.createSingleClientWebpackConfig.bind(null, 'prod') });
9
9
  exports.default = config;
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { OverrideFile } from './configs/util/apply-overrides';
2
- export type { PackageSettings } from './configs/app-configs/available-package-settings';
2
+ export type { AppConfigs, PackageSettings } from './configs/app-configs/types';
3
3
  export { prepareFilesForDocker } from './commands/util/docker-build';
4
4
  export { getBuildParamsFromArgs } from './commands/util/docker-build';
5
5
  export { getDockerBuildCommand } from './commands/util/docker-build';