@gravity-ui/app-builder 0.6.11 → 0.7.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 (42) hide show
  1. package/README.md +29 -27
  2. package/dist/commands/build/build-service/server.js +1 -1
  3. package/dist/commands/build/index.js +1 -1
  4. package/dist/commands/dev/client.js +33 -10
  5. package/dist/commands/dev/index.js +25 -2
  6. package/dist/commands/dev/server.js +25 -2
  7. package/dist/common/babel/ui-preset.js +7 -0
  8. package/dist/common/child-process/controllable-script.js +4 -2
  9. package/dist/common/child-process/utils.js +5 -8
  10. package/dist/common/config.d.ts +1 -1
  11. package/dist/common/config.js +25 -2
  12. package/dist/common/env.js +2 -2
  13. package/dist/common/library/index.js +77 -55
  14. package/dist/common/links/link.js +42 -19
  15. package/dist/common/links/unlink.js +26 -3
  16. package/dist/common/logger/index.js +79 -79
  17. package/dist/common/models/index.d.ts +3 -3
  18. package/dist/common/package.js +30 -10
  19. package/dist/common/paths.js +26 -6
  20. package/dist/common/s3-upload/compress.js +3 -3
  21. package/dist/common/s3-upload/s3-client.d.ts +1 -1
  22. package/dist/common/s3-upload/s3-client.js +1 -1
  23. package/dist/common/s3-upload/upload.js +1 -1
  24. package/dist/common/s3-upload/webpack-plugin.js +1 -0
  25. package/dist/common/tempData.js +31 -7
  26. package/dist/common/typescript/compile.d.ts +7 -2
  27. package/dist/common/typescript/compile.js +5 -5
  28. package/dist/common/typescript/diagnostic.js +24 -4
  29. package/dist/common/typescript/transformers.js +1 -1
  30. package/dist/common/typescript/utils.d.ts +1 -1
  31. package/dist/common/typescript/utils.js +3 -3
  32. package/dist/common/utils.js +5 -5
  33. package/dist/common/webpack/config.js +33 -23
  34. package/dist/common/webpack/progress-plugin.js +6 -5
  35. package/dist/common/webpack/storybook.js +25 -3
  36. package/dist/common/webpack/utils.js +29 -9
  37. package/dist/common/webpack/worker/worker-loader.js +27 -4
  38. package/dist/create-cli.js +25 -2
  39. package/package.json +14 -11
  40. package/CHANGELOG.md +0 -264
  41. package/dist/common/library/babel-plugin-remove-css-imports.d.ts +0 -6
  42. package/dist/common/library/babel-plugin-remove-css-imports.js +0 -15
