@gravity-ui/app-builder 0.30.0 → 0.30.2

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 (59) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +20 -15
  3. package/dist/commands/build/build-lib.js +8 -5
  4. package/dist/commands/build/build-service/client.js +6 -3
  5. package/dist/commands/build/build-service/index.js +7 -4
  6. package/dist/commands/build/build-service/server.js +17 -11
  7. package/dist/commands/build/index.js +6 -3
  8. package/dist/commands/dev/client.js +63 -34
  9. package/dist/commands/dev/index.js +50 -21
  10. package/dist/commands/dev/server.js +42 -13
  11. package/dist/common/babel/index.js +4 -1
  12. package/dist/common/babel/ui-preset.d.ts +1 -1
  13. package/dist/common/babel/ui-preset.js +1 -0
  14. package/dist/common/child-process/controllable-script.js +32 -5
  15. package/dist/common/child-process/utils.js +30 -4
  16. package/dist/common/command.js +2 -1
  17. package/dist/common/config.js +49 -19
  18. package/dist/common/env.js +5 -3
  19. package/dist/common/library/babel-plugin-replace-paths.js +4 -2
  20. package/dist/common/library/index.js +95 -66
  21. package/dist/common/logger/colors.js +8 -2
  22. package/dist/common/logger/index.js +24 -17
  23. package/dist/common/logger/log-config.js +6 -3
  24. package/dist/common/logger/pretty-time.js +6 -2
  25. package/dist/common/models/index.d.ts +6 -1
  26. package/dist/common/models/index.js +8 -3
  27. package/dist/common/paths.js +28 -3
  28. package/dist/common/s3-upload/compress.js +12 -8
  29. package/dist/common/s3-upload/create-plugin.js +30 -4
  30. package/dist/common/s3-upload/index.js +9 -3
  31. package/dist/common/s3-upload/s3-client.js +37 -11
  32. package/dist/common/s3-upload/upload.js +38 -9
  33. package/dist/common/s3-upload/webpack-plugin.js +9 -5
  34. package/dist/common/swc/compile.js +12 -9
  35. package/dist/common/swc/index.js +7 -2
  36. package/dist/common/swc/utils.js +13 -6
  37. package/dist/common/swc/watch.js +9 -6
  38. package/dist/common/typescript/compile.js +14 -11
  39. package/dist/common/typescript/diagnostic.js +37 -11
  40. package/dist/common/typescript/transformers.js +29 -3
  41. package/dist/common/typescript/utils.js +18 -8
  42. package/dist/common/typescript/watch.js +13 -10
  43. package/dist/common/utils.js +25 -14
  44. package/dist/common/webpack/compile.js +22 -16
  45. package/dist/common/webpack/config.js +143 -89
  46. package/dist/common/webpack/node-externals.js +34 -5
  47. package/dist/common/webpack/progress-plugin.js +6 -3
  48. package/dist/common/webpack/public-path.d.ts +1 -0
  49. package/dist/common/webpack/public-path.js +1 -0
  50. package/dist/common/webpack/rspack.js +5 -1
  51. package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
  52. package/dist/common/webpack/storybook.js +51 -21
  53. package/dist/common/webpack/utils.js +36 -9
  54. package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
  55. package/dist/common/webpack/worker/public-path.worker.js +1 -0
  56. package/dist/common/webpack/worker/worker-loader.js +34 -4
  57. package/dist/create-cli.js +48 -19
  58. package/dist/index.js +27 -5
  59. package/package.json +1 -2
