@gravity-ui/app-builder 0.29.3 → 0.30.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 (63) hide show
  1. package/README.md +138 -0
  2. package/dist/cli.js +17 -22
  3. package/dist/commands/build/build-lib.js +5 -8
  4. package/dist/commands/build/build-service/client.js +3 -6
  5. package/dist/commands/build/build-service/index.js +4 -7
  6. package/dist/commands/build/build-service/server.js +11 -17
  7. package/dist/commands/build/index.js +3 -6
  8. package/dist/commands/dev/client.js +34 -63
  9. package/dist/commands/dev/index.js +22 -50
  10. package/dist/commands/dev/server.js +13 -42
  11. package/dist/common/babel/index.js +1 -4
  12. package/dist/common/babel/ui-preset.d.ts +1 -1
  13. package/dist/common/babel/ui-preset.js +0 -1
  14. package/dist/common/child-process/controllable-script.js +5 -32
  15. package/dist/common/child-process/utils.js +4 -30
  16. package/dist/common/command.js +1 -2
  17. package/dist/common/config.js +36 -45
  18. package/dist/common/env.js +3 -5
  19. package/dist/common/library/babel-plugin-replace-paths.js +2 -4
  20. package/dist/common/library/index.js +66 -95
  21. package/dist/common/logger/colors.js +2 -8
  22. package/dist/common/logger/index.js +17 -24
  23. package/dist/common/logger/log-config.js +3 -6
  24. package/dist/common/logger/pretty-time.js +2 -6
  25. package/dist/common/models/index.d.ts +66 -1
  26. package/dist/common/models/index.js +3 -8
  27. package/dist/common/paths.js +3 -28
  28. package/dist/common/s3-upload/compress.js +8 -12
  29. package/dist/common/s3-upload/create-plugin.js +9 -7
  30. package/dist/common/s3-upload/index.js +3 -9
  31. package/dist/common/s3-upload/s3-client.js +11 -37
  32. package/dist/common/s3-upload/upload.js +9 -38
  33. package/dist/common/s3-upload/webpack-plugin.js +5 -9
  34. package/dist/common/swc/compile.js +9 -12
  35. package/dist/common/swc/index.js +2 -7
  36. package/dist/common/swc/utils.js +6 -13
  37. package/dist/common/swc/watch.js +6 -9
  38. package/dist/common/typescript/compile.js +11 -14
  39. package/dist/common/typescript/diagnostic.js +11 -37
  40. package/dist/common/typescript/transformers.js +3 -29
  41. package/dist/common/typescript/utils.js +8 -18
  42. package/dist/common/typescript/watch.js +10 -13
  43. package/dist/common/utils.d.ts +3 -1
  44. package/dist/common/utils.js +16 -22
  45. package/dist/common/webpack/compile.js +16 -22
  46. package/dist/common/webpack/config.d.ts +0 -2
  47. package/dist/common/webpack/config.js +187 -137
  48. package/dist/common/webpack/node-externals.js +5 -34
  49. package/dist/common/webpack/progress-plugin.js +3 -6
  50. package/dist/common/webpack/public-path.d.ts +0 -1
  51. package/dist/common/webpack/public-path.js +1 -1
  52. package/dist/common/webpack/rspack.js +1 -5
  53. package/dist/common/webpack/runtime-versioning-plugin.d.ts +5 -0
  54. package/dist/common/webpack/runtime-versioning-plugin.js +20 -0
  55. package/dist/common/webpack/storybook.js +21 -53
  56. package/dist/common/webpack/utils.js +9 -36
  57. package/dist/common/webpack/worker/public-path.worker.d.ts +0 -1
  58. package/dist/common/webpack/worker/public-path.worker.js +2 -1
  59. package/dist/common/webpack/worker/worker-loader.js +4 -34
  60. package/dist/create-cli.js +19 -48
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +5 -27
  63. package/package.json +4 -1
@@ -1,8 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createS3UploadPlugins = createS3UploadPlugins;
4
- const webpack_plugin_1 = require("./webpack-plugin");
5
- function createS3UploadPlugins(config, logger) {
1
+ import * as path from 'node:path';
2
+ import { S3UploadPlugin } from './webpack-plugin';
3
+ export function createS3UploadPlugins(config, logger) {
6
4
  const plugins = [];
7
5
  let credentialsGlobal;
8
6
  if (process.env.FRONTEND_S3_ACCESS_KEY_ID && process.env.FRONTEND_S3_SECRET_ACCESS_KEY) {
@@ -26,7 +24,11 @@ function createS3UploadPlugins(config, logger) {
26
24
  secretAccessKey,
27
25
  };
28
26
  }
29
- plugins.push(new webpack_plugin_1.S3UploadPlugin({
27
+ let targetPath = cdn.prefix;
28
+ if (config.moduleFederation && targetPath !== undefined) {
29
+ targetPath = path.join(targetPath, config.moduleFederation.name);
30
+ }
31
+ plugins.push(new S3UploadPlugin({
30
32
  exclude: config.hiddenSourceMap ? /\.map$/ : undefined,
31
33
  compress: cdn.compress,
32
34
  s3ClientOptions: {
@@ -36,7 +38,7 @@ function createS3UploadPlugins(config, logger) {
36
38
  },
37
39
  s3UploadOptions: {
38
40
  bucket: cdn.bucket,
39
- targetPath: cdn.prefix,
41
+ targetPath,
40
42
  cacheControl: cdn.cacheControl,
41
43
  },
42
44
  additionalPattern: cdn.additionalPattern,
@@ -1,9 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createS3UploadPlugins = exports.uploadFiles = exports.S3UploadPlugin = void 0;
4
- var webpack_plugin_1 = require("./webpack-plugin");
5
- Object.defineProperty(exports, "S3UploadPlugin", { enumerable: true, get: function () { return webpack_plugin_1.S3UploadPlugin; } });
6
- var upload_1 = require("./upload");
7
- Object.defineProperty(exports, "uploadFiles", { enumerable: true, get: function () { return upload_1.uploadFiles; } });
8
- var create_plugin_1 = require("./create-plugin");
9
- Object.defineProperty(exports, "createS3UploadPlugins", { enumerable: true, get: function () { return create_plugin_1.createS3UploadPlugins; } });
1
+ export { S3UploadPlugin } from './webpack-plugin';
2
+ export { uploadFiles } from './upload';
3
+ export { createS3UploadPlugins } from './create-plugin';
@@ -1,39 +1,13 @@
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.getS3Client = getS3Client;
27
- const fs = __importStar(require("fs/promises"));
28
- const path = __importStar(require("node:path"));
29
- const client_s3_1 = require("@aws-sdk/client-s3");
30
- const mime = __importStar(require("mime-types"));
31
- const fast_glob_1 = require("fast-glob");
32
- function getS3Client(options) {
33
- const s3Client = new client_s3_1.S3Client(options);
1
+ import * as fs from 'fs/promises';
2
+ import * as path from 'node:path';
3
+ import { DeleteObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client, } from '@aws-sdk/client-s3';
4
+ import * as mime from 'mime-types';
5
+ import { globSync } from 'fast-glob';
6
+ export function getS3Client(options) {
7
+ const s3Client = new S3Client(options);
34
8
  return {
35
9
  headObject(bucket, key) {
36
- return s3Client.send(new client_s3_1.HeadObjectCommand({ Bucket: bucket, Key: key }));
10
+ return s3Client.send(new HeadObjectCommand({ Bucket: bucket, Key: key }));
37
11
  },
38
12
  async uploadFile(bucket, localFileOrPath, key, opts = {}) {
39
13
  const isBuffer = Buffer.isBuffer(localFileOrPath);
@@ -62,10 +36,10 @@ function getS3Client(options) {
62
36
  if (opts.cacheControl) {
63
37
  params.CacheControl = opts.cacheControl;
64
38
  }
65
- return s3Client.send(new client_s3_1.PutObjectCommand(params));
39
+ return s3Client.send(new PutObjectCommand(params));
66
40
  },
67
41
  async uploadDir(bucket, dirPath, keyPrefix = '', { concurrency = 512, ...opts } = {}) {
68
- const files = (0, fast_glob_1.globSync)('**', { cwd: dirPath });
42
+ const files = globSync('**', { cwd: dirPath });
69
43
  const { default: pMap } = await import('p-map');
70
44
  return pMap(files, (filePath) => {
71
45
  const sourcePath = path.join(dirPath, filePath);
@@ -73,7 +47,7 @@ function getS3Client(options) {
73
47
  }, { concurrency });
74
48
  },
75
49
  deleteObject(bucket, key) {
76
- return s3Client.send(new client_s3_1.DeleteObjectCommand({ Bucket: bucket, Key: key }));
50
+ return s3Client.send(new DeleteObjectCommand({ Bucket: bucket, Key: key }));
77
51
  },
78
52
  };
79
53
  }
@@ -1,39 +1,10 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.uploadFiles = uploadFiles;
30
- const path = __importStar(require("node:path"));
31
- const index_js_1 = __importDefault(require("../logger/index.js"));
32
- const s3_client_js_1 = require("./s3-client.js");
33
- const compress_js_1 = require("./compress.js");
34
- async function uploadFiles(files, config) {
35
- const s3Client = (0, s3_client_js_1.getS3Client)(config.s3);
36
- const log = config.logger ?? index_js_1.default;
1
+ import * as path from 'node:path';
2
+ import logger from '../logger/index.js';
3
+ import { getS3Client } from './s3-client.js';
4
+ import { brotli, gzip } from './compress.js';
5
+ export async function uploadFiles(files, config) {
6
+ const s3Client = getS3Client(config.s3);
7
+ const log = config.logger ?? logger;
37
8
  const { default: PQueue } = await import('p-queue');
38
9
  const queue = new PQueue({
39
10
  concurrency: config.concurrency ?? 512,
@@ -97,8 +68,8 @@ async function uploadFiles(files, config) {
97
68
  function compress(sourcePath) {
98
69
  // throwOnTimeout is only used to get the correct type and does not change behavior since we are not setting a timeout.
99
70
  return [
100
- queue.add(() => (0, compress_js_1.gzip)(sourcePath), { throwOnTimeout: true }),
101
- queue.add(() => (0, compress_js_1.brotli)(sourcePath), { throwOnTimeout: true }),
71
+ queue.add(() => gzip(sourcePath), { throwOnTimeout: true }),
72
+ queue.add(() => brotli(sourcePath), { throwOnTimeout: true }),
102
73
  ];
103
74
  }
104
75
  function fileProcessor(options) {
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.S3UploadPlugin = void 0;
4
- const fast_glob_1 = require("fast-glob");
5
- const upload_js_1 = require("./upload.js");
6
- class S3UploadPlugin {
1
+ import { globSync } from 'fast-glob';
2
+ import { uploadFiles } from './upload.js';
3
+ export class S3UploadPlugin {
7
4
  options;
8
5
  constructor(options) {
9
6
  this.options = options;
@@ -16,7 +13,7 @@ class S3UploadPlugin {
16
13
  }
17
14
  let fileNames = Object.keys(stats.compilation.assets);
18
15
  if (this.options.additionalPattern) {
19
- const additionalFiles = (0, fast_glob_1.globSync)(this.options.additionalPattern, {
16
+ const additionalFiles = globSync(this.options.additionalPattern, {
20
17
  cwd: stats.compilation.outputOptions.path,
21
18
  });
22
19
  fileNames = fileNames.concat(additionalFiles);
@@ -26,7 +23,7 @@ class S3UploadPlugin {
26
23
  return this.isIncludeAndNotExclude(fullPath);
27
24
  });
28
25
  try {
29
- await (0, upload_js_1.uploadFiles)(fileNames, {
26
+ await uploadFiles(fileNames, {
30
27
  s3: this.options.s3ClientOptions,
31
28
  compress: this.options.compress,
32
29
  options: {
@@ -50,7 +47,6 @@ class S3UploadPlugin {
50
47
  return isInclude && !isExclude;
51
48
  }
52
49
  }
53
- exports.S3UploadPlugin = S3UploadPlugin;
54
50
  function testRule(rule, source) {
55
51
  if (rule instanceof RegExp) {
56
52
  return rule.test(source);
@@ -1,26 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = compile;
4
- const pretty_time_1 = require("../logger/pretty-time");
1
+ import { elapsedTime } from '../logger/pretty-time';
5
2
  // @ts-ignore @swc/cli is not typed
6
- const cli_1 = require("@swc/cli");
7
- const utils_1 = require("./utils");
8
- async function compile({ projectPath, outputPath, logger }) {
3
+ import { swcDir } from '@swc/cli';
4
+ import { EXTENSIONS_TO_COMPILE, getSwcOptionsFromTsconfig } from './utils';
5
+ export async function compile({ projectPath, outputPath, logger }) {
9
6
  const start = process.hrtime.bigint();
10
7
  logger.message('Start compilation');
11
- const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
8
+ const { swcOptions, directoriesToCompile } = getSwcOptionsFromTsconfig(projectPath);
12
9
  const cliOptions = {
13
10
  filenames: directoriesToCompile,
14
11
  outDir: outputPath,
15
12
  watch: false,
16
- extensions: utils_1.EXTENSIONS_TO_COMPILE,
13
+ extensions: EXTENSIONS_TO_COMPILE,
17
14
  stripLeadingPaths: true,
18
15
  sync: false,
19
16
  };
20
17
  return new Promise((resolve, reject) => {
21
18
  const callbacks = {
22
19
  onSuccess: (_result) => {
23
- logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
20
+ logger.success(`Compiled successfully in ${elapsedTime(start)}`);
24
21
  resolve();
25
22
  },
26
23
  onFail: (result) => {
@@ -30,12 +27,12 @@ async function compile({ projectPath, outputPath, logger }) {
30
27
  logger.error(`${filename}: ${error}`);
31
28
  }
32
29
  }
33
- logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
30
+ logger.error(`Error compile, elapsed time ${elapsedTime(start)}`);
34
31
  reject(new Error('Compilation failed'));
35
32
  },
36
33
  };
37
34
  try {
38
- (0, cli_1.swcDir)({
35
+ swcDir({
39
36
  cliOptions,
40
37
  swcOptions,
41
38
  callbacks,
@@ -1,7 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watch = exports.compile = void 0;
4
- var compile_1 = require("./compile");
5
- Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
6
- var watch_1 = require("./watch");
7
- Object.defineProperty(exports, "watch", { enumerable: true, get: function () { return watch_1.watch; } });
1
+ export { compile } from './compile';
2
+ export { watch } from './watch';
@@ -1,25 +1,18 @@
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.EXTENSIONS_TO_COMPILE = void 0;
7
- exports.getSwcOptionsFromTsconfig = getSwcOptionsFromTsconfig;
8
- const path_1 = __importDefault(require("path"));
9
- const tsconfig_to_swcconfig_1 = require("tsconfig-to-swcconfig");
10
- exports.EXTENSIONS_TO_COMPILE = ['.js', '.ts', '.mts', '.mjs', '.cjs'];
1
+ import path from 'path';
2
+ import { convert } from 'tsconfig-to-swcconfig';
3
+ export const EXTENSIONS_TO_COMPILE = ['.js', '.ts', '.mts', '.mjs', '.cjs'];
11
4
  function resolvePaths(paths, baseUrl) {
12
5
  const entries = [];
13
6
  for (const targets of Object.values(paths)) {
14
7
  for (const target of targets) {
15
- const resolvedPath = path_1.default.resolve(baseUrl, target.replace(/\*$/, ''));
8
+ const resolvedPath = path.resolve(baseUrl, target.replace(/\*$/, ''));
16
9
  entries.push(resolvedPath);
17
10
  }
18
11
  }
19
12
  return entries;
20
13
  }
21
- function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
22
- const swcOptions = (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
14
+ export function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
15
+ const swcOptions = convert(filename, projectPath);
23
16
  swcOptions.jsc = {
24
17
  ...swcOptions.jsc,
25
18
  // SWC requires absolute path as baseUrl
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.watch = watch;
4
1
  // @ts-ignore @swc/cli is not typed
5
- const cli_1 = require("@swc/cli");
6
- const utils_1 = require("./utils");
7
- async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
2
+ import { swcDir } from '@swc/cli';
3
+ import { EXTENSIONS_TO_COMPILE, getSwcOptionsFromTsconfig } from './utils';
4
+ export async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
8
5
  logger.message('Start compilation in watch mode');
9
- const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
6
+ const { swcOptions, directoriesToCompile } = getSwcOptionsFromTsconfig(projectPath);
10
7
  const cliOptions = {
11
8
  filenames: directoriesToCompile,
12
9
  outDir: outputPath,
13
10
  watch: true,
14
- extensions: utils_1.EXTENSIONS_TO_COMPILE,
11
+ extensions: EXTENSIONS_TO_COMPILE,
15
12
  stripLeadingPaths: true,
16
13
  sync: false,
17
14
  logWatchCompilation: true,
@@ -38,7 +35,7 @@ async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
38
35
  logger.message('Watching for file changes');
39
36
  },
40
37
  };
41
- (0, cli_1.swcDir)({
38
+ swcDir({
42
39
  cliOptions,
43
40
  swcOptions,
44
41
  callbacks,
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compile = compile;
4
- const utils_1 = require("./utils");
5
- const transformers_1 = require("./transformers");
6
- const pretty_time_1 = require("../logger/pretty-time");
7
- const diagnostic_1 = require("./diagnostic");
8
- function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToExtend, logger }) {
1
+ import { displayFilename, getTsProjectConfig } from './utils';
2
+ import { createTransformPathsToLocalModules } from './transformers';
3
+ import { elapsedTime } from '../logger/pretty-time';
4
+ import { formatDiagnosticBrief } from './diagnostic';
5
+ export function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToExtend, logger }) {
9
6
  const start = process.hrtime.bigint();
10
7
  logger.message('Start compilation');
11
8
  logger.message(`Typescript v${ts.version}`);
12
9
  logger.verbose(`Searching for the ${configFileName} in ${projectPath}`);
13
- const parsedConfig = (0, utils_1.getTsProjectConfig)(ts, projectPath, configFileName, {
10
+ const parsedConfig = getTsProjectConfig(ts, projectPath, configFileName, {
14
11
  noEmit: false,
15
12
  noEmitOnError: true,
16
13
  ...optionsToExtend,
@@ -18,7 +15,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
18
15
  logger.verbose('Config found and parsed');
19
16
  logger.verbose("We're about to create the program");
20
17
  const compilerHost = ts.createCompilerHost(parsedConfig.options);
21
- compilerHost.readFile = (0, utils_1.displayFilename)(compilerHost.readFile, 'Reading', logger);
18
+ compilerHost.readFile = displayFilename(compilerHost.readFile, 'Reading', logger);
22
19
  // @ts-expect-error
23
20
  compilerHost.readFile.enableDisplay();
24
21
  const program = ts.createProgram(parsedConfig.fileNames, parsedConfig.options, compilerHost);
@@ -28,7 +25,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
28
25
  logger.verbose(`Program created, read ${filesCount} files`);
29
26
  if (!hasErrors(allDiagnostics)) {
30
27
  logger.verbose('We finished making the program! Emitting...');
31
- const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
28
+ const transformPathsToLocalModules = createTransformPathsToLocalModules(ts);
32
29
  const emitResult = program.emit(undefined, undefined, undefined, undefined, {
33
30
  after: [transformPathsToLocalModules],
34
31
  afterDeclarations: [transformPathsToLocalModules],
@@ -38,11 +35,11 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
38
35
  }
39
36
  allDiagnostics.forEach(reportDiagnostic);
40
37
  if (hasErrors(allDiagnostics)) {
41
- logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
38
+ logger.error(`Error compile, elapsed time ${elapsedTime(start)}`);
42
39
  process.exit(1);
43
40
  }
44
41
  else {
45
- logger.success(`Compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
42
+ logger.success(`Compiled successfully in ${elapsedTime(start)}`);
46
43
  }
47
44
  function reportDiagnostic(diagnostic) {
48
45
  const formatHost = {
@@ -54,7 +51,7 @@ function compile(ts, { projectPath, configFileName = 'tsconfig.json', optionsToE
54
51
  logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
55
52
  }
56
53
  else {
57
- logger.message((0, diagnostic_1.formatDiagnosticBrief)(ts, diagnostic, formatHost));
54
+ logger.message(formatDiagnosticBrief(ts, diagnostic, formatHost));
58
55
  }
59
56
  }
60
57
  function hasErrors(diagnostics) {
@@ -1,32 +1,6 @@
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) {
1
+ import * as path from 'node:path';
2
+ import { colors } from '../logger/colors';
3
+ export function formatDiagnosticBrief(ts, diagnostic, host) {
30
4
  let output = '';
31
5
  if (diagnostic.file) {
32
6
  const { file, start } = diagnostic;
@@ -34,31 +8,31 @@ function formatDiagnosticBrief(ts, diagnostic, host) {
34
8
  output += ' - ';
35
9
  }
36
10
  output += categoryColor(diagnostic.category)(ts.DiagnosticCategory[diagnostic.category]);
37
- output += colors_1.colors.grey(` TS${diagnostic.code}: `);
11
+ output += colors.grey(` TS${diagnostic.code}: `);
38
12
  output += ts.flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
39
13
  return output;
40
14
  function formatLocation(file, start) {
41
15
  const { line, character } = ts.getLineAndCharacterOfPosition(file, start);
42
16
  const filePath = path.relative(process.cwd(), file.fileName);
43
- return (colors_1.colors.cyanBright(filePath) +
17
+ return (colors.cyanBright(filePath) +
44
18
  ':' +
45
- colors_1.colors.yellowBright(line + 1) +
19
+ colors.yellowBright(line + 1) +
46
20
  ':' +
47
- colors_1.colors.yellowBright(character + 1));
21
+ colors.yellowBright(character + 1));
48
22
  }
49
23
  function categoryColor(category) {
50
24
  switch (category) {
51
25
  case ts.DiagnosticCategory.Error: {
52
- return colors_1.colors.redBright;
26
+ return colors.redBright;
53
27
  }
54
28
  case ts.DiagnosticCategory.Warning: {
55
- return colors_1.colors.yellowBright;
29
+ return colors.yellowBright;
56
30
  }
57
31
  case ts.DiagnosticCategory.Suggestion: {
58
- return colors_1.colors.magentaBright;
32
+ return colors.magentaBright;
59
33
  }
60
34
  default: {
61
- return colors_1.colors;
35
+ return colors;
62
36
  }
63
37
  }
64
38
  }
@@ -1,32 +1,6 @@
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) {
1
+ import * as path from 'node:path';
2
+ import * as semver from 'semver';
3
+ export function createTransformPathsToLocalModules(ts) {
30
4
  function resolveModule(module, sourceFileName, options) {
31
5
  if (module.startsWith('.')) {
32
6
  return undefined;
@@ -1,23 +1,13 @@
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') {
1
+ import path from 'node:path';
2
+ import paths from '../paths';
3
+ export function getTsProjectConfigPath(ts, projectPath, filename = 'tsconfig.json') {
14
4
  const configPath = ts.findConfigFile(projectPath, ts.sys.fileExists, filename);
15
5
  if (!configPath) {
16
6
  throw new Error(`Could not find a valid '${filename}'.`);
17
7
  }
18
8
  return configPath;
19
9
  }
20
- function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
10
+ export function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', optionsToExtend) {
21
11
  const configPath = getTsProjectConfigPath(ts, projectPath, filename);
22
12
  const parseConfigFileHost = {
23
13
  getCurrentDirectory: ts.sys.getCurrentDirectory,
@@ -34,7 +24,7 @@ function getTsProjectConfig(ts, projectPath, filename = 'tsconfig.json', options
34
24
  }
35
25
  return parsedConfig;
36
26
  }
37
- function displayFilename(originalFunc, operationName, logger) {
27
+ export function displayFilename(originalFunc, operationName, logger) {
38
28
  let displayEnabled = false;
39
29
  let count = 0;
40
30
  function displayFunction(...args) {
@@ -62,7 +52,7 @@ function displayFilename(originalFunc, operationName, logger) {
62
52
  return displayFunction;
63
53
  }
64
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- function onHostEvent(host, functionName, before, after) {
55
+ export function onHostEvent(host, functionName, before, after) {
66
56
  const originalFunction = host[functionName];
67
57
  // eslint-disable-next-line no-param-reassign
68
58
  host[functionName] = ((...args) => {
@@ -79,9 +69,9 @@ function onHostEvent(host, functionName, before, after) {
79
69
  return result;
80
70
  });
81
71
  }
82
- function resolveTypescript() {
72
+ export function resolveTypescript() {
83
73
  try {
84
- return require.resolve(node_path_1.default.resolve(paths_1.default.appNodeModules, 'typescript'));
74
+ return require.resolve(path.resolve(paths.appNodeModules, 'typescript'));
85
75
  }
86
76
  catch (err) {
87
77
  if (!err ||
@@ -1,13 +1,10 @@
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, }) {
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, }) {
8
5
  logger.message('Start compilation in watch mode');
9
6
  logger.message(`Typescript v${ts.version}`);
10
- const configPath = (0, utils_1.getTsProjectConfigPath)(ts, projectPath);
7
+ const configPath = getTsProjectConfigPath(ts, projectPath);
11
8
  const createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
12
9
  const host = ts.createWatchCompilerHost(configPath, {
13
10
  noEmit: false,
@@ -16,8 +13,8 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
16
13
  inlineSources: enableSourceMap,
17
14
  ...(enableSourceMap ? { sourceMap: false } : undefined),
18
15
  }, ts.sys, createProgram, reportDiagnostic, reportWatchStatusChanged);
19
- host.readFile = (0, utils_1.displayFilename)(host.readFile, 'Reading', logger);
20
- (0, utils_1.onHostEvent)(host, 'createProgram', () => {
16
+ host.readFile = displayFilename(host.readFile, 'Reading', logger);
17
+ onHostEvent(host, 'createProgram', () => {
21
18
  logger.verbose("We're about to create the program");
22
19
  // @ts-expect-error
23
20
  host.readFile.enableDisplay();
@@ -26,9 +23,9 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
26
23
  const count = host.readFile.disableDisplay();
27
24
  logger.verbose(`Program created, read ${count} files`);
28
25
  });
29
- (0, utils_1.onHostEvent)(host, 'afterProgramCreate', (program) => {
26
+ onHostEvent(host, 'afterProgramCreate', (program) => {
30
27
  logger.verbose('We finished making the program! Emitting...');
31
- const transformPathsToLocalModules = (0, transformers_1.createTransformPathsToLocalModules)(ts);
28
+ const transformPathsToLocalModules = createTransformPathsToLocalModules(ts);
32
29
  program.emit(undefined, undefined, undefined, undefined, {
33
30
  after: [transformPathsToLocalModules],
34
31
  afterDeclarations: [transformPathsToLocalModules],
@@ -50,7 +47,7 @@ function watch(ts, projectPath, { logger, onAfterFilesEmitted, enableSourceMap,
50
47
  logger.message(ts.formatDiagnosticsWithColorAndContext([diagnostic], formatHost));
51
48
  }
52
49
  else {
53
- logger.message((0, diagnostic_1.formatDiagnosticBrief)(ts, diagnostic, formatHost));
50
+ logger.message(formatDiagnosticBrief(ts, diagnostic, formatHost));
54
51
  }
55
52
  }
56
53
  /*
@@ -1,4 +1,6 @@
1
- export declare function createRunFolder(): void;
1
+ import type { NormalizedServiceConfig } from './models';
2
+ export declare function getAppRunPath(config: NormalizedServiceConfig): string;
3
+ export declare function createRunFolder(config: NormalizedServiceConfig): void;
2
4
  export declare function shouldCompileTarget(target: 'client' | 'server' | undefined, targetName: string): boolean;
3
5
  export declare function getCacheDir(): Promise<string>;
4
6
  export declare function getPort({ port }: {