arui-scripts 18.0.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.
- package/.eslintrc.js +2 -0
- package/.turbo/turbo-lint.log +25 -102
- package/.turbo/turbo-test.log +7 -4
- package/CHANGELOG.md +23 -0
- package/build/commands/changelog/index.js +22 -27
- package/build/commands/start/print-compiler-output.js +1 -1
- package/build/commands/start-prod/index.js +1 -1
- package/build/commands/util/client-assets-sizes.js +2 -3
- package/build/commands/util/docker-build.js +6 -7
- package/build/commands/util/run-client-dev-server.js +1 -2
- package/build/commands/util/run-compilers.js +1 -2
- package/build/commands/util/run-server-watch-compiler.js +2 -3
- package/build/commands/util/tsc.js +1 -2
- package/build/commands/util/yarn.js +3 -4
- package/build/configs/app-configs/calculate-dependent-config.d.ts +1 -75
- package/build/configs/app-configs/calculate-dependent-config.js +3 -4
- package/build/configs/app-configs/get-defaults.js +5 -4
- package/build/configs/app-configs/read-config-file.js +2 -3
- package/build/configs/app-configs/types.d.ts +8 -0
- package/build/configs/app-configs/update-with-config-file.js +1 -2
- package/build/configs/app-configs/update-with-env.js +1 -2
- package/build/configs/app-configs/update-with-package.js +1 -2
- package/build/configs/app-configs/update-with-presets.js +2 -3
- package/build/configs/app-configs/validate-settings-keys.js +1 -2
- package/build/configs/app-configs/warn-about-deprecations.js +4 -3
- package/build/configs/client-env-config/add-env-to-html-template.js +1 -2
- package/build/configs/client-env-config/get-env-config.js +2 -3
- package/build/configs/jest/index.d.ts +3 -3
- package/build/configs/jest/settings.d.ts +11 -11
- package/build/configs/jest/settings.js +29 -13
- package/build/configs/modules.js +6 -6
- package/build/configs/postcss.config.js +2 -2
- package/build/configs/process-assets-plugin-output.js +1 -2
- package/build/configs/swc.d.ts +4 -0
- package/build/configs/swc.js +35 -0
- package/build/configs/util/apply-overrides.d.ts +5 -0
- package/build/configs/util/find-loader.js +1 -2
- package/build/configs/util/find-plugin.d.ts +0 -1
- package/build/configs/util/find-plugin.js +1 -2
- package/build/configs/util/get-polyfills.d.ts +0 -1
- package/build/configs/util/get-polyfills.js +1 -2
- package/build/configs/util/get-webpack-cache-dependencies.js +1 -2
- package/build/configs/util/resolve.js +2 -3
- package/build/configs/webpack.client.d.ts +2 -2
- package/build/configs/webpack.client.js +84 -61
- package/build/configs/webpack.server.d.ts +1 -1
- package/build/configs/webpack.server.js +70 -46
- package/build/plugins/arui-runtime/arui-runtime-module.js +1 -1
- package/build/plugins/arui-runtime/index.js +2 -2
- package/build/templates/dockerfile.template.js +1 -1
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/docs/overrides.md +3 -0
- package/docs/settings.md +27 -0
- package/package.json +15 -10
|
@@ -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.
|
|
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.
|
|
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.
|
|
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?: {
|
|
@@ -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 =
|
|
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 =
|
|
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 =
|
|
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.
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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.
|
|
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
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export let testRegex: string;
|
|
2
|
+
export let moduleFileExtensions: string[];
|
|
3
|
+
export let collectCoverageFrom: string[];
|
|
4
4
|
export namespace testEnvironmentOptions {
|
|
5
|
-
|
|
5
|
+
let url: string;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
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
|
|
13
|
+
export let moduleNameMapper: {
|
|
14
14
|
'\\.css$': string;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
17
|
-
export
|
|
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?$':
|
|
27
|
-
'^.+\\.mjs$':
|
|
28
|
-
'^.+\\.tsx?$':
|
|
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(
|
|
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
|
+
}
|
package/build/configs/modules.js
CHANGED
|
@@ -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.
|
|
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 для библиотек, которые мы хотим вынести в глобальную область видимости
|
|
@@ -37,7 +41,6 @@ function patchMainWebpackConfigForModules(webpackConf) {
|
|
|
37
41
|
}));
|
|
38
42
|
return webpackConf;
|
|
39
43
|
}
|
|
40
|
-
exports.patchMainWebpackConfigForModules = patchMainWebpackConfigForModules;
|
|
41
44
|
function getCssPrefixForModule(module) {
|
|
42
45
|
if (module.cssPrefix) {
|
|
43
46
|
return module.cssPrefix;
|
|
@@ -47,7 +50,6 @@ function getCssPrefixForModule(module) {
|
|
|
47
50
|
}
|
|
48
51
|
return `.module-${module.name}`;
|
|
49
52
|
}
|
|
50
|
-
exports.getCssPrefixForModule = getCssPrefixForModule;
|
|
51
53
|
function getExposeLoadersFormCompatModules() {
|
|
52
54
|
var _a;
|
|
53
55
|
const shared = (_a = app_configs_1.default.compatModules) === null || _a === void 0 ? void 0 : _a.shared;
|
|
@@ -69,7 +71,6 @@ function getExposeLoadersFormCompatModules() {
|
|
|
69
71
|
};
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
|
-
exports.getExposeLoadersFormCompatModules = getExposeLoadersFormCompatModules;
|
|
73
74
|
function addCssPrefix(webpackConf, cssPrefix) {
|
|
74
75
|
const cssRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.css$/');
|
|
75
76
|
const cssModulesRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.module\\.css$/');
|
|
@@ -113,4 +114,3 @@ function patchWebpackConfigForCompat(module, webpackConf) {
|
|
|
113
114
|
}
|
|
114
115
|
return webpackConf;
|
|
115
116
|
}
|
|
116
|
-
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 =
|
|
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 =
|
|
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,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 =
|
|
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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findPlugin =
|
|
3
|
+
exports.findPlugin = findPlugin;
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param config конфигурация webpack
|
|
@@ -20,4 +20,3 @@ function findPlugin() {
|
|
|
20
20
|
return result;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports.findPlugin = findPlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPolyfills =
|
|
3
|
+
exports.getPolyfills = getPolyfills;
|
|
4
4
|
// require.resolve вынесен как параметр функции для того, чтоб это можно было протестировать.
|
|
5
5
|
// на данный момент jest не дает возможности мокать require.resolve https://github.com/facebook/jest/issues/9543
|
|
6
6
|
function getPolyfills(config, requireResolve = require.resolve) {
|
|
@@ -24,4 +24,3 @@ function getPolyfills(config, requireResolve = require.resolve) {
|
|
|
24
24
|
}
|
|
25
25
|
return polyfills;
|
|
26
26
|
}
|
|
27
|
-
exports.getPolyfills = getPolyfills;
|
|
@@ -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.getWebpackCacheDependencies =
|
|
6
|
+
exports.getWebpackCacheDependencies = getWebpackCacheDependencies;
|
|
7
7
|
const app_configs_1 = __importDefault(require("../app-configs"));
|
|
8
8
|
const read_config_file_1 = require("../app-configs/read-config-file");
|
|
9
9
|
const update_with_presets_1 = require("../app-configs/update-with-presets");
|
|
@@ -16,4 +16,3 @@ function getWebpackCacheDependencies() {
|
|
|
16
16
|
].filter(Boolean),
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
exports.getWebpackCacheDependencies = getWebpackCacheDependencies;
|
|
@@ -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.
|
|
6
|
+
exports.tryResolve = tryResolve;
|
|
7
|
+
exports.resolveNodeModuleRelativeTo = resolveNodeModuleRelativeTo;
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
function tryResolve(...args) {
|
|
9
10
|
try {
|
|
@@ -13,7 +14,6 @@ function tryResolve(...args) {
|
|
|
13
14
|
return undefined;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
exports.tryResolve = tryResolve;
|
|
17
17
|
/**
|
|
18
18
|
* Возвращает полный путь до модуля из node_modules относительно базового пути.
|
|
19
19
|
* Может быть полезно для определения пути до модуля, когда в проекте установлено сразу несколько модулей.
|
|
@@ -27,4 +27,3 @@ exports.tryResolve = tryResolve;
|
|
|
27
27
|
function resolveNodeModuleRelativeTo(basePath, moduleName) {
|
|
28
28
|
return path_1.default.resolve(basePath, `node_modules/${moduleName}`);
|
|
29
29
|
}
|
|
30
|
-
exports.resolveNodeModuleRelativeTo = resolveNodeModuleRelativeTo;
|
|
@@ -6,5 +6,5 @@ import { Entry } from './util/get-entry';
|
|
|
6
6
|
* @param entry Точка входа, любой валидный вход для webpack
|
|
7
7
|
* @param configName Имя конфигурации, если не указано, то используется имя по умолчанию
|
|
8
8
|
*/
|
|
9
|
-
export declare const createSingleClientWebpackConfig: (mode:
|
|
10
|
-
export declare const createClientWebpackConfig: (mode:
|
|
9
|
+
export declare const createSingleClientWebpackConfig: (mode: "dev" | "prod", entry: Entry, configName?: string) => Configuration;
|
|
10
|
+
export declare const createClientWebpackConfig: (mode: "dev" | "prod") => webpack.Configuration | webpack.Configuration[];
|