@gravity-ui/app-builder 0.28.1-beta.9 → 0.29.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.
@@ -39,7 +39,6 @@ compile(ts, {logger, projectPath: ${JSON.stringify(paths_1.default.appServer)}})
39
39
  }
40
40
  function buildServer(config) {
41
41
  (0, utils_1.createRunFolder)();
42
- // Используем TypeScript для компиляции (по умолчанию)
43
42
  return new Promise((resolve, reject) => {
44
43
  const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
45
44
  ? createSWCBuildScript(config)
@@ -8,12 +8,12 @@ const utils_1 = require("./utils");
8
8
  async function compile({ projectPath, outputPath, logger }) {
9
9
  const start = process.hrtime.bigint();
10
10
  logger.message('Start compilation');
11
- const swcOptions = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
11
+ const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
12
12
  const cliOptions = {
13
- filenames: [projectPath],
13
+ filenames: directoriesToCompile,
14
14
  outDir: outputPath,
15
15
  watch: false,
16
- extensions: ['.js', '.ts', '.mjs', '.cjs'],
16
+ extensions: utils_1.EXTENSIONS_TO_COMPILE,
17
17
  stripLeadingPaths: true,
18
18
  sync: false,
19
19
  };
@@ -1 +1,5 @@
1
- export declare function getSwcOptionsFromTsconfig(projectPath: string, filename?: string): import("@swc/types").Options;
1
+ export declare const EXTENSIONS_TO_COMPILE: string[];
2
+ export declare function getSwcOptionsFromTsconfig(projectPath: string, filename?: string): {
3
+ swcOptions: import("@swc/types").Options;
4
+ directoriesToCompile: string[];
5
+ };
@@ -1,7 +1,35 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.EXTENSIONS_TO_COMPILE = void 0;
3
7
  exports.getSwcOptionsFromTsconfig = getSwcOptionsFromTsconfig;
8
+ const path_1 = __importDefault(require("path"));
4
9
  const tsconfig_to_swcconfig_1 = require("tsconfig-to-swcconfig");
10
+ exports.EXTENSIONS_TO_COMPILE = ['.js', '.ts', '.mts', '.mjs', '.cjs'];
11
+ function resolvePaths(paths, baseUrl) {
12
+ const entries = [];
13
+ for (const targets of Object.values(paths)) {
14
+ for (const target of targets) {
15
+ const resolvedPath = path_1.default.resolve(baseUrl, target.replace(/\*$/, ''));
16
+ entries.push(resolvedPath);
17
+ }
18
+ }
19
+ return entries;
20
+ }
5
21
  function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
6
- return (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
22
+ const swcOptions = (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
23
+ swcOptions.jsc = {
24
+ ...swcOptions.jsc,
25
+ // SWC requires absolute path as baseUrl
26
+ baseUrl: projectPath,
27
+ };
28
+ // SWC don't compile referenced files like tsc, so we need collect all directories to compile.
29
+ const paths = swcOptions.jsc.paths || {};
30
+ const directoriesToCompile = [projectPath, ...resolvePaths(paths, projectPath)];
31
+ return {
32
+ swcOptions,
33
+ directoriesToCompile,
34
+ };
7
35
  }
@@ -6,12 +6,12 @@ const cli_1 = require("@swc/cli");
6
6
  const utils_1 = require("./utils");
7
7
  async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
8
8
  logger.message('Start compilation in watch mode');
9
- const swcOptions = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
9
+ const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
10
10
  const cliOptions = {
11
- filenames: [projectPath],
11
+ filenames: directoriesToCompile,
12
12
  outDir: outputPath,
13
13
  watch: true,
14
- extensions: ['.js', '.ts', '.mjs', '.cjs'],
14
+ extensions: utils_1.EXTENSIONS_TO_COMPILE,
15
15
  stripLeadingPaths: true,
16
16
  sync: false,
17
17
  logWatchCompilation: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.28.1-beta.9",
3
+ "version": "0.29.1",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",