arui-scripts 17.4.0 → 18.1.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 (55) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.turbo/turbo-lint.log +27 -105
  3. package/.turbo/turbo-test.log +7 -4
  4. package/CHANGELOG.md +33 -0
  5. package/build/commands/changelog/index.js +22 -27
  6. package/build/commands/start/print-compiler-output.js +1 -1
  7. package/build/commands/start-prod/index.js +1 -1
  8. package/build/commands/util/client-assets-sizes.js +2 -3
  9. package/build/commands/util/docker-build.js +6 -7
  10. package/build/commands/util/run-client-dev-server.js +1 -2
  11. package/build/commands/util/run-compilers.js +1 -2
  12. package/build/commands/util/run-server-watch-compiler.js +2 -3
  13. package/build/commands/util/tsc.js +1 -2
  14. package/build/commands/util/yarn.js +3 -4
  15. package/build/configs/app-configs/calculate-dependent-config.d.ts +1 -75
  16. package/build/configs/app-configs/calculate-dependent-config.js +3 -4
  17. package/build/configs/app-configs/get-defaults.js +5 -4
  18. package/build/configs/app-configs/read-config-file.js +2 -3
  19. package/build/configs/app-configs/types.d.ts +13 -2
  20. package/build/configs/app-configs/update-with-config-file.js +1 -2
  21. package/build/configs/app-configs/update-with-env.js +1 -2
  22. package/build/configs/app-configs/update-with-package.js +1 -2
  23. package/build/configs/app-configs/update-with-presets.js +2 -3
  24. package/build/configs/app-configs/validate-settings-keys.js +1 -2
  25. package/build/configs/app-configs/warn-about-deprecations.js +4 -3
  26. package/build/configs/client-env-config/add-env-to-html-template.js +1 -2
  27. package/build/configs/client-env-config/get-env-config.js +2 -3
  28. package/build/configs/jest/index.d.ts +3 -3
  29. package/build/configs/jest/settings.d.ts +11 -11
  30. package/build/configs/jest/settings.js +29 -13
  31. package/build/configs/modules.js +20 -12
  32. package/build/configs/postcss.config.js +2 -2
  33. package/build/configs/process-assets-plugin-output.js +1 -2
  34. package/build/configs/swc.d.ts +4 -0
  35. package/build/configs/swc.js +35 -0
  36. package/build/configs/util/apply-overrides.d.ts +5 -0
  37. package/build/configs/util/find-loader.js +1 -2
  38. package/build/configs/util/find-plugin.d.ts +0 -1
  39. package/build/configs/util/find-plugin.js +1 -2
  40. package/build/configs/util/get-polyfills.d.ts +0 -1
  41. package/build/configs/util/get-polyfills.js +1 -2
  42. package/build/configs/util/get-webpack-cache-dependencies.js +1 -2
  43. package/build/configs/util/resolve.js +2 -3
  44. package/build/configs/webpack.client.d.ts +2 -2
  45. package/build/configs/webpack.client.js +84 -61
  46. package/build/configs/webpack.server.d.ts +1 -1
  47. package/build/configs/webpack.server.js +70 -46
  48. package/build/plugins/arui-runtime/arui-runtime-module.js +1 -1
  49. package/build/plugins/arui-runtime/index.js +2 -2
  50. package/build/templates/dockerfile.template.js +1 -1
  51. package/build/tsconfig-local.tsbuildinfo +1 -1
  52. package/docs/modules.md +25 -3
  53. package/docs/overrides.md +3 -0
  54. package/docs/settings.md +27 -0
  55. package/package.json +15 -10
@@ -2,81 +2,7 @@ import { AppConfigs, AppContext } from './types';
2
2
  /**
3
3
  * Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
4
4
  */