@@ -1,18 +1,38 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.readNodeModules = exports.readPackage = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
27
+ const fs = __importStar(require("node:fs"));
28
+ const path = __importStar(require("node:path"));
9
29
  function readPackage(location) {
10
- const packageJsonLocation = path_1.default.resolve(location, 'package.json');
11
- if (!fs_1.default.existsSync(packageJsonLocation)) {
30
+ const packageJsonLocation = path.resolve(location, 'package.json');
31
+ if (!fs.existsSync(packageJsonLocation)) {
12
32
  throw new Error(`package.json not found in ${location}`);
13
33
  }
14
34
  try {
15
- const packageJson = fs_1.default.readFileSync(packageJsonLocation, 'utf-8');
35
+ const packageJson = fs.readFileSync(packageJsonLocation, 'utf-8');
16
36
  return {
17
37
  ...JSON.parse(packageJson),
18
38
  location,
@@ -24,11 +44,11 @@ function readPackage(location) {
24
44
  }
25
45
  exports.readPackage = readPackage;
26
46
  function readNodeModules(location) {
27
- const dirContents = fs_1.default.readdirSync(location);
47
+ const dirContents = fs.readdirSync(location);
28
48
  return dirContents.reduce((acc, nodeModule) => {
29
49
  if (!nodeModule.startsWith('.')) {
30
- const nodeModulePath = path_1.default.resolve(location, nodeModule);
31
- if (fs_1.default.existsSync(path_1.default.resolve(nodeModulePath, 'package.json'))) {
50
+ const nodeModulePath = path.resolve(location, nodeModule);
51
+ if (fs.existsSync(path.resolve(nodeModulePath, 'package.json'))) {
32
52
  const packageInfo = readPackage(nodeModulePath);
33
53
  acc.data[packageInfo.name] = packageInfo;
34
54
  acc.keys.push(packageInfo.name);
@@ -1,12 +1,32 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = __importDefault(require("fs"));
7
- const path_1 = __importDefault(require("path"));
8
- const appDirectory = fs_1.default.realpathSync(process.cwd());
9
- const resolveApp = (relativePath) => path_1.default.resolve(appDirectory, relativePath);
26
+ const fs = __importStar(require("node:fs"));
27
+ const path = __importStar(require("node:path"));
28
+ const appDirectory = fs.realpathSync(process.cwd());
29
+ const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
10
30
  exports.default = {
11
31
  app: resolveApp('.'),
12
32
  appNodeModules: resolveApp('node_modules'),
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.brotli = exports.gzip = void 0;
4
- const fs_1 = require("fs");
4
+ const node_fs_1 = require("node:fs");
5
5
  const zlib_1 = require("zlib");
6
6
  function compressor(sourcePath, destinationPath, transformer) {
7
7
  return new Promise((resolve, reject) => {
8
- const sourceStream = (0, fs_1.createReadStream)(sourcePath);
8
+ const sourceStream = (0, node_fs_1.createReadStream)(sourcePath);
9
9
  sourceStream.on('error', reject);
10
- const destinationStream = (0, fs_1.createWriteStream)(destinationPath);
10
+ const destinationStream = (0, node_fs_1.createWriteStream)(destinationPath);
11
11
  destinationStream.on('finish', () => resolve(destinationPath));
12
12
  destinationStream.on('error', reject);
13
13
  sourceStream.pipe(transformer).pipe(destinationStream);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { S3ClientConfig, PutObjectCommandInput } from '@aws-sdk/client-s3';
2
+ import type { PutObjectCommandInput, S3ClientConfig } from '@aws-sdk/client-s3';
3
3
  export type S3ClientOptions = S3ClientConfig;
4
4
  export declare function getS3Client(options: S3ClientOptions): {
5
5
  headObject(bucket: string, key: string): Promise<import("@aws-sdk/client-s3").HeadObjectCommandOutput>;
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.getS3Client = void 0;
30
30
  const fs = __importStar(require("fs/promises"));
31
- const path = __importStar(require("path"));
31
+ const path = __importStar(require("node:path"));
32
32
  const client_s3_1 = require("@aws-sdk/client-s3");
33
33
  const file_type_1 = require("file-type");
34
34
  const mime = __importStar(require("mime-types"));
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.uploadFiles = void 0;
30
- const path = __importStar(require("path"));
30
+ const path = __importStar(require("node:path"));
31
31
  const p_queue_1 = __importDefault(require("p-queue"));
32
32
  const s3_client_js_1 = require("./s3-client.js");
33
33
  const compress_js_1 = require("./compress.js");
@@ -5,6 +5,7 @@ const webpack_1 = require("webpack");
5
5
  const fast_glob_1 = require("fast-glob");
6
6
  const upload_js_1 = require("./upload.js");
7
7
  class S3UploadPlugin {
8
+ options;
8
9
  constructor(options) {
9
10
  this.options = options;
10
11
  }
@@ -1,17 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const fs_1 = __importDefault(require("fs"));
29
+ const path = __importStar(require("node:path"));
30
+ const fs = __importStar(require("node:fs"));
8
31
  const paths_1 = __importDefault(require("./paths"));
9
32
  const logger_1 = __importDefault(require("./logger"));
10
- const tempDataPath = path_1.default.resolve(paths_1.default.appNodeModules, '.app-builder.temp.json');
33
+ const tempDataPath = path.resolve(paths_1.default.appNodeModules, '.app-builder.temp.json');
11
34
  class TempDataUtils {
35
+ state;
12
36
  constructor() {
13
37
  try {
14
- const settingsJson = fs_1.default.readFileSync(tempDataPath, 'utf-8');
38
+ const settingsJson = fs.readFileSync(tempDataPath, 'utf-8');
15
39
  this.state = JSON.parse(settingsJson);
16
40
  }
17
41
  catch (e) {
@@ -20,11 +44,11 @@ class TempDataUtils {
20
44
  }
21
45
  saveSettings(newSettings = {}) {
22
46
  this.state = { ...this.state, ...newSettings };
23
- if (fs_1.default.existsSync(tempDataPath)) {
24
- fs_1.default.unlinkSync(tempDataPath);
47
+ if (fs.existsSync(tempDataPath)) {
48
+ fs.unlinkSync(tempDataPath);
25
49
  }
26
50
  try {
27
- fs_1.default.writeFileSync(tempDataPath, JSON.stringify(this.state), 'utf-8');
51
+ fs.writeFileSync(tempDataPath, JSON.stringify(this.state), 'utf-8');
28
52
  return true;
29
53
  }
30
54
  catch (e) {
@@ -1,5 +1,10 @@
1
1
  import type Typescript from 'typescript';
2
2
  import type { Logger } from '../logger';
3
- export declare function compile(ts: typeof Typescript, projectPath: string, { logger }: {
3
+ interface CompileOptions {
4
+ projectPath: string;
5
+ configFileName?: string;
4
6
  logger: Logger;
5
- }): void;
7
+ optionsToExtend?: Typescript.CompilerOptions;
8
+ }
9
+ export declare function compile(ts: typeof Typescript, { projectPath, configFileName, optionsToExtend, logger }: CompileOptions): void;
10
+ export {};
@@ -5,12 +5,12 @@ const utils_1 = require("./utils");
5
5
  const transformers_1 = require("./transformers");
6
6
  const pretty_time_1 = require("../logger/pretty-time");
7
7
  const diagnostic_1 = require("./diagnostic");
8
- function compile(ts, projectPath, { logger }) {
8
+ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToExtend, logger }) {
9
9
  const start = process.hrtime.bigint();
10
10
  logger.message('Start compilation');
11
11
  logger.message(`Typescript v${ts.version}`);
12
- logger.verbose(`Searching for the tsconfig.json in ${projectPath}`);
13
- const configPath = (0, utils_1.getProjectConfig)(ts, projectPath);
12
+ logger.verbose(`Searching for the ${configFileName} in ${projectPath}`);
13
+ const configPath = (0, utils_1.getProjectConfig)(ts, projectPath, configFileName);
14
14
  const formatHost = {
15
15
  getCanonicalFileName: (path) => path,
16
16
  getCurrentDirectory: ts.sys.getCurrentDirectory,
@@ -24,9 +24,9 @@ function compile(ts, projectPath, { logger }) {
24
24
  readFile: ts.sys.readFile,
25
25
  onUnRecoverableConfigFileDiagnostic: reportDiagnostic,
26
26
  };
27
- const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, { noEmitOnError: true }, parseConfigFileHost);
27
+ const parsedConfig = ts.getParsedCommandLineOfConfigFile(configPath, { noEmitOnError: true, ...optionsToExtend }, parseConfigFileHost);
28
28
  if (!parsedConfig) {
29
- throw new Error("Invalid 'tsconfig.json'");
29
+ throw new Error(`Invalid '${configFileName}'`);
30
30
  }
31
31
  logger.verbose('Config found and parsed');
32
32
  logger.verbose("We're about to create the program");
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.formatDiagnosticBrief = void 0;
7
- const path_1 = __importDefault(require("path"));
27
+ const path = __importStar(require("node:path"));
8
28
  const colors_1 = require("../logger/colors");
9
29
  function formatDiagnosticBrief(ts, diagnostic, host) {
10
30
  let output = '';
@@ -19,7 +39,7 @@ function formatDiagnosticBrief(ts, diagnostic, host) {
19
39
  return output;
20
40
  function formatLocation(file, start) {
21
41
  const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
22
- const filePath = path_1.default.relative(process.cwd(), file.fileName);
42
+ const filePath = path.relative(process.cwd(), file.fileName);
23
43
  return (colors_1.colors.cyanBright(filePath) +
24
44
  ':' +
25
45
  colors_1.colors.yellowBright(line + 1) +
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createTransformPathsToLocalModules = void 0;
27
- const path = __importStar(require("path"));
27
+ const path = __importStar(require("node:path"));
28
28
  const semver = __importStar(require("semver"));
29
29
  function createTransformPathsToLocalModules(ts) {
30
30
  function resolveModule(module, sourceFileName, options) {
@@ -1,6 +1,6 @@
1
1
  import type Typescript from 'typescript';
2
2
  import type { Logger } from '../logger';
3
- export declare function getProjectConfig(ts: typeof Typescript, projectPath: string): string;
3
+ export declare function getProjectConfig(ts: typeof Typescript, projectPath: string, filename?: string): string;
4
4
  export declare function displayFilename(originalFunc: (path: string, encoding?: string) => string | undefined, operationName: string, logger: Logger): {
5
5
  (path: string, encoding?: string | undefined): string | undefined;
6
6
  originalFunc: (path: string, encoding?: string) => string | undefined;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onHostEvent = exports.displayFilename = exports.getProjectConfig = void 0;
4
- function getProjectConfig(ts, projectPath) {
5
- const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, 'tsconfig.json');
4
+ function getProjectConfig(ts, projectPath, filename = 'tsconfig.json') {
5
+ const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
6
6
  if (!configPath) {
7
- throw new Error("Could not find a valid 'tsconfig.json'.");
7
+ throw new Error(`Could not find a valid '${filename}'.`);
8
8
  }
9
9
  return configPath;
10
10
  }
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPort = exports.getCacheDir = exports.shouldCompileTarget = exports.createRunFolder = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_os_1 = __importDefault(require("node:os"));
9
9
  const find_cache_dir_1 = __importDefault(require("find-cache-dir"));
10
10
  const paths_1 = __importDefault(require("./paths"));
11
11
  function createRunFolder() {
12
12
  const runPath = paths_1.default.appRun;
13
- if (!fs_1.default.existsSync(runPath)) {
14
- fs_1.default.mkdirSync(runPath, { recursive: true });
13
+ if (!node_fs_1.default.existsSync(runPath)) {
14
+ node_fs_1.default.mkdirSync(runPath, { recursive: true });
15
15
  }
16
16
  }
17
17
  exports.createRunFolder = createRunFolder;
@@ -20,7 +20,7 @@ function shouldCompileTarget(target, targetName) {
20
20
  }
21
21
  exports.shouldCompileTarget = shouldCompileTarget;
22
22
  function getCacheDir() {
23
- return (0, find_cache_dir_1.default)({ name: '@gravity-ui/app-builder', create: true }) || os_1.default.tmpdir();
23
+ return (0, find_cache_dir_1.default)({ name: '@gravity-ui/app-builder', create: true }) || node_os_1.default.tmpdir();
24
24
  }
25
25
  exports.getCacheDir = getCacheDir;
26
26
  async function getPort({ port }) {
@@ -28,8 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.configureResolve = exports.configureModuleRules = exports.webpackConfigFactory = void 0;
30
30
  /* eslint-disable complexity */
31
- const path_1 = __importStar(require("path"));
32
- const fs_1 = __importDefault(require("fs"));
31
+ const path = __importStar(require("node:path"));
32
+ const fs = __importStar(require("node:fs"));
33
33
  const webpack = __importStar(require("webpack"));
34
34
  const lodash_1 = __importDefault(require("lodash"));
35
35
  const clean_webpack_plugin_1 = require("clean-webpack-plugin");
@@ -193,7 +193,7 @@ function configureExperiments({ config, isEnvProduction, }) {
193
193
  function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
194
194
  let alias = config.alias || {};
195
195
  alias = Object.entries(alias).reduce((result, [key, value]) => {
196
- result[key] = path_1.default.resolve(paths_1.default.app, value);
196
+ result[key] = path.resolve(paths_1.default.app, value);
197
197
  return result;
198
198
  }, {});
199
199
  if (isEnvProduction && config.reactProfiling) {
@@ -205,7 +205,7 @@ function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
205
205
  alias[`${name}$`] = `${name}/src`;
206
206
  });
207
207
  }
208
- const { aliases, modules = [] } = (0, utils_1.resolveTsconfigPathsToAlias)(path_1.default.resolve(paths_1.default.appClient, 'tsconfig.json')) || {};
208
+ const { aliases, modules = [] } = (0, utils_1.resolveTsconfigPathsToAlias)(path.resolve(paths_1.default.appClient, 'tsconfig.json')) || {};
209
209
  return {
210
210
  alias: {
211
211
  ...aliases,
@@ -222,14 +222,14 @@ function createEntryArray(entry) {
222
222
  return [require.resolve('./public-path'), entry];
223
223
  }
224
224
  function addEntry(entry, file) {
225
- const newEntry = path_1.default.resolve(paths_1.default.appEntry, file);
225
+ const newEntry = path.resolve(paths_1.default.appEntry, file);
226
226
  return {
227
227
  ...entry,
228
- [path_1.default.parse(file).name]: createEntryArray(newEntry),
228
+ [path.parse(file).name]: createEntryArray(newEntry),
229
229
  };
230
230
  }
231
231
  function configureEntry({ config }) {
232
- let entries = fs_1.default.readdirSync(paths_1.default.appEntry).filter((file) => /\.[jt]sx?$/.test(file));
232
+ let entries = fs.readdirSync(paths_1.default.appEntry).filter((file) => /\.[jt]sx?$/.test(file));
233
233
  if (Array.isArray(config.entryFilter) && config.entryFilter.length) {
234
234
  entries = entries.filter((entry) => config.entryFilter?.includes(entry.split('.')[0] ?? ''));
235
235
  }
@@ -289,7 +289,7 @@ function createJavaScriptRule({ updateIncludes = lodash_1.default.identity, conf
289
289
  const include = updateIncludes([
290
290
  paths_1.default.appClient,
291
291
  ...(config.monaco && isEnvProduction
292
- ? [path_1.default.resolve(paths_1.default.appNodeModules, 'monaco-editor/esm/vs')]
292
+ ? [path.resolve(paths_1.default.appNodeModules, 'monaco-editor/esm/vs')]
293
293
  : []),
294
294
  ...(config.includes || []),
295
295
  ]);
@@ -593,11 +593,11 @@ function configurePlugins(options) {
593
593
  ...config.monaco,
594
594
  // currently, workers located on cdn are not working properly, so we are enforcing loading workers from
595
595
  // service instead
596
- publicPath: path_1.default.normalize(config.publicPathPrefix + '/build/'),
596
+ publicPath: path.normalize(config.publicPathPrefix + '/build/'),
597
597
  }));
598
598
  }
599
599
  if (isEnvDevelopment && !config.disableReactRefresh) {
600
- const { webSocketPath = path_1.default.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
600
+ const { webSocketPath = path.normalize(`/${config.publicPathPrefix}/build/sockjs-node`) } = config.devServer || {};
601
601
  plugins.push(new react_refresh_webpack_plugin_1.default({
602
602
  overlay: { sockPath: webSocketPath },
603
603
  exclude: /\.worker\.[jt]sx?$/,
@@ -617,8 +617,8 @@ function configurePlugins(options) {
617
617
  plugins.push(new fork_ts_checker_webpack_plugin_1.default({
618
618
  ...config.forkTsChecker,
619
619
  typescript: {
620
- typescriptPath: require.resolve((0, path_1.resolve)(paths_1.default.appNodeModules, 'typescript')),
621
- configFile: (0, path_1.resolve)(paths_1.default.app, 'src/ui/tsconfig.json'),
620
+ typescriptPath: require.resolve(path.resolve(paths_1.default.appNodeModules, 'typescript')),
621
+ configFile: path.resolve(paths_1.default.app, 'src/ui/tsconfig.json'),
622
622
  diagnosticOptions: {
623
623
  syntactic: true,
624
624
  },
@@ -649,8 +649,8 @@ function configurePlugins(options) {
649
649
  if (config.analyzeBundle === 'statoscope') {
650
650
  const customStatoscopeConfig = config.statoscopeConfig || {};
651
651
  plugins.push(new webpack_plugin_1.default({
652
- saveReportTo: path_1.default.resolve(paths_1.default.appBuild, 'report.html'),
653
- saveStatsTo: path_1.default.resolve(paths_1.default.appBuild, 'stats.json'),
652
+ saveReportTo: path.resolve(paths_1.default.appBuild, 'report.html'),
653
+ saveStatsTo: path.resolve(paths_1.default.appBuild, 'stats.json'),
654
654
  open: false,
655
655
  statsOptions: {
656
656
  all: true,
@@ -668,7 +668,7 @@ function configurePlugins(options) {
668
668
  : {
669
669
  entrypoints: true,
670
670
  writeToDisk: true,
671
- output: path_1.default.resolve(paths_1.default.appBuild, manifestFile),
671
+ output: path.resolve(paths_1.default.appBuild, manifestFile),
672
672
  }));
673
673
  if (config.cdn) {
674
674
  let credentialsGlobal;
@@ -713,7 +713,7 @@ function configurePlugins(options) {
713
713
  }
714
714
  function configureOptimization({ config }) {
715
715
  const configVendors = config.vendors ?? [];
716
- const vendorsList = [
716
+ let vendorsList = [
717
717
  'react',
718
718
  'react-dom',
719
719
  'prop-types',
@@ -725,18 +725,28 @@ function configureOptimization({ config }) {
725
725
  'moment',
726
726
  'bem-cn-lite',
727
727
  'axios',
728
- ...configVendors,
729
728
  ];
729
+ if (typeof configVendors === 'function') {
730
+ vendorsList = configVendors(vendorsList);
731
+ }
732
+ else if (Array.isArray(configVendors)) {
733
+ vendorsList = vendorsList.concat(configVendors);
734
+ }
735
+ const useVendorsList = vendorsList.length > 0;
730
736
  const optimization = {
731
737
  splitChunks: {
732
738
  chunks: 'all',
733
739
  cacheGroups: {
734
- defaultVendors: {
735
- name: 'vendors',
736
- // eslint-disable-next-line security/detect-non-literal-regexp
737
- test: new RegExp(`([\\\\/])node_modules\\1(${vendorsList.join('|')})\\1`),
738
- priority: Infinity,
739
- },
740
+ ...(useVendorsList
741
+ ? {
742
+ defaultVendors: {
743
+ name: 'vendors',
744
+ // eslint-disable-next-line security/detect-non-literal-regexp
745
+ test: new RegExp(`([\\\\/])node_modules\\1(${vendorsList.join('|')})\\1`),
746
+ priority: Infinity,
747
+ },
748
+ }
749
+ : undefined),
740
750
  css: {
741
751
  test: /\.css$/,
742
752
  enforce: true,
@@ -27,15 +27,16 @@ exports.ProgressPlugin = void 0;
27
27
  const webpack = __importStar(require("webpack"));
28
28
  const pretty_time_1 = require("../logger/pretty-time");
29
29
  class ProgressPlugin extends webpack.ProgressPlugin {
30
+ _logger;
31
+ _state = {};
30
32
  constructor({ logger }) {
31
33
  super();
32
- this._state = {};
33
- this.handler = (percent, message, ...details) => {
34
- const progress = Math.floor(percent * 100);
35
- this._logger.status(`${this._logger.colors.green(`${progress}%`)} - ${this._logger.colors.yellow(message)}${details.length > 0 ? `: ${this._logger.colors.dim(...details)}` : ''}`);
36
- };
37
34
  this._logger = logger;
38
35
  }
36
+ handler = (percent, message, ...details) => {
37
+ const progress = Math.floor(percent * 100);
38
+ this._logger.status(`${this._logger.colors.green(`${progress}%`)} - ${this._logger.colors.yellow(message)}${details.length > 0 ? `: ${this._logger.colors.dim(...details)}` : ''}`);
39
+ };
39
40
  apply(compiler) {
40
41
  super.apply(compiler);
41
42
  hook(compiler, 'compile', () => {
@@ -1,10 +1,33 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.configureWebpackConfigForStorybook = exports.configureServiceWebpackConfig = void 0;
7
- const path_1 = __importDefault(require("path"));
30
+ const path = __importStar(require("node:path"));
8
31
  const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
9
32
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
10
33
  const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
@@ -78,8 +101,7 @@ exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
78
101
  function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
79
102
  const plugins = [];
80
103
  if (config.definitions) {
81
- // eslint-disable-next-line security/detect-non-literal-require
82
- const webpack = require(path_1.default.resolve(process.cwd(), 'node_modules/webpack'));
104
+ const webpack = require(path.resolve(process.cwd(), 'node_modules/webpack'));
83
105
  plugins.push(new webpack.DefinePlugin({
84
106
  ...config.definitions,
85
107
  }));