arui-scripts 13.2.0-feat-babel-config-update.1 → 13.2.1
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/CHANGELOG.md +1090 -21
- package/README.md +12 -0
- package/build/bin/index.js +0 -0
- package/build/commands/start/server.js +5 -1
- package/build/commands/util/format-webpack-messages.d.ts +7 -1
- package/build/commands/util/format-webpack-messages.js +2 -1
- package/build/configs/app-configs/available-package-settings.d.ts +1 -1
- package/build/configs/app-configs/available-package-settings.js +2 -0
- package/build/configs/app-configs/calculate-dependent-config.d.ts +2 -0
- package/build/configs/app-configs/calculate-dependent-config.js +17 -0
- package/build/configs/app-configs/get-defaults.js +6 -2
- package/build/configs/app-configs/types.d.ts +4 -0
- package/build/configs/app-configs/update-with-config-file.js +2 -2
- package/build/configs/app-configs/update-with-presets.js +3 -3
- package/build/configs/babel-client.js +1 -1
- package/build/configs/babel-dependencies.js +2 -1
- package/build/configs/dev-server.js +9 -4
- package/build/configs/util/resolve.d.ts +12 -0
- package/build/configs/util/resolve.js +30 -0
- package/build/configs/webpack.client.dev.js +6 -5
- package/build/configs/webpack.client.prod.js +3 -0
- package/build/configs/webpack.dll.dev.d.ts +3 -0
- package/build/configs/webpack.dll.dev.js +91 -0
- package/build/configs/webpack.server.dev.js +4 -2
- package/build/configs/webpack.server.prod.js +3 -0
- package/build/tsconfig-local.tsbuildinfo +8545 -7341
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ npm install arui-scripts --save-dev
|
|
|
64
64
|
- `clientPolyfillsEntry` - точка входа для полифилов. Будет подключаться до основной точки входа. По умолчанию подтягивает полифилы из `arui-feather`, если он установлен.
|
|
65
65
|
- `clientEntry` - точка входа для клиентского приложения. По умолчанию `src/index.js`.
|
|
66
66
|
- `useServerHMR` - использовать ли HotModuleReplacement для сервера. По умолчанию `false`.
|
|
67
|
+
- `webpack4Compatibility` - включить ли режим совместимости с webpack 4. По умолчанию `false`. Подробнее можно почитать в [этом issue](https://github.com/webpack/webpack/issues/14580).
|
|
67
68
|
- `clientServerPort` - порт WebpackDevServer и nginx итогового контейнера. По умолчанию `8080`.
|
|
68
69
|
- `serverPort` - порт нодового сервера. Нужен для правильного проксирования запросов от дев сервера и nginx. По умолчанию `3000`.
|
|
69
70
|
- `installServerSourceMaps` - добавлять ли в серверную сборку пакет `source-map-support`. По умолчанию `false`.
|
|
@@ -72,6 +73,8 @@ npm install arui-scripts --save-dev
|
|
|
72
73
|
- `keepPropTypes` - если `true`, пакеты с prop-types не будут удалены из production билда.
|
|
73
74
|
- `debug` - режим отладки, в котором не выполняются некоторые нежелательные операции и выводится больше сообщений об ошибках, по умолчанию `false`.
|
|
74
75
|
- `statsOutputFilename` - имя [stats-файла](https://webpack.js.org/api/stats/), которое будет использоваться в [bundle-analyze](#анализ-бандла) команде
|
|
76
|
+
- `devSourceMaps` - какой вид source-map использовать в режиме разработки. По умолчанию `eval`. Эта настройка может сильно влиять на время сборки. Подробнее можно почитать [здесь](https://webpack.js.org/configuration/devtool/).
|
|
77
|
+
**Внимание**. При использовании любых source-map на основании `eval` webpack-dev-server будет модифицировать заголовок `Content-Security-Policy` (при наличии) и добавлять в него `unsafe-eval`. [Подробнее тут](#dev-csp).
|
|
75
78
|
- `useTscLoader` - использовать ts-loader вместо babel-loader для обработки ts файлов. У babel-loader есть [ряд ограничений](https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/). По умолчанию `false`.
|
|
76
79
|
- `componentsTheme` - путь к css файлу с темой для [core-components](https://alfa-laboratory.github.io/core-components). Используется для настройки [postcss-custom-properties](https://github.com/postcss/postcss-custom-properties#importfrom).
|
|
77
80
|
- `keepCssVars` - отключает `postcss-custom-properties`, css переменные будут оставаться в бандле.
|
|
@@ -464,6 +467,15 @@ webpack и перезапустить сборку. Кеши хранятся в
|
|
|
464
467
|
rm -rf ./node_modules/.cache
|
|
465
468
|
```
|
|
466
469
|
|
|
470
|
+
<a name="dev-csp"></a>
|
|
471
|
+
Модификация CSP для разработки
|
|
472
|
+
---
|
|
473
|
+
Если в дев-режиме используются любой тип source-map, основанный на eval (это дефолтное поведение) - то
|
|
474
|
+
webpack-dev-server автоматически будет добавлять в CSP заголовок `script-src` значение `unsafe-eval` (при наличии заголовка).
|
|
475
|
+
Это необходимо для того, чтобы код вообще запускался в браузере. Это не влияет на реальную безопасность приложения, так
|
|
476
|
+
как используется ТОЛЬКО в дев-режиме. Если по каким-то причинам вас такое поведение не устраивает - вы можете поменять
|
|
477
|
+
тип source-map на любой другой, не использующий eval.
|
|
478
|
+
|
|
467
479
|
|
|
468
480
|
Анализ бандла
|
|
469
481
|
---
|
package/build/bin/index.js
CHANGED
|
File without changes
|
|
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const webpack_1 = __importDefault(require("webpack"));
|
|
7
7
|
const print_compiler_output_1 = __importDefault(require("./print-compiler-output"));
|
|
8
8
|
const webpack_server_dev_1 = __importDefault(require("../../configs/webpack.server.dev"));
|
|
9
|
+
const app_configs_1 = __importDefault(require("../../configs/app-configs"));
|
|
9
10
|
const serverCompiler = webpack_1.default(webpack_server_dev_1.default);
|
|
10
11
|
serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
|
|
11
12
|
serverCompiler.hooks.invalid.tap('server', () => console.log('Compiling server...'));
|
|
12
13
|
serverCompiler.hooks.done.tap('server', (stats) => print_compiler_output_1.default('Server', stats));
|
|
13
|
-
serverCompiler.watch({
|
|
14
|
+
serverCompiler.watch({
|
|
15
|
+
aggregateTimeout: 50,
|
|
16
|
+
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
17
|
+
}, () => { });
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
2
7
|
declare function formatWebpackMessages(json: any): {
|
|
3
8
|
errors: any;
|
|
4
9
|
warnings: any;
|
|
5
10
|
};
|
|
11
|
+
export default formatWebpackMessages;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
9
|
// WARNING: this code is untranspiled and is used in browser too.
|
|
9
10
|
// Please make sure any changes are in ES5 or contribute a Babel compile step.
|
|
10
11
|
// Some custom utilities to prettify Webpack output.
|
|
@@ -89,4 +90,4 @@ function formatWebpackMessages(json) {
|
|
|
89
90
|
}
|
|
90
91
|
return result;
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
exports.default = formatWebpackMessages;
|
|
@@ -2,7 +2,7 @@ import { AppConfigs } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Эти ключи из конфига будут обновляться из package.json при их наличии
|
|
4
4
|
*/
|
|
5
|
-
export declare const availablePackageSettings: readonly ["dockerRegistry", "baseDockerImage", "serverEntry", "buildPath", "assetsPath", "additionalBuildPath", "nginxRootPath", "runFromNonRootUser", "archiveName", "serverOutput", "clientPolyfillsEntry", "clientEntry", "keepPropTypes", "useTscLoader", "useServerHMR", "clientServerPort", "serverPort", "debug", "statsOutputFilename", "componentsTheme", "keepCssVars", "removeDevDependenciesDuringDockerBuild"];
|
|
5
|
+
export declare const availablePackageSettings: readonly ["dockerRegistry", "baseDockerImage", "serverEntry", "buildPath", "assetsPath", "additionalBuildPath", "nginxRootPath", "runFromNonRootUser", "archiveName", "serverOutput", "clientPolyfillsEntry", "clientEntry", "keepPropTypes", "devSourceMaps", "useTscLoader", "useServerHMR", "webpack4Compatibility", "clientServerPort", "serverPort", "debug", "statsOutputFilename", "componentsTheme", "keepCssVars", "removeDevDependenciesDuringDockerBuild"];
|
|
6
6
|
declare type ArrayElementType<ArrayType extends ReadonlyArray<unknown>> = ArrayType[number];
|
|
7
7
|
export declare type PackageSettings = Partial<Pick<AppConfigs, ArrayElementType<typeof availablePackageSettings>>>;
|
|
8
8
|
export {};
|
|
@@ -4,19 +4,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.calculateDependentConfig = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
9
10
|
const get_polyfills_1 = require("../util/get-polyfills");
|
|
11
|
+
const resolve_1 = require("../util/resolve");
|
|
10
12
|
/**
|
|
11
13
|
* Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
|
|
12
14
|
*/
|
|
13
15
|
function calculateDependentConfig(config) {
|
|
16
|
+
let babelRuntimeVersion;
|
|
17
|
+
try {
|
|
18
|
+
// В проекте может стоять babel/runtime отличный от того, что установлен как зависимость arui-scripts.
|
|
19
|
+
// При этом webpack будет резолвить babel/runtime относительно проекта, а не относительно arui-scripts.
|
|
20
|
+
// Поэтому мы читаем версию того babel/runtime, который установлен в проекте.
|
|
21
|
+
// Так же мы не можем использовать require для получения контента из babel/runtime/package.json,
|
|
22
|
+
// потому что webpack.cache будет ругаться на то, что мы пытаемся импортировать файлы НЕ из своего node_modules.
|
|
23
|
+
const pathToProjectBabelRuntime = resolve_1.resolveNodeModuleRelativeTo(config.cwd, '@babel/runtime/package.json');
|
|
24
|
+
babelRuntimeVersion = JSON.parse(fs_1.default.readFileSync(pathToProjectBabelRuntime, 'utf8')).version;
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
babelRuntimeVersion = require('@babel/runtime/package.json').version;
|
|
28
|
+
}
|
|
14
29
|
return lodash_merge_1.default(config, {
|
|
15
30
|
publicPath: `${config.assetsPath}/`,
|
|
16
31
|
serverOutputPath: path_1.default.resolve(config.cwd, config.buildPath),
|
|
17
32
|
clientOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.assetsPath),
|
|
18
33
|
clientPolyfillsEntry: get_polyfills_1.getPolyfills(config),
|
|
19
34
|
statsOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.statsOutputFilename),
|
|
35
|
+
watchIgnorePath: ['node_modules', config.buildPath],
|
|
36
|
+
babelRuntimeVersion,
|
|
20
37
|
});
|
|
21
38
|
}
|
|
22
39
|
exports.calculateDependentConfig = calculateDependentConfig;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getDefaults = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
9
|
+
const resolve_1 = require("../util/resolve");
|
|
10
10
|
function getDefaults() {
|
|
11
11
|
const CWD = process.cwd();
|
|
12
12
|
const appPackage = JSON.parse(fs_1.default.readFileSync(path_1.default.join(CWD, 'package.json'), 'utf8'));
|
|
@@ -17,7 +17,7 @@ function getDefaults() {
|
|
|
17
17
|
const absoluteNodeModulesPath = path_1.default.resolve(CWD, 'node_modules');
|
|
18
18
|
const projectTsConfigPath = path_1.default.join(CWD, 'tsconfig.json');
|
|
19
19
|
const yarnLockFilePath = path_1.default.join(CWD, 'yarn.lock');
|
|
20
|
-
const overridesPath =
|
|
20
|
+
const overridesPath = resolve_1.tryResolve(path_1.default.join(CWD, 'arui-scripts.overrides'));
|
|
21
21
|
const nginxConfFilePath = path_1.default.join(CWD, 'nginx.conf');
|
|
22
22
|
const dockerfileFilePath = path_1.default.join(CWD, 'Dockerfile');
|
|
23
23
|
return {
|
|
@@ -36,6 +36,7 @@ function getDefaults() {
|
|
|
36
36
|
nginxRootPath: '/src',
|
|
37
37
|
runFromNonRootUser: false,
|
|
38
38
|
archiveName: 'build.tar',
|
|
39
|
+
babelRuntimeVersion: '7.0.0-beta.0',
|
|
39
40
|
// server compilation configs
|
|
40
41
|
serverEntry: path_1.default.resolve(absoluteSrcPath, 'server/index'),
|
|
41
42
|
serverOutput: 'server.js',
|
|
@@ -47,8 +48,10 @@ function getDefaults() {
|
|
|
47
48
|
tsconfig: fs_1.default.existsSync(projectTsConfigPath) ? projectTsConfigPath : null,
|
|
48
49
|
localNginxConf: fs_1.default.existsSync(nginxConfFilePath) ? nginxConfFilePath : null,
|
|
49
50
|
localDockerfile: fs_1.default.existsSync(dockerfileFilePath) ? dockerfileFilePath : null,
|
|
51
|
+
devSourceMaps: 'eval',
|
|
50
52
|
useTscLoader: false,
|
|
51
53
|
useServerHMR: false,
|
|
54
|
+
webpack4Compatibility: false,
|
|
52
55
|
useYarn: fs_1.default.existsSync(yarnLockFilePath),
|
|
53
56
|
clientServerPort: 8080,
|
|
54
57
|
serverPort: 3000,
|
|
@@ -64,6 +67,7 @@ function getDefaults() {
|
|
|
64
67
|
serverOutputPath: '',
|
|
65
68
|
clientOutputPath: '',
|
|
66
69
|
statsOutputPath: '',
|
|
70
|
+
watchIgnorePath: [],
|
|
67
71
|
};
|
|
68
72
|
}
|
|
69
73
|
exports.getDefaults = getDefaults;
|
|
@@ -13,6 +13,7 @@ export declare type AppConfigs = {
|
|
|
13
13
|
nginxRootPath: string;
|
|
14
14
|
runFromNonRootUser: boolean;
|
|
15
15
|
archiveName: string;
|
|
16
|
+
babelRuntimeVersion: string;
|
|
16
17
|
serverEntry: string | string[] | Record<string, string | string[]>;
|
|
17
18
|
serverOutput: string;
|
|
18
19
|
clientPolyfillsEntry: null | string | string[];
|
|
@@ -21,8 +22,10 @@ export declare type AppConfigs = {
|
|
|
21
22
|
tsconfig: string | null;
|
|
22
23
|
localNginxConf: string | null;
|
|
23
24
|
localDockerfile: string | null;
|
|
25
|
+
devSourceMaps: string;
|
|
24
26
|
useTscLoader: boolean;
|
|
25
27
|
useServerHMR: boolean;
|
|
28
|
+
webpack4Compatibility: boolean;
|
|
26
29
|
useYarn: boolean;
|
|
27
30
|
clientServerPort: number;
|
|
28
31
|
serverPort: number;
|
|
@@ -37,4 +40,5 @@ export declare type AppConfigs = {
|
|
|
37
40
|
serverOutputPath: string;
|
|
38
41
|
clientOutputPath: string;
|
|
39
42
|
statsOutputPath: string;
|
|
43
|
+
watchIgnorePath: string[];
|
|
40
44
|
};
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.updateWithConfigFile = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
9
|
-
const
|
|
9
|
+
const resolve_1 = require("../util/resolve");
|
|
10
10
|
const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
|
|
11
11
|
const available_package_settings_1 = require("./available-package-settings");
|
|
12
12
|
function updateWithConfigFile(config) {
|
|
13
|
-
const appConfigPath =
|
|
13
|
+
const appConfigPath = resolve_1.tryResolve(path_1.default.join(config.cwd, '/arui-scripts.config'));
|
|
14
14
|
if (appConfigPath) {
|
|
15
15
|
let appSettings = require(appConfigPath);
|
|
16
16
|
if (appSettings.__esModule) {
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.updateWithPresets = void 0;
|
|
7
7
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
|
-
const
|
|
8
|
+
const resolve_1 = require("../util/resolve");
|
|
9
9
|
const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
|
|
10
10
|
const available_package_settings_1 = require("./available-package-settings");
|
|
11
11
|
function updateWithPresets(config) {
|
|
@@ -13,8 +13,8 @@ function updateWithPresets(config) {
|
|
|
13
13
|
if (!packageSettings.presets) {
|
|
14
14
|
return config;
|
|
15
15
|
}
|
|
16
|
-
const presetsConfigPath =
|
|
17
|
-
const presetsOverridesPath =
|
|
16
|
+
const presetsConfigPath = resolve_1.tryResolve(`${packageSettings.presets}/arui-scripts.config`, { paths: [config.cwd] });
|
|
17
|
+
const presetsOverridesPath = resolve_1.tryResolve(`${packageSettings.presets}/arui-scripts.overrides`, { paths: [config.cwd] });
|
|
18
18
|
if (presetsConfigPath) {
|
|
19
19
|
let presetsSettings = require(presetsConfigPath);
|
|
20
20
|
if (presetsSettings.__esModule) {
|
|
@@ -41,7 +41,7 @@ const babelClientConfig = apply_overrides_1.default(['babel', 'babelClient'], {
|
|
|
41
41
|
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
|
|
42
42
|
// explicitly resolving to match the provided helper functions.
|
|
43
43
|
// https://github.com/babel/babel/issues/10261
|
|
44
|
-
version:
|
|
44
|
+
version: app_configs_1.default.babelRuntimeVersion,
|
|
45
45
|
regenerator: true,
|
|
46
46
|
}],
|
|
47
47
|
require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'),
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.babelDependencies = void 0;
|
|
7
7
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
8
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
8
9
|
exports.babelDependencies = apply_overrides_1.default('babelDependencies', {
|
|
9
10
|
sourceType: 'unambiguous',
|
|
10
11
|
presets: [
|
|
@@ -30,7 +31,7 @@ exports.babelDependencies = apply_overrides_1.default('babelDependencies', {
|
|
|
30
31
|
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
|
|
31
32
|
// explicitly resolving to match the provided helper functions.
|
|
32
33
|
// https://github.com/babel/babel/issues/10261
|
|
33
|
-
version:
|
|
34
|
+
version: app_configs_1.default.babelRuntimeVersion,
|
|
34
35
|
regenerator: true,
|
|
35
36
|
},
|
|
36
37
|
]
|
|
@@ -20,17 +20,22 @@ const devServerConfig = apply_overrides_1.default('devServer', {
|
|
|
20
20
|
},
|
|
21
21
|
static: [app_configs_1.default.serverOutputPath],
|
|
22
22
|
proxy: Object.assign(app_configs_1.default.appPackage.proxy || {}, {
|
|
23
|
-
'/**': {
|
|
24
|
-
target: `http://localhost:${app_configs_1.default.serverPort}`,
|
|
25
|
-
bypass: (req) => {
|
|
23
|
+
'/**': Object.assign({ target: `http://localhost:${app_configs_1.default.serverPort}`, bypass: (req) => {
|
|
26
24
|
var _a;
|
|
27
25
|
const assetsRoot = path_1.default.normalize(`/${app_configs_1.default.publicPath}`).replace(/\\/g, '/');
|
|
28
26
|
if ((_a = req === null || req === void 0 ? void 0 : req.url) === null || _a === void 0 ? void 0 : _a.startsWith(assetsRoot)) {
|
|
29
27
|
return req.url;
|
|
30
28
|
}
|
|
31
29
|
return null;
|
|
30
|
+
} }, (app_configs_1.default.devSourceMaps.includes('eval') ? {
|
|
31
|
+
onProxyRes: (proxyRes) => {
|
|
32
|
+
const cspHeader = proxyRes.headers['content-security-policy'];
|
|
33
|
+
if (typeof cspHeader === 'string' && !cspHeader.includes('unsafe-eval')) {
|
|
34
|
+
proxyRes.headers['content-security-policy'] = cspHeader
|
|
35
|
+
.replace(/script-src/, "script-src 'unsafe-eval'");
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
|
-
}
|
|
38
|
+
} : {}))
|
|
34
39
|
})
|
|
35
40
|
});
|
|
36
41
|
exports.default = devServerConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function tryResolve(...args: Parameters<typeof require.resolve>): string | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Возвращает полный путь до модуля из node_modules относительно базового пути.
|
|
4
|
+
* Может быть полезно для определения пути до модуля, когда в проекте установлено сразу несколько модулей.
|
|
5
|
+
* /project
|
|
6
|
+
* --/node_modules
|
|
7
|
+
* ----/module1 // через эту функцию мы получим этот модуль
|
|
8
|
+
* ----/arui-scripts
|
|
9
|
+
* ------/node_modules
|
|
10
|
+
* --------/module1 // через require.resolve мы получим этот модуль
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveNodeModuleRelativeTo(basePath: string, moduleName: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
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.resolveNodeModuleRelativeTo = exports.tryResolve = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function tryResolve(...args) {
|
|
9
|
+
try {
|
|
10
|
+
return require.resolve(...args);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.tryResolve = tryResolve;
|
|
17
|
+
/**
|
|
18
|
+
* Возвращает полный путь до модуля из node_modules относительно базового пути.
|
|
19
|
+
* Может быть полезно для определения пути до модуля, когда в проекте установлено сразу несколько модулей.
|
|
20
|
+
* /project
|
|
21
|
+
* --/node_modules
|
|
22
|
+
* ----/module1 // через эту функцию мы получим этот модуль
|
|
23
|
+
* ----/arui-scripts
|
|
24
|
+
* ------/node_modules
|
|
25
|
+
* --------/module1 // через require.resolve мы получим этот модуль
|
|
26
|
+
*/
|
|
27
|
+
function resolveNodeModuleRelativeTo(basePath, moduleName) {
|
|
28
|
+
return path_1.default.resolve(basePath, `node_modules/${moduleName}`);
|
|
29
|
+
}
|
|
30
|
+
exports.resolveNodeModuleRelativeTo = resolveNodeModuleRelativeTo;
|
|
@@ -37,8 +37,7 @@ function getSingleEntry(clientEntry) {
|
|
|
37
37
|
const webpackClientDev = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], {
|
|
38
38
|
target: 'web',
|
|
39
39
|
mode: 'development',
|
|
40
|
-
|
|
41
|
-
devtool: 'cheap-module-source-map',
|
|
40
|
+
devtool: app_configs_1.default.devSourceMaps,
|
|
42
41
|
// These are the "entry points" to our application.
|
|
43
42
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
44
43
|
entry: get_entry_1.default(app_configs_1.default.clientEntry, getSingleEntry),
|
|
@@ -257,8 +256,6 @@ const webpackClientDev = apply_overrides_1.default(['webpack', 'webpackClient',
|
|
|
257
256
|
// Tell Webpack to provide empty mocks for process.env.
|
|
258
257
|
'process.env': '{}'
|
|
259
258
|
}),
|
|
260
|
-
// This is necessary to emit hot updates (currently CSS only):
|
|
261
|
-
new webpack_1.default.HotModuleReplacementPlugin(),
|
|
262
259
|
new ReactRefreshWebpackPlugin({
|
|
263
260
|
overlay: {
|
|
264
261
|
sockIntegration: 'whm',
|
|
@@ -285,9 +282,13 @@ const webpackClientDev = apply_overrides_1.default(['webpack', 'webpackClient',
|
|
|
285
282
|
removeEmptyChunks: false,
|
|
286
283
|
splitChunks: false
|
|
287
284
|
},
|
|
285
|
+
experiments: {
|
|
286
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
287
|
+
},
|
|
288
288
|
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
289
289
|
watchOptions: {
|
|
290
|
-
ignored:
|
|
290
|
+
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
291
|
+
aggregateTimeout: 100,
|
|
291
292
|
}
|
|
292
293
|
});
|
|
293
294
|
exports.default = webpackClientDev;
|
|
@@ -332,5 +332,8 @@ const config = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackPr
|
|
|
332
332
|
new webpack_1.default.NormalModuleReplacementPlugin(/^react-style-proptype$/, noopPath),
|
|
333
333
|
new webpack_1.default.NormalModuleReplacementPlugin(/^thrift-services\/proptypes/, noopPath)
|
|
334
334
|
])),
|
|
335
|
+
experiments: {
|
|
336
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
337
|
+
},
|
|
335
338
|
});
|
|
336
339
|
exports.default = config;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
9
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
10
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
11
|
+
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
12
|
+
// style files regexes
|
|
13
|
+
const cssRegex = /\.css$/;
|
|
14
|
+
const cssModuleRegex = /\.module\.css$/;
|
|
15
|
+
const webpackDllDev = {
|
|
16
|
+
mode: 'development',
|
|
17
|
+
entry: {
|
|
18
|
+
vendor: ['react', 'react-dom', 'lodash']
|
|
19
|
+
},
|
|
20
|
+
module: {
|
|
21
|
+
rules: [
|
|
22
|
+
{
|
|
23
|
+
test: cssRegex,
|
|
24
|
+
exclude: cssModuleRegex,
|
|
25
|
+
use: [
|
|
26
|
+
{
|
|
27
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
28
|
+
options: { publicPath: './' }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
loader: require.resolve('css-loader'),
|
|
32
|
+
options: {
|
|
33
|
+
importLoaders: 1,
|
|
34
|
+
sourceMap: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
loader: require.resolve('postcss-loader'),
|
|
39
|
+
options: {
|
|
40
|
+
// Necessary for external CSS imports to work
|
|
41
|
+
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
42
|
+
ident: 'postcss',
|
|
43
|
+
plugins: () => postcss_1.default,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
test: cssModuleRegex,
|
|
50
|
+
use: [
|
|
51
|
+
{
|
|
52
|
+
loader: mini_css_extract_plugin_1.default.loader,
|
|
53
|
+
options: { publicPath: './' }
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
loader: require.resolve('css-loader'),
|
|
57
|
+
options: {
|
|
58
|
+
importLoaders: 1,
|
|
59
|
+
sourceMap: false,
|
|
60
|
+
modules: {
|
|
61
|
+
getLocalIdent: getCSSModuleLocalIdent_1.default
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
loader: require.resolve('postcss-loader'),
|
|
67
|
+
options: {
|
|
68
|
+
// Necessary for external CSS imports to work
|
|
69
|
+
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
70
|
+
ident: 'postcss',
|
|
71
|
+
plugins: () => postcss_1.default,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
output: {
|
|
79
|
+
filename: 'vendor.bundle.js',
|
|
80
|
+
path: app_configs_1.default.clientOutputPath,
|
|
81
|
+
library: 'vendor_lib'
|
|
82
|
+
},
|
|
83
|
+
plugins: [
|
|
84
|
+
new mini_css_extract_plugin_1.default(),
|
|
85
|
+
new webpack_1.default.DllPlugin({
|
|
86
|
+
name: 'vendor_lib',
|
|
87
|
+
path: path_1.default.join(app_configs_1.default.clientOutputPath, 'vendor-manifest.json')
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
exports.default = webpackDllDev;
|
|
@@ -33,8 +33,7 @@ function getSingleEntry(entryPoint) {
|
|
|
33
33
|
// The production configuration is different and lives in a separate file.
|
|
34
34
|
const config = {
|
|
35
35
|
mode: 'development',
|
|
36
|
-
|
|
37
|
-
devtool: 'cheap-module-source-map',
|
|
36
|
+
devtool: app_configs_1.default.devSourceMaps,
|
|
38
37
|
target: 'node',
|
|
39
38
|
node: {
|
|
40
39
|
__filename: true,
|
|
@@ -233,6 +232,9 @@ const config = {
|
|
|
233
232
|
performance: {
|
|
234
233
|
hints: false,
|
|
235
234
|
},
|
|
235
|
+
experiments: {
|
|
236
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
237
|
+
},
|
|
236
238
|
watchOptions: {
|
|
237
239
|
ignored: /node_modules/,
|
|
238
240
|
}
|
|
@@ -201,5 +201,8 @@ const config = apply_overrides_1.default(['webpack', 'webpackServer', 'webpackPr
|
|
|
201
201
|
}),
|
|
202
202
|
app_configs_1.default.tsconfig !== null && new fork_ts_checker_webpack_plugin_1.default()
|
|
203
203
|
].filter(Boolean)),
|
|
204
|
+
experiments: {
|
|
205
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
206
|
+
},
|
|
204
207
|
});
|
|
205
208
|
exports.default = config;
|