@@ -1,6 +1,32 @@
1
- import * as path from 'node:path';
2
- import { colors } from '../logger/colors';
3
- export function formatDiagnosticBrief(ts, diagnostic, host) {
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.formatDiagnosticBrief = formatDiagnosticBrief;
27
+ const path = __importStar(require("node:path"));
28
+ const colors_1 = require("../logger/colors");
29
+ function formatDiagnosticBrief(ts, diagnostic, host) {
4
30
  let output = '';
5
31
  if (diagnostic.file) {
6
32
  const { file, start } = diagnostic;
@@ -8,31 +34,31 @@ export function formatDiagnosticBrief(ts, diagnostic, host) {
8
34
  output += ' - ';
9
35
  }
10
36
  output += categoryColor(diagnostic.category)(ts.DiagnosticCategory[diagnostic.category]);
11
- output += colors.grey(` TS${diagnostic.code}: `);
37
+ output += colors_1.colors.grey(` TS${diagnostic.code}: `);
12
38
  output += ts.flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
13
39
  return output;
14
40
  function formatLocation(file, start) {
15
41
  const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
16
42
  const filePath = path.relative(process.cwd(), file.fileName);
17
- return (colors.cyanBright(filePath) +
43
+ return (colors_1.colors.cyanBright(filePath) +
18
44
  ':' +
19
- colors.yellowBright(line + 1) +
45
+ colors_1.colors.yellowBright(line + 1) +
20
46
  ':' +
21
- colors.yellowBright(character + 1));
47
+ colors_1.colors.yellowBright(character + 1));
22
48
  }
23
49
  function categoryColor(category) {
24
50
  switch (category) {
25
51
  case ts.DiagnosticCategory.Error: {
26
- return colors.redBright;
52
+ return colors_1.colors.redBright;
27
53
  }
28
54
  case ts.DiagnosticCategory.Warning: {
29
- return colors.yellowBright;
55
+ return colors_1.colors.yellowBright;
30
56
  }
31
57
  case ts.DiagnosticCategory.Suggestion: {
32
- return colors.magentaBright;
58
+ return colors_1.colors.magentaBright;
33
59
  }
34
60
  default: {
35
- return colors;
61
+ return colors_1.colors;
36
62
  }
37
63
  }
38
64
  }
@@ -1,6 +1,32 @@
1
- import * as path from 'node:path';
2
- import * as semver from 'semver';
3
- export function createTransformPathsToLocalModules(ts) {
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
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.createTransformPathsToLocalModules = createTransformPathsToLocalModules;
27
+ const path = __importStar(require("node:path"));
28
+ const semver = __importStar(require("semver"));
29
+ function createTransformPathsToLocalModules(ts) {
4
30
  function resolveModule(module, sourceFileName, options) {
5
31
  if (module.startsWith('.')) {
6
32
  return undefined;
@@ -1,13 +1,23 @@
1
- import path from 'node:path';
2
- import paths from '../paths';
3
- export function getTsProjectConfigPath(ts, projectPath, filename = 'tsconfig.json') {
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.getTsProjectConfigPath = getTsProjectConfigPath;
7
+ exports.getTsProjectConfig = getTsProjectConfig;
8
+ exports.displayFilename = displayFilename;
9
+ exports.onHostEvent = onHostEvent;
10
+ exports.resolveTypescript = resolveTypescript;
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const paths_1 = __importDefault(require("../paths"));
13
+ function getTsProjectConfigPath(ts, projectPath, filename = 'tsconfig.json') {
4
14
  const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
5
15
  if (!configPath) {
6
16
  throw new Error(`Could not find a valid '${filename}'.`);
7
17
  }
8
18
  return configPath;
9
19
  }
10
- export function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
20
+ function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
11
21
  const configPath = getTsProjectConfigPath(ts, projectPath, filename);
12
22
  const parseConfigFileHost = {
13
23
  getCurrentDirectory: ts.sys.getCurrentDirectory,
@@ -24,7 +34,7 @@ export function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json',
24
34
  }
25
35
  return parsedConfig;
26
36
  }
27
- export function displayFilename(originalFunc, operationName, logger) {
37
+ function displayFilename(originalFunc, operationName, logger) {
28
38
  let displayEnabled = false;
29
39
  let count = 0;
30
40
  function displayFunction(...args) {
@@ -52,7 +62,7 @@ export function displayFilename(originalFunc, operationName, logger) {
52
62
  return displayFunction;
53
63
  }
54
64
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- export function onHostEvent(host, functionName, before, after) {
65
+ function onHostEvent(host, functionName, before, after) {
56
66
  const originalFunction = host[functionName];
57
67
  // eslint-disable-next-line no-param-reassign
58
68
  host[functionName] = ((...args) => {
@@ -69,9 +79,9 @@ export function onHostEvent(host, functionName, before, after) {
69
79
  return result;
70
80
  });
71
81
  }
72
- export function resolveTypescript() {
82
+ function resolveTypescript() {
73
83
  try {
74
- return require.resolve(path.resolve(paths.appNodeModules, 'typescript'));
84
+ return require.resolve(node_path_1.default.resolve(paths_1.default.appNodeModules, 'typescript'));
75
85
  }
76
86
  catch (err) {
77
87
  if (!err ||
@@ -1,10 +1,13 @@
1
- import { createTransformPathsToLocalModules } from './transformers';
2
- import { displayFilename, getTsProjectConfigPath, onHostEvent } from './utils';
3
- import { formatDiagnosticBrief } from './diagnostic';
4
- export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap, }) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.watch = watch;
4
+ const transformers_1 = require("./transformers");
5
+ const utils_1 = require("./utils");
6
+ const diagnostic_1 = require("./diagnostic");
7
+ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap, }) {
5
8
  logger.message('Start compilation in watch mode');
6
9
  logger.message(`Typescript v${ts.version}`);
7
- const configPath = getTsProjectConfigPath(ts, projectPath);
10
+ const configPath = (0, utils_1.getTsProjectConfigPath)(ts, projectPath);
8
11
  const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
9
12
  const host = ts.createWatchCompilerHost(configPath, {
10
13
  noEmit: false,
@@ -13,8 +16,8 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
13
16
  inlineSources: enableSourceMap,
14
17
  ...(enableSourceMap ? { sourceMap: false } : undefined),
15
18
  }, ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
16
- host.readFile = displayFilename(host.readFile, 'Reading', logger);
17
- onHostEvent(host, 'createProgram', () => {
19
+ host.readFile = (0, utils_1.displayFilename)(host.readFile, 'Reading', logger);
20
+ (0, utils_1.onHostEvent)(host, 'createProgram', () => {
18
21
  logger.verbose("We're about to create the program");
19
22
  // @ts-expect-error
20
23
  host.readFile.enableDisplay();
@@ -23,9 +26,9 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
23
26
  const count = host.readFile.disableDisplay();
24
27
  logger.verbose(`Program created, read ${count} files`);
25
28
  });
26
- onHostEvent(host, 'afterProgramCreate', (program) => {
29
+ (0, utils_1.onHostEvent)(host, 'afterProgramCreate', (program) => {
27
30
  logger.verbose('We finished making the program! Emitting...');
28
- const transformPathsToLocalModules = createTransformPathsToLocalModules(ts);
31
+ const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
29
32
  program.emit(undefined, undefined, undefined, undefined, {
30
33
  after: [transformPathsToLocalModules],
31
34
  afterDeclarations: [transformPathsToLocalModules],
@@ -47,7 +50,7 @@ export function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSour
47
50
  logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
48
51
  }
49
52
  else {
50
- logger.message(formatDiagnosticBrief(ts, diagnostic, formatHost));
53
+ logger.message((0, diagnostic_1.formatDiagnosticBrief)(ts, diagnostic, formatHost));
51
54
  }
52
55
  }
53
56
  /*
@@ -1,28 +1,39 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import paths from './paths';
5
- export function getAppRunPath(config) {
6
- return path.resolve(paths.appRun, config.client.moduleFederation?.name || '');
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.getAppRunPath = getAppRunPath;
7
+ exports.createRunFolder = createRunFolder;
8
+ exports.shouldCompileTarget = shouldCompileTarget;
9
+ exports.getCacheDir = getCacheDir;
10
+ exports.getPort = getPort;
11
+ exports.deferredPromise = deferredPromise;
12
+ const node_fs_1 = __importDefault(require("node:fs"));
13
+ const node_os_1 = __importDefault(require("node:os"));
14
+ const node_path_1 = __importDefault(require("node:path"));
15
+ const paths_1 = __importDefault(require("./paths"));
16
+ function getAppRunPath(config) {
17
+ return node_path_1.default.resolve(paths_1.default.appRun, config.client.moduleFederation?.name || '');
7
18
  }
8
- export function createRunFolder(config) {
19
+ function createRunFolder(config) {
9
20
  const appRunPath = getAppRunPath(config);
10
- if (!fs.existsSync(appRunPath)) {
11
- fs.mkdirSync(appRunPath, { recursive: true });
21
+ if (!node_fs_1.default.existsSync(appRunPath)) {
22
+ node_fs_1.default.mkdirSync(appRunPath, { recursive: true });
12
23
  }
13
24
  }
14
- export function shouldCompileTarget(target, targetName) {
25
+ function shouldCompileTarget(target, targetName) {
15
26
  return target === undefined || target === targetName;
16
27
  }
17
- export async function getCacheDir() {
28
+ async function getCacheDir() {
18
29
  const { default: findCacheDirectory } = await import('find-cache-dir');
19
- return findCacheDirectory({ name: '@gravity-ui/app-builder', create: true }) || os.tmpdir();
30
+ return findCacheDirectory({ name: '@gravity-ui/app-builder', create: true }) || node_os_1.default.tmpdir();
20
31
  }
21
- export async function getPort({ port }) {
32
+ async function getPort({ port }) {
22
33
  const { default: getPortDefault, portNumbers } = await import('get-port');
23
34
  return getPortDefault({ port: portNumbers(port, port + 100) });
24
35
  }
25
- export function deferredPromise() {
36
+ function deferredPromise() {
26
37
  let resolve;
27
38
  let reject;
28
39
  const promise = new Promise((res, rej) => {
@@ -1,23 +1,29 @@
1
- import webpack from 'webpack';
2
- import { rspack } from '@rspack/core';
3
- import { Logger } from '../logger';
4
- import { rspackConfigFactory, webpackConfigFactory } from './config';
5
- import { compilerHandlerFactory } from './utils';
6
- export async function clientCompile(config, configPath) {
7
- const logger = new Logger('client', config.verbose);
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.clientCompile = clientCompile;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const core_1 = require("@rspack/core");
9
+ const logger_1 = require("../logger");
10
+ const config_1 = require("./config");
11
+ const utils_1 = require("./utils");
12
+ async function clientCompile(config, configPath) {
13
+ const logger = new logger_1.Logger('client', config.verbose);
8
14
  const webpackConfigs = [];
9
15
  const rspackConfigs = [];
10
16
  const isSsr = Boolean(config.ssr);
11
17
  if (config.bundler === 'rspack') {
12
- rspackConfigs.push(await rspackConfigFactory({
18
+ rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
13
19
  webpackMode: "production" /* WebpackMode.Prod */,
14
20
  config,
15
21
  configPath,
16
22
  logger,
17
23
  }));
18
24
  if (isSsr) {
19
- const ssrLogger = new Logger('client(SSR)', config.verbose);
20
- rspackConfigs.push(await rspackConfigFactory({
25
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
26
+ rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
21
27
  webpackMode: "production" /* WebpackMode.Prod */,
22
28
  config,
23
29
  configPath,
@@ -27,15 +33,15 @@ export async function clientCompile(config, configPath) {
27
33
  }
28
34
  }
29
35
  else {
30
- webpackConfigs.push(await webpackConfigFactory({
36
+ webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
31
37
  webpackMode: "production" /* WebpackMode.Prod */,
32
38
  config,
33
39
  configPath,
34
40
  logger,
35
41
  }));
36
42
  if (isSsr) {
37
- const ssrLogger = new Logger('client(SSR)', config.verbose);
38
- webpackConfigs.push(await webpackConfigFactory({
43
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
44
+ webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
39
45
  webpackMode: "production" /* WebpackMode.Prod */,
40
46
  config,
41
47
  configPath,
@@ -46,12 +52,12 @@ export async function clientCompile(config, configPath) {
46
52
  }
47
53
  logger.verbose('Config created');
48
54
  return new Promise((resolve) => {
49
- const compilerHandler = compilerHandlerFactory(logger, async () => {
55
+ const compilerHandler = (0, utils_1.compilerHandlerFactory)(logger, async () => {
50
56
  resolve();
51
57
  });
52
58
  const compiler = config.bundler === 'rspack'
53
- ? rspack(rspackConfigs, compilerHandler)
54
- : webpack(webpackConfigs, compilerHandler);
59
+ ? (0, core_1.rspack)(rspackConfigs, compilerHandler)
60
+ : (0, webpack_1.default)(webpackConfigs, compilerHandler);
55
61
  process.on('SIGINT', async () => {
56
62
  compiler?.close(() => {
57
63
  process.exit(1);