5
- export declare function calculateDependentConfig(config: AppConfigs): {
6
- clientPolyfillsEntry: string[];
7
- clientServerPort: number;
8
- serverPort: number;
9
- debug: boolean;
10
- devSourceMaps: string;
11
- devServerCors: boolean;
12
- useServerHMR: boolean;
13
- presets: string | null;
14
- proxy: {
15
- [url: string]: import("webpack-dev-server").ProxyConfigArrayItem;
16
- } | null;
17
- clientOnly: boolean;
18
- buildPath: string;
19
- assetsPath: string;
20
- additionalBuildPath: string[];
21
- statsOutputFilename: string;
22
- serverEntry: string | string[] | Record<string, string | string[]>;
23
- serverOutput: string;
24
- clientEntry: string | string[] | Record<string, string | string[]>;
25
- dockerRegistry: string;
26
- baseDockerImage: string;
27
- nginxRootPath: string;
28
- runFromNonRootUser: boolean;
29
- removeDevDependenciesDuringDockerBuild: boolean;
30
- archiveName: string;
31
- keepPropTypes: boolean;
32
- useTscLoader: boolean;
33
- webpack4Compatibility: boolean;
34
- installServerSourceMaps: boolean;
35
- disableDevWebpackTypecheck: boolean;
36
- jestUseTsJest: boolean;
37
- collectCoverage: boolean;
38
- dataUrlMaxSize?: number | undefined;
39
- imageMinimizer?: {
40
- svg?: {
41
- enabled?: boolean | undefined;
42
- } | undefined;
43
- gif?: {
44
- enabled?: boolean | undefined;
45
- optimizationLevel?: number | undefined;
46
- } | undefined;
47
- jpg?: {
48
- enabled?: boolean | undefined;
49
- quality: number;
50
- } | undefined;
51
- png?: {
52
- enabled?: boolean | undefined;
53
- optimizationLevel?: number | undefined;
54
- bitDepthReduction?: boolean | undefined;
55
- colorTypeReduction?: boolean | undefined;
56
- paletteReduction?: boolean | undefined;
57
- interlaced?: boolean | undefined;
58
- } | undefined;
59
- } | undefined;
60
- componentsTheme: string | null;
61
- keepCssVars: boolean;
62
- compatModules: {
63
- shared?: {
64
- [libraryName: string]: string;
65
- } | undefined;
66
- exposes?: {
67
- [moduleId: string]: {
68
- entry: string;
69
- externals?: Record<string, string> | undefined;
70
- cssPrefix?: string | false | undefined;
71
- };
72
- } | undefined;
73
- } | null;
74
- modules: {
75
- name?: string | undefined;
76
- shared: any;
77
- exposes?: Record<string, string> | undefined;
78
- } | null;
79
- };
5
+ export declare function calculateDependentConfig(config: AppConfigs): AppConfigs;
80
6
  /**
81
7
  * Обновление контекста в зависимости от ключей конфига
82
8
  */
@@ -3,7 +3,8 @@ 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.calculateDependentContext = exports.calculateDependentConfig = void 0;
6
+ exports.calculateDependentConfig = calculateDependentConfig;
7
+ exports.calculateDependentContext = calculateDependentContext;
7
8
  // TODO: remove eslint-disable-next-line
8
9
  const fs_1 = __importDefault(require("fs"));
9
10
  const path_1 = __importDefault(require("path"));
@@ -13,9 +14,8 @@ const resolve_1 = require("../util/resolve");
13
14
  * Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
14
15
  */
15
16
  function calculateDependentConfig(config) {
16
- return Object.assign(Object.assign({}, config), { clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config) });
17
+ return Object.assign(Object.assign({}, config), { codeLoader: config.useTscLoader ? 'tsc' : config.codeLoader, jestCodeTransformer: config.jestUseTsJest ? 'tsc' : config.jestCodeTransformer, clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config) });
17
18
  }
18
- exports.calculateDependentConfig = calculateDependentConfig;
19
19
  /**
20
20
  * Обновление контекста в зависимости от ключей конфига
21
21
  */
@@ -36,4 +36,3 @@ function calculateDependentContext(config, context) {
36
36
  }
37
37
  return Object.assign(Object.assign({}, context), { publicPath: `${config.assetsPath}/`, serverOutputPath: path_1.default.resolve(context.cwd, config.buildPath), clientOutputPath: path_1.default.resolve(context.cwd, config.buildPath, config.assetsPath), statsOutputPath: path_1.default.resolve(context.cwd, config.buildPath, config.statsOutputFilename), watchIgnorePath: ['node_modules', config.buildPath], babelRuntimeVersion });
38
38
  }
39
- exports.calculateDependentContext = calculateDependentContext;
@@ -3,7 +3,8 @@ 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.getDefaultAppContext = exports.getDefaultAppConfig = void 0;
6
+ exports.getDefaultAppConfig = getDefaultAppConfig;
7
+ exports.getDefaultAppContext = getDefaultAppContext;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const resolve_1 = require("../util/resolve");
@@ -45,10 +46,12 @@ function getDefaultAppConfig() {
45
46
  // build tuning
46
47
  keepPropTypes: false,
47
48
  useTscLoader: false,
49
+ codeLoader: 'babel',
48
50
  webpack4Compatibility: false,
49
51
  installServerSourceMaps: false,
50
52
  disableDevWebpackTypecheck: true,
51
53
  jestUseTsJest: false,
54
+ jestCodeTransformer: 'babel',
52
55
  collectCoverage: process.env.NODE_ENV === 'cypress' || process.env.USE_ISTANBUL === 'enabled',
53
56
  // image processing
54
57
  dataUrlMaxSize: 1536,
@@ -80,7 +83,6 @@ function getDefaultAppConfig() {
80
83
  modules: null,
81
84
  };
82
85
  }
83
- exports.getDefaultAppConfig = getDefaultAppConfig;
84
86
  function getPackageJson() {
85
87
  const appPackage = JSON.parse(fs_1.default.readFileSync(path_1.default.join(CWD, 'package.json'), 'utf8'));
86
88
  if (appPackage['arui-scripts']) {
@@ -101,7 +103,7 @@ function getDefaultAppContext() {
101
103
  return {
102
104
  appPackage,
103
105
  name: appPackage.name,
104
- normalizedName: appPackage.name.replace(/-/g, '_'),
106
+ normalizedName: appPackage.name.replace(/-/g, '_'), // для использования в качестве имени переменной
105
107
  version: appPackage.version,
106
108
  // general paths
107
109
  cwd: CWD,
@@ -131,4 +133,3 @@ function getDefaultAppContext() {
131
133
  changelogBreakingChangesPath: path_1.default.resolve(CWD, './changelog_breaking_changes.tmp'),
132
134
  };
133
135
  }
134
- exports.getDefaultAppContext = getDefaultAppContext;
@@ -3,7 +3,8 @@ 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.getConfigFilePath = exports.readConfigFile = void 0;
6
+ exports.readConfigFile = readConfigFile;
7
+ exports.getConfigFilePath = getConfigFilePath;
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const resolve_1 = require("../util/resolve");
9
10
  function readConfigFile(cwd) {
@@ -22,8 +23,6 @@ function readConfigFile(cwd) {
22
23
  }
23
24
  return null;
24
25
  }
25
- exports.readConfigFile = readConfigFile;
26
26
  function getConfigFilePath(cwd) {
27
27
  return (0, resolve_1.tryResolve)(path_1.default.join(cwd, '/arui-scripts.config'));
28
28
  }
29
- exports.getConfigFilePath = getConfigFilePath;
@@ -33,10 +33,18 @@ export type AppConfigs = {
33
33
  * @deprecated использование ts-loader крайне не рекомендуется - он медленнее и не имеет преимуществ перед babel
34
34
  */
35
35
  useTscLoader: boolean;
36
+ codeLoader: 'babel' | 'tsc' | 'swc';
37
+ /**
38
+ * @deprecated эта настройка будет удалена в будущих версиях скриптов
39
+ */
36
40
  webpack4Compatibility: boolean;
37
41
  installServerSourceMaps: boolean;
38
42
  disableDevWebpackTypecheck: boolean;
43
+ /**
44
+ * @deprecated используйте настройку jestCodeTransformer
45
+ */
39
46
  jestUseTsJest: boolean;
47
+ jestCodeTransformer: 'babel' | 'tsc' | 'swc';
40
48
  collectCoverage: boolean;
41
49
  dataUrlMaxSize?: number;
42
50
  imageMinimizer?: {
@@ -74,12 +82,15 @@ export type AppConfigs = {
74
82
  name?: string;
75
83
  shared: any;
76
84
  exposes?: Record<string, string>;
85
+ options?: ModuleConfigBase;
77
86
  } | null;
78
87
  };
79
- type CompatModuleConfigBase = {
88
+ export type ModuleConfigBase = {
89
+ cssPrefix?: false | string;
90
+ };
91
+ type CompatModuleConfigBase = ModuleConfigBase & {
80
92
  entry: string;
81
93
  externals?: Record<string, string>;
82
- cssPrefix?: false | string;
83
94
  };
84
95
  export type CompatModuleConfig = CompatModuleConfigBase & {
85
96
  name: string;
@@ -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.updateWithConfigFile = void 0;
6
+ exports.updateWithConfigFile = updateWithConfigFile;
7
7
  const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
8
  const read_config_file_1 = require("./read-config-file");
9
9
  const validate_settings_keys_1 = require("./validate-settings-keys");
@@ -15,4 +15,3 @@ function updateWithConfigFile(config, context) {
15
15
  }
16
16
  return config;
17
17
  }
18
- exports.updateWithConfigFile = updateWithConfigFile;
@@ -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.updateWithEnv = void 0;
6
+ exports.updateWithEnv = updateWithEnv;
7
7
  const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
8
  const validate_settings_keys_1 = require("./validate-settings-keys");
9
9
  function updateWithEnv(config) {
@@ -21,4 +21,3 @@ function updateWithEnv(config) {
21
21
  throw Error('Not valid JSON passed. Correct it. For example: ARUI_SCRIPTS_CONFIG="{"serverPort":3333}"');
22
22
  }
23
23
  }
24
- exports.updateWithEnv = updateWithEnv;
@@ -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.updateWithPackage = void 0;
6
+ exports.updateWithPackage = updateWithPackage;
7
7
  const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
8
  const validate_settings_keys_1 = require("./validate-settings-keys");
9
9
  function updateWithPackage(config, context) {
@@ -11,4 +11,3 @@ function updateWithPackage(config, context) {
11
11
  (0, validate_settings_keys_1.validateSettingsKeys)(config, packageSettings, 'package.json');
12
12
  return (0, lodash_merge_1.default)(config, packageSettings);
13
13
  }
14
- exports.updateWithPackage = updateWithPackage;
@@ -3,7 +3,8 @@ 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.getPresetsConfigPath = exports.updateWithPresets = void 0;
6
+ exports.updateWithPresets = updateWithPresets;
7
+ exports.getPresetsConfigPath = getPresetsConfigPath;
7
8
  // TODO: remove eslint-disable-next-line
8
9
  const lodash_merge_1 = __importDefault(require("lodash.merge"));
9
10
  const resolve_1 = require("../util/resolve");
@@ -33,10 +34,8 @@ function updateWithPresets(config, context) {
33
34
  }
34
35
  return config;
35
36
  }
36
- exports.updateWithPresets = updateWithPresets;
37
37
  function getPresetsConfigPath(config, cwd) {
38
38
  return (0, resolve_1.tryResolve)(`${config.presets}/arui-scripts.config`, {
39
39
  paths: [cwd],
40
40
  });
41
41
  }
42
- exports.getPresetsConfigPath = getPresetsConfigPath;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSettingsKeys = void 0;
3
+ exports.validateSettingsKeys = validateSettingsKeys;
4
4
  /**
5
5
  * Функция проверяет что все ключи объекта settingsObject есть в уже существующей конфигурации
6
6
  */
@@ -11,4 +11,3 @@ function validateSettingsKeys(existingConfig, settingsObject, source) {
11
11
  }
12
12
  });
13
13
  }
14
- exports.validateSettingsKeys = validateSettingsKeys;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.warnAboutDeprecations = void 0;
3
+ exports.warnAboutDeprecations = warnAboutDeprecations;
4
4
  function warnAboutDeprecations(config) {
5
5
  if (config.useTscLoader) {
6
- // eslint-disable-next-line no-console
7
6
  console.warn('Использование опции `useTscLoader` не рекомендуется и будет удалено в будущих версиях. ', 'Обратитесь к документации https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#usetscloader', 'для получения дополнительной информации.');
8
7
  }
8
+ if (config.webpack4Compatibility) {
9
+ console.warn('Опция `webpack4Compatibility` будет удалена в будущих версиях arui-scripts.', 'Обратитесь к issue в webpack https://github.com/webpack/webpack/issues/14580 для получения дополнительной информации');
10
+ }
9
11
  }
10
- exports.warnAboutDeprecations = warnAboutDeprecations;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addEnvToHtmlTemplate = void 0;
3
+ exports.addEnvToHtmlTemplate = addEnvToHtmlTemplate;
4
4
  const get_env_config_1 = require("./get-env-config");
5
5
  function addEnvToHtmlTemplate(html) {
6
6
  return html.replace('<%= envConfig %>', (0, get_env_config_1.getEnvConfigContent)());
7
7
  }
8
- exports.addEnvToHtmlTemplate = addEnvToHtmlTemplate;
@@ -3,7 +3,8 @@ 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.getEnvConfigContent = exports.replaceTemplateVariables = void 0;
6
+ exports.replaceTemplateVariables = replaceTemplateVariables;
7
+ exports.getEnvConfigContent = getEnvConfigContent;
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const app_configs_1 = require("../app-configs");
@@ -11,7 +12,6 @@ const constants_1 = require("./constants");
11
12
  function replaceTemplateVariables(template, variables) {
12
13
  return template.replace(/\$\{(\w+)}/g, (match, varName) => variables[varName] || '');
13
14
  }
14
- exports.replaceTemplateVariables = replaceTemplateVariables;
15
15
  let cachedEnvConfig = null;
16
16
  function getEnvConfigContent() {
17
17
  if (cachedEnvConfig) {
@@ -26,4 +26,3 @@ function getEnvConfigContent() {
26
26
  cachedEnvConfig = replaceTemplateVariables(templateContent, process.env);
27
27
  return cachedEnvConfig;
28
28
  }
29
- exports.getEnvConfigContent = getEnvConfigContent;
@@ -6,9 +6,9 @@ declare const _exports: {
6
6
  url: string;
7
7
  };
8
8
  transform: {
9
- '^.+\\.jsx?$': string;
10
- '^.+\\.mjs$': string;
11
- '^.+\\.tsx?$': string;
9
+ '^.+\\.jsx?$': string | (string | import("@swc/types").Options)[];
10
+ '^.+\\.mjs$': string | (string | import("@swc/types").Options)[];
11
+ '^.+\\.tsx?$': string | (string | import("@swc/types").Options)[];
12
12
  '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': string;
13
13
  };
14
14
  moduleNameMapper: {
@@ -1,20 +1,20 @@
1
- export const testRegex: string;
2
- export const moduleFileExtensions: string[];
3
- export const collectCoverageFrom: string[];
1
+ export let testRegex: string;
2
+ export let moduleFileExtensions: string[];
3
+ export let collectCoverageFrom: string[];
4
4
  export namespace testEnvironmentOptions {
5
- const url: string;
5
+ let url: string;
6
6
  }
7
- export const transform: {
8
- '^.+\\.jsx?$': string;
9
- '^.+\\.mjs$': string;
10
- '^.+\\.tsx?$': string;
7
+ export let transform: {
8
+ '^.+\\.jsx?$': string | (string | import("@swc/types").Options)[];
9
+ '^.+\\.mjs$': string | (string | import("@swc/types").Options)[];
10
+ '^.+\\.tsx?$': string | (string | import("@swc/types").Options)[];
11
11
  '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': string;
12
12
  };
13
- export const moduleNameMapper: {
13
+ export let moduleNameMapper: {
14
14
  '\\.css$': string;
15
15
  };
16
- export const snapshotSerializers: string[];
17
- export const globals: {
16
+ export let snapshotSerializers: string[];
17
+ export let globals: {
18
18
  'ts-jest': {
19
19
  tsconfig: string | null;
20
20
  };
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a;
3
2
  /* eslint-disable @typescript-eslint/no-var-requires */
4
3
  // Мы используем эти настройки сразу в двух местах - в jest-presets и в настройках jest-а, которые мы загружаем в самих скриптах
5
4
  // jest-presets могут использоваться внешними утилитами, которые используют разработчики, настройки в скриптах
@@ -8,13 +7,8 @@ var _a;
8
7
  const fs = require('fs');
9
8
  const { pathsToModuleNameMapper } = require('ts-jest');
10
9
  const { parseConfigFileTextToJson } = require('typescript');
10
+ const { swcJestConfig } = require('../swc');
11
11
  const configs = require('../app-configs').default;
12
- let tsConfigPaths = {};
13
- if (configs.tsconfig) {
14
- const tsConfigText = fs.readFileSync(configs.tsconfig, 'utf8');
15
- const tsConfig = parseConfigFileTextToJson(configs.tsconfig, tsConfigText);
16
- tsConfigPaths = ((_a = tsConfig.config.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) || {};
17
- }
18
12
  module.exports = {
19
13
  testRegex: 'src/.*(((/__test__/|/__tests__/).*)|(test|spec|tests)).(jsx?|tsx?)$',
20
14
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
@@ -23,16 +17,14 @@ module.exports = {
23
17
  url: 'http://localhost',
24
18
  },
25
19
  transform: {
26
- '^.+\\.jsx?$': require.resolve('./babel-transform'),
27
- '^.+\\.mjs$': require.resolve('./babel-transform'),
28
- '^.+\\.tsx?$': configs.jestUseTsJest
29
- ? require.resolve('ts-jest')
30
- : require.resolve('./babel-transform'),
20
+ '^.+\\.jsx?$': getJsTransformer(),
21
+ '^.+\\.mjs$': getJsTransformer(),
22
+ '^.+\\.tsx?$': getTsTransformer(),
31
23
  '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': require.resolve('./file-transform'),
32
24
  },
33
25
  moduleNameMapper: Object.assign({
34
26
  // replace all css files with simple empty exports
35
- '\\.css$': require.resolve('./css-mock') }, pathsToModuleNameMapper(tsConfigPaths, { prefix: '<rootDir>/' })),
27
+ '\\.css$': require.resolve('./css-mock') }, pathsToModuleNameMapper(getPathMapping(), { prefix: '<rootDir>/' })),
36
28
  snapshotSerializers: [require.resolve('jest-snapshot-serializer-class-name-to-string')],
37
29
  globals: {
38
30
  'ts-jest': {
@@ -40,3 +32,27 @@ module.exports = {
40
32
  },
41
33
  },
42
34
  };
35
+ function getPathMapping() {
36
+ var _a;
37
+ if (!configs.tsconfig) {
38
+ return {};
39
+ }
40
+ const tsConfigText = fs.readFileSync(configs.tsconfig, 'utf8');
41
+ const tsConfig = parseConfigFileTextToJson(configs.tsconfig, tsConfigText);
42
+ return ((_a = tsConfig.config.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) || {};
43
+ }
44
+ function getTsTransformer() {
45
+ if (configs.jestCodeTransformer === 'tsc') {
46
+ return require.resolve('ts-jest');
47
+ }
48
+ if (configs.jestCodeTransformer === 'swc') {
49
+ return [require.resolve('@swc/jest'), swcJestConfig];
50
+ }
51
+ return require.resolve('./babel-transform');
52
+ }
53
+ function getJsTransformer() {
54
+ if (configs.jestCodeTransformer === 'swc') {
55
+ return [require.resolve('@swc/jest'), swcJestConfig];
56
+ }
57
+ return require.resolve('./babel-transform');
58
+ }
@@ -3,7 +3,12 @@ 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.patchWebpackConfigForCompat = exports.getExposeLoadersFormCompatModules = exports.getCssPrefixForModule = exports.patchMainWebpackConfigForModules = exports.MODULES_ENTRY_NAME = exports.haveExposedDefaultModules = void 0;
6
+ exports.MODULES_ENTRY_NAME = void 0;
7
+ exports.haveExposedDefaultModules = haveExposedDefaultModules;
8
+ exports.patchMainWebpackConfigForModules = patchMainWebpackConfigForModules;
9
+ exports.getCssPrefixForModule = getCssPrefixForModule;
10
+ exports.getExposeLoadersFormCompatModules = getExposeLoadersFormCompatModules;
11
+ exports.patchWebpackConfigForCompat = patchWebpackConfigForCompat;
7
12
  // TODO: remove eslint-disable
8
13
  /* eslint-disable no-param-reassign */
9
14
  const webpack_1 = __importDefault(require("webpack"));
@@ -14,7 +19,6 @@ function haveExposedDefaultModules() {
14
19
  var _a;
15
20
  return (_a = app_configs_1.default.modules) === null || _a === void 0 ? void 0 : _a.exposes;
16
21
  }
17
- exports.haveExposedDefaultModules = haveExposedDefaultModules;
18
22
  exports.MODULES_ENTRY_NAME = 'remoteEntry.js';
19
23
  function patchMainWebpackConfigForModules(webpackConf) {
20
24
  // Добавляем expose loader для библиотек, которые мы хотим вынести в глобальную область видимости
@@ -22,6 +26,10 @@ function patchMainWebpackConfigForModules(webpackConf) {
22
26
  if (!app_configs_1.default.modules || !webpackConf.output || !webpackConf.plugins) {
23
27
  return webpackConf;
24
28
  }
29
+ const { cssPrefix } = app_configs_1.default.modules.options || {};
30
+ if (cssPrefix) {
31
+ addCssPrefix(webpackConf, cssPrefix);
32
+ }
25
33
  webpackConf.output.publicPath = haveExposedDefaultModules()
26
34
  ? 'auto' // Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
27
35
  : app_configs_1.default.publicPath;
@@ -33,7 +41,6 @@ function patchMainWebpackConfigForModules(webpackConf) {
33
41
  }));
34
42
  return webpackConf;
35
43
  }
36
- exports.patchMainWebpackConfigForModules = patchMainWebpackConfigForModules;
37
44
  function getCssPrefixForModule(module) {
38
45
  if (module.cssPrefix) {
39
46
  return module.cssPrefix;
@@ -43,7 +50,6 @@ function getCssPrefixForModule(module) {
43
50
  }
44
51
  return `.module-${module.name}`;
45
52
  }
46
- exports.getCssPrefixForModule = getCssPrefixForModule;
47
53
  function getExposeLoadersFormCompatModules() {
48
54
  var _a;
49
55
  const shared = (_a = app_configs_1.default.compatModules) === null || _a === void 0 ? void 0 : _a.shared;
@@ -65,7 +71,12 @@ function getExposeLoadersFormCompatModules() {
65
71
  };
66
72
  });
67
73
  }
68
- exports.getExposeLoadersFormCompatModules = getExposeLoadersFormCompatModules;
74
+ function addCssPrefix(webpackConf, cssPrefix) {
75
+ const cssRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.css$/');
76
+ const cssModulesRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.module\\.css$/');
77
+ addPrefixCssRule(cssRule, cssPrefix);
78
+ addPrefixCssRule(cssModulesRule, `:global(${cssPrefix})`);
79
+ }
69
80
  function addPrefixCssRule(rule, prefix) {
70
81
  if (!rule || !rule.use || !Array.isArray(rule.use)) {
71
82
  return;
@@ -94,15 +105,12 @@ function patchWebpackConfigForCompat(module, webpackConf) {
94
105
  webpackConf.externals = Object.assign(Object.assign({}, (webpackConf.externals || {})), (module.externals || {}));
95
106
  // Название переменной вебпака, которую он будет использовать для загрузки чанков. Важно чтобы для разных модулей они отличались,
96
107
  // иначе несколько модулей из одного приложения будут конфликтовать между собой
97
- webpackConf.output.uniqueName = module.name;
108
+ const uniqueName = module.name;
109
+ // Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать publicPath = auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
110
+ webpackConf.output = Object.assign(Object.assign({}, webpackConf.output), { publicPath: 'auto', uniqueName });
98
111
  const cssPrefix = getCssPrefixForModule(module);
99
112
  if (cssPrefix) {
100
- // Добавляем префикс для css-классов, чтобы изолировать стили модуля от стилей основного приложения
101
- const cssRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.css$/');
102
- const cssModulesRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.module\\.css$/');
103
- addPrefixCssRule(cssRule, cssPrefix);
104
- addPrefixCssRule(cssModulesRule, `:global(${cssPrefix})`);
113
+ addCssPrefix(webpackConf, cssPrefix);
105
114
  }
106
115
  return webpackConf;
107
116
  }
108
- exports.patchWebpackConfigForCompat = patchWebpackConfigForCompat;
@@ -3,7 +3,8 @@ 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.postcssPluginsOptions = exports.postcssPlugins = exports.createPostcssConfig = void 0;
6
+ exports.postcssPluginsOptions = exports.postcssPlugins = void 0;
7
+ exports.createPostcssConfig = createPostcssConfig;
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const app_configs_1 = __importDefault(require("./app-configs"));
9
10
  const supporting_browsers_1 = __importDefault(require("./supporting-browsers"));
@@ -21,7 +22,6 @@ function createPostcssConfig(plugins, options) {
21
22
  return pluginName;
22
23
  });
23
24
  }
24
- exports.createPostcssConfig = createPostcssConfig;
25
25
  exports.postcssPlugins = [
26
26
  'postcss-omit-import-tilde',
27
27
  'postcss-import',
@@ -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.processAssetsPluginOutput = void 0;
6
+ exports.processAssetsPluginOutput = processAssetsPluginOutput;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const app_configs_1 = __importDefault(require("./app-configs"));
9
9
  const modules_1 = require("./modules");
@@ -34,7 +34,6 @@ function processAssetsPluginOutput(assets) {
34
34
  } });
35
35
  return JSON.stringify(result);
36
36
  }
37
- exports.processAssetsPluginOutput = processAssetsPluginOutput;
38
37
  function replaceAutoPath(assets) {
39
38
  if (!assets) {
40
39
  return assets;
@@ -0,0 +1,4 @@
1
+ import type { Options } from '@swc/core';
2
+ export declare const swcClientConfig: Options;
3
+ export declare const swcServerConfig: Options;
4
+ export declare const swcJestConfig: Options;
@@ -0,0 +1,35 @@
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.swcJestConfig = exports.swcServerConfig = exports.swcClientConfig = void 0;
7
+ const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
8
+ const app_configs_1 = require("./app-configs");
9
+ const swcConfig = {
10
+ env: { coreJs: '3', mode: 'entry' },
11
+ jsc: {
12
+ parser: {
13
+ syntax: 'typescript',
14
+ tsx: true,
15
+ decorators: true,
16
+ },
17
+ loose: true,
18
+ transform: {
19
+ legacyDecorator: true,
20
+ react: {
21
+ runtime: 'automatic',
22
+ },
23
+ },
24
+ experimental: app_configs_1.configs.collectCoverage
25
+ ? {
26
+ plugins: [
27
+ ['swc-plugin-coverage-instrument', {}],
28
+ ],
29
+ }
30
+ : {},
31
+ },
32
+ };
33
+ exports.swcClientConfig = (0, apply_overrides_1.default)(['swc', 'swcClient'], swcConfig);
34
+ exports.swcServerConfig = (0, apply_overrides_1.default)(['swc', 'swcServer'], swcConfig);
35
+ exports.swcJestConfig = (0, apply_overrides_1.default)(['swc', 'swcJest'], swcConfig);
@@ -1,5 +1,6 @@
1
1
  import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
2
2
  import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
3
+ import type { Options as SwcOptions } from '@swc/core';
3
4
  import { AppContextWithConfigs } from '../app-configs/types';
4
5
  import { createSingleClientWebpackConfig } from '../webpack.client';
5
6
  import { findLoader } from './find-loader';
@@ -20,6 +21,10 @@ type Overrides = {
20
21
  babelClient: any;
21
22
  babelServer: any;
22
23
  babelDependencies: any;
24
+ swc: SwcOptions;
25
+ swcServer: SwcOptions;
26
+ swcClient: SwcOptions;
27
+ swcJest: SwcOptions;
23
28
  postcss: any[];
24
29
  browsers: string[];
25
30
  supportingBrowsers: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findLoader = void 0;
3
+ exports.findLoader = findLoader;
4
4
  function findLoader(config, testRule) {
5
5
  var _a;
6
6
  for (const rule of config.module.rules) {
@@ -22,4 +22,3 @@ function findLoader(config, testRule) {
22
22
  }
23
23
  return undefined;
24
24
  }
25
- exports.findLoader = findLoader;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Cluster } from 'cluster';
3
2
  import { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
4
3
  import AssetsPlugin from 'assets-webpack-plugin';