@gravity-ui/app-builder 0.28.1-beta.7 → 0.28.1-beta.9

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.
@@ -10,21 +10,11 @@ const paths_1 = __importDefault(require("../../../common/paths"));
10
10
  const utils_1 = require("../../../common/utils");
11
11
  function createSWCBuildScript(config) {
12
12
  return `
13
- let swcCli;
14
- try {
15
- swcCli = require('@swc/cli');
16
- } catch (e) {
17
- if (e.code !== 'MODULE_NOT_FOUND') {
18
- throw e;
19
- }
20
- swcCli = require(${JSON.stringify(require.resolve('@swc/cli'))});
21
- }
22
- const {swcDir} = swcCli;
23
13
  const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logger'))});
24
14
  const {compile} = require(${JSON.stringify(require.resolve('../../../common/swc/compile'))});
25
15
 
26
16
  const logger = new Logger('server', ${config.verbose});
27
- compile(swcDir, {
17
+ compile({
28
18
  logger,
29
19
  outputPath: ${JSON.stringify(paths_1.default.appDist)},
30
20
  projectPath: ${JSON.stringify(paths_1.default.appServer)},
@@ -61,22 +61,11 @@ watch(
61
61
  }
62
62
  function createSWCBuildScript(config) {
63
63
  return `
64
- let swcCli;
65
- try {
66
- swcCli = require('@swc/cli');
67
- } catch (e) {
68
- if (e.code !== 'MODULE_NOT_FOUND') {
69
- throw e;
70
- }
71
- swcCli = require(${JSON.stringify(require.resolve('@swc/cli'))});
72
- }
73
- const {swcDir} = swcCli;
74
64
  const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
75
65
  const {watch} = require(${JSON.stringify(require.resolve('../../common/swc/watch'))});
76
66
 
77
67
  const logger = new Logger('server', ${config.verbose});
78
68
  watch(
79
- swcDir,
80
69
  ${JSON.stringify(paths_1.default.appServer)},
81
70
  {
82
71
  outputPath: ${JSON.stringify(paths_1.default.appDist)},
@@ -84,7 +73,6 @@ watch(
84
73
  onAfterFilesEmitted: () => {
85
74
  process.send({type: 'Emitted'});
86
75
  },
87
- enableSourceMap: true
88
76
  }
89
77
  );`;
90
78
  }
@@ -3,7 +3,6 @@ interface SwcCompileOptions {
3
3
  projectPath: string;
4
4
  outputPath: string;
5
5
  logger: Logger;
6
- enableSourceMap?: boolean;
7
6
  }
8
- export declare function compile(swcDir: any, { projectPath, outputPath, logger, enableSourceMap }: SwcCompileOptions): Promise<void>;
7
+ export declare function compile({ projectPath, outputPath, logger }: SwcCompileOptions): Promise<void>;
9
8
  export {};
@@ -2,31 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compile = compile;
4
4
  const pretty_time_1 = require("../logger/pretty-time");
5
- const getSwcConfig = (enableSourceMap = false) => {
6
- return {
7
- module: {
8
- type: 'commonjs',
9
- },
10
- jsc: {
11
- target: 'es2020',
12
- parser: {
13
- syntax: 'typescript',
14
- },
15
- },
16
- sourceMaps: enableSourceMap,
17
- };
18
- };
19
- async function compile(
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- swcDir, { projectPath, outputPath, logger, enableSourceMap = false }) {
5
+ // @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 }) {
22
9
  const start = process.hrtime.bigint();
23
10
  logger.message('Start compilation');
24
- const swcConfig = getSwcConfig(enableSourceMap);
11
+ const swcOptions = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
25
12
  const cliOptions = {
26
13
  filenames: [projectPath],
27
14
  outDir: outputPath,
28
15
  watch: false,
29
- sourceMaps: enableSourceMap,
30
16
  extensions: ['.js', '.ts', '.mjs', '.cjs'],
31
17
  stripLeadingPaths: true,
32
18
  sync: false,
@@ -49,9 +35,9 @@ swcDir, { projectPath, outputPath, logger, enableSourceMap = false }) {
49
35
  },
50
36
  };
51
37
  try {
52
- swcDir({
38
+ (0, cli_1.swcDir)({
53
39
  cliOptions,
54
- swcOptions: swcConfig,
40
+ swcOptions,
55
41
  callbacks,
56
42
  });
57
43
  }
@@ -0,0 +1 @@
1
+ export declare function getSwcOptionsFromTsconfig(projectPath: string, filename?: string): import("@swc/types").Options;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSwcOptionsFromTsconfig = getSwcOptionsFromTsconfig;
4
+ const tsconfig_to_swcconfig_1 = require("tsconfig-to-swcconfig");
5
+ function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
6
+ return (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
7
+ }
@@ -3,7 +3,6 @@ interface SwcWatchOptions {
3
3
  outputPath: string;
4
4
  logger: Logger;
5
5
  onAfterFilesEmitted?: () => void;
6
- enableSourceMap?: boolean;
7
6
  }
8
- export declare function watch(swcDir: any, projectPath: string, { outputPath, logger, onAfterFilesEmitted, enableSourceMap }: SwcWatchOptions): Promise<void>;
7
+ export declare function watch(projectPath: string, { outputPath, logger, onAfterFilesEmitted }: SwcWatchOptions): Promise<void>;
9
8
  export {};
@@ -1,30 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watch = watch;
4
- const getSwcConfig = (enableSourceMap = false) => {
5
- return {
6
- module: {
7
- type: 'commonjs',
8
- },
9
- jsc: {
10
- target: 'es2020',
11
- parser: {
12
- syntax: 'typescript',
13
- },
14
- },
15
- sourceMaps: enableSourceMap,
16
- };
17
- };
18
- async function watch(
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- swcDir, projectPath, { outputPath, logger, onAfterFilesEmitted, enableSourceMap = false }) {
4
+ // @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 }) {
21
8
  logger.message('Start compilation in watch mode');
22
- const swcConfig = getSwcConfig(enableSourceMap);
9
+ const swcOptions = (0, utils_1.getSwcOptionsFromTsconfig)(projectPath);
23
10
  const cliOptions = {
24
11
  filenames: [projectPath],
25
12
  outDir: outputPath,
26
13
  watch: true,
27
- sourceMaps: enableSourceMap,
28
14
  extensions: ['.js', '.ts', '.mjs', '.cjs'],
29
15
  stripLeadingPaths: true,
30
16
  sync: false,
@@ -52,9 +38,9 @@ swcDir, projectPath, { outputPath, logger, onAfterFilesEmitted, enableSourceMap
52
38
  logger.message('Watching for file changes');
53
39
  },
54
40
  };
55
- swcDir({
41
+ (0, cli_1.swcDir)({
56
42
  cliOptions,
57
- swcOptions: swcConfig,
43
+ swcOptions,
58
44
  callbacks,
59
45
  });
60
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.28.1-beta.7",
3
+ "version": "0.28.1-beta.9",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -82,7 +82,7 @@
82
82
  "@svgr/core": "^8.1.0",
83
83
  "@svgr/plugin-jsx": "^8.1.0",
84
84
  "@svgr/webpack": "^8.1.0",
85
- "@swc/cli": "^0.7.8",
85
+ "@swc/cli": "0.7.7",
86
86
  "@swc/core": "1.11.24",
87
87
  "@swc/plugin-transform-imports": "7.0.3",
88
88
  "babel-loader": "^9.2.1",
@@ -136,6 +136,7 @@
136
136
  "terser-webpack-plugin": "5.3.10",
137
137
  "ts-checker-rspack-plugin": "^1.1.1",
138
138
  "ts-node": "10.9.2",
139
+ "tsconfig-to-swcconfig": "^2.8.1",
139
140
  "tslib": "^2.6.2",
140
141
  "typescript": "~5.6.0",
141
142
  "webpack": "^5.95.0",