@gravity-ui/app-builder 0.28.1-beta.5 → 0.28.1-beta.6
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.
- package/README.md +0 -2
- package/dist/commands/build/build-service/server.js +0 -40
- package/dist/commands/dev/server.js +26 -58
- package/dist/common/config.js +0 -1
- package/dist/common/models/index.d.ts +1 -8
- package/package.json +2 -3
- package/dist/common/swc/compile.d.ts +0 -9
- package/dist/common/swc/compile.js +0 -73
- package/dist/common/swc/index.d.ts +0 -2
- package/dist/common/swc/index.js +0 -7
- package/dist/common/swc/watch.d.ts +0 -10
- package/dist/common/swc/watch.js +0 -68
package/README.md
CHANGED
|
@@ -143,8 +143,6 @@ All server settings are used only in dev mode:
|
|
|
143
143
|
- `watchThrottle` (`number`) — use to add an extra throttle, or delay restarting.
|
|
144
144
|
- `inspect/inspectBrk` (`number | true`) — listen for a debugging client on specified port.
|
|
145
145
|
If specified `true`, try to listen on `9229`.
|
|
146
|
-
- `compiler` (`'typescript' | 'swc'`) — choose TypeScript compiler for server code compilation.
|
|
147
|
-
Default is `'typescript'`. Set to `'swc'` for faster compilation with SWC.
|
|
148
146
|
|
|
149
147
|
### Client
|
|
150
148
|
|
|
@@ -1,55 +1,15 @@
|
|
|
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
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.buildServer = buildServer;
|
|
30
|
-
const path = __importStar(require("node:path"));
|
|
31
7
|
const signal_exit_1 = require("signal-exit");
|
|
32
8
|
const controllable_script_1 = require("../../../common/child-process/controllable-script");
|
|
33
|
-
const logger_1 = require("../../../common/logger");
|
|
34
9
|
const paths_1 = __importDefault(require("../../../common/paths"));
|
|
35
10
|
const utils_1 = require("../../../common/utils");
|
|
36
|
-
const swc = __importStar(require("../../../common/swc"));
|
|
37
11
|
function buildServer(config) {
|
|
38
12
|
(0, utils_1.createRunFolder)();
|
|
39
|
-
if (config.server.compiler === 'swc') {
|
|
40
|
-
// Используем SWC для компиляции
|
|
41
|
-
return new Promise((resolve, reject) => {
|
|
42
|
-
const logger = new logger_1.Logger('server', config.verbose);
|
|
43
|
-
const serverPath = path.resolve(paths_1.default.appDist, 'server');
|
|
44
|
-
swc.compile({
|
|
45
|
-
projectPath: paths_1.default.appServer,
|
|
46
|
-
outputPath: serverPath,
|
|
47
|
-
logger,
|
|
48
|
-
enableSourceMap: false,
|
|
49
|
-
}).then(() => resolve(), (error) => reject(new Error(`SWC compilation failed: ${error}`)));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Используем TypeScript для компиляции (по умолчанию)
|
|
53
13
|
return new Promise((resolve, reject) => {
|
|
54
14
|
const build = new controllable_script_1.ControllableScript(`
|
|
55
15
|
let ts;
|
|
@@ -32,68 +32,36 @@ const rimraf_1 = require("rimraf");
|
|
|
32
32
|
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
33
33
|
const utils_1 = require("../../common/utils");
|
|
34
34
|
const paths_1 = __importDefault(require("../../common/paths"));
|
|
35
|
-
function createTypescriptBuildScript(config) {
|
|
36
|
-
return `
|
|
37
|
-
let ts;
|
|
38
|
-
try {
|
|
39
|
-
ts = require('typescript');
|
|
40
|
-
} catch (e) {
|
|
41
|
-
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
ts = require(${JSON.stringify(require.resolve('typescript'))});
|
|
45
|
-
}
|
|
46
|
-
const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
|
|
47
|
-
const {watch} = require(${JSON.stringify(require.resolve('../../common/typescript/watch'))});
|
|
48
|
-
|
|
49
|
-
const logger = new Logger('server', ${config.verbose});
|
|
50
|
-
watch(
|
|
51
|
-
ts,
|
|
52
|
-
${JSON.stringify(paths_1.default.appServer)},
|
|
53
|
-
{
|
|
54
|
-
logger,
|
|
55
|
-
onAfterFilesEmitted: () => {
|
|
56
|
-
process.send({type: 'Emitted'});
|
|
57
|
-
},
|
|
58
|
-
enableSourceMap: true
|
|
59
|
-
}
|
|
60
|
-
);`;
|
|
61
|
-
}
|
|
62
|
-
function createSWCBuildScript(config) {
|
|
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
|
-
const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
|
|
75
|
-
const {watch} = require(${JSON.stringify(require.resolve('../../common/swc/watch'))});
|
|
76
|
-
|
|
77
|
-
const logger = new Logger('server', ${config.verbose});
|
|
78
|
-
watch(
|
|
79
|
-
swcDir,
|
|
80
|
-
${JSON.stringify(paths_1.default.appServer)},
|
|
81
|
-
{
|
|
82
|
-
logger,
|
|
83
|
-
onAfterFilesEmitted: () => {
|
|
84
|
-
process.send({type: 'Emitted'});
|
|
85
|
-
},
|
|
86
|
-
enableSourceMap: true
|
|
87
|
-
}
|
|
88
|
-
);`;
|
|
89
|
-
}
|
|
90
35
|
async function watchServerCompilation(config) {
|
|
91
36
|
const serverPath = path.resolve(paths_1.default.appDist, 'server');
|
|
92
37
|
rimraf_1.rimraf.sync(serverPath);
|
|
93
38
|
(0, utils_1.createRunFolder)();
|
|
94
|
-
const build = new controllable_script_1.ControllableScript(
|
|
95
|
-
|
|
96
|
-
|
|
39
|
+
const build = new controllable_script_1.ControllableScript(`
|
|
40
|
+
let ts;
|
|
41
|
+
try {
|
|
42
|
+
ts = require('typescript');
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
ts = require(${JSON.stringify(require.resolve('typescript'))});
|
|
48
|
+
}
|
|
49
|
+
const {Logger} = require(${JSON.stringify(require.resolve('../../common/logger'))});
|
|
50
|
+
const {watch} = require(${JSON.stringify(require.resolve('../../common/typescript/watch'))});
|
|
51
|
+
|
|
52
|
+
const logger = new Logger('server', ${config.verbose});
|
|
53
|
+
watch(
|
|
54
|
+
ts,
|
|
55
|
+
${JSON.stringify(paths_1.default.appServer)},
|
|
56
|
+
{
|
|
57
|
+
logger,
|
|
58
|
+
onAfterFilesEmitted: () => {
|
|
59
|
+
process.send({type: 'Emitted'});
|
|
60
|
+
},
|
|
61
|
+
enableSourceMap: true
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
`, null);
|
|
97
65
|
await build.start();
|
|
98
66
|
return build;
|
|
99
67
|
}
|
package/dist/common/config.js
CHANGED
|
@@ -18,7 +18,6 @@ import type { TerserOptions } from 'terser-webpack-plugin';
|
|
|
18
18
|
import type { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
|
|
19
19
|
type Bundler = 'webpack' | 'rspack';
|
|
20
20
|
type JavaScriptLoader = 'babel' | 'swc';
|
|
21
|
-
type ServerCompiler = 'typescript' | 'swc';
|
|
22
21
|
export type SwcConfig = Swc.Config & Pick<Swc.Options, 'isModule'>;
|
|
23
22
|
export interface Entities<T> {
|
|
24
23
|
data: Record<string, T>;
|
|
@@ -267,11 +266,6 @@ export interface ServerConfig {
|
|
|
267
266
|
watchThrottle?: number;
|
|
268
267
|
inspect?: number | true;
|
|
269
268
|
inspectBrk?: number | true;
|
|
270
|
-
/**
|
|
271
|
-
* Compiler for server code compilation
|
|
272
|
-
* @default 'typescript'
|
|
273
|
-
*/
|
|
274
|
-
compiler?: ServerCompiler;
|
|
275
269
|
}
|
|
276
270
|
export interface ServiceConfig {
|
|
277
271
|
target?: 'client' | 'server';
|
|
@@ -312,12 +306,11 @@ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'pu
|
|
|
312
306
|
}) => SwcConfig | Promise<SwcConfig>;
|
|
313
307
|
reactRefresh: NonNullable<ClientConfig['reactRefresh']>;
|
|
314
308
|
};
|
|
315
|
-
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk'
|
|
309
|
+
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk'> & {
|
|
316
310
|
port?: number;
|
|
317
311
|
verbose?: boolean;
|
|
318
312
|
inspect?: number;
|
|
319
313
|
inspectBrk?: number;
|
|
320
|
-
compiler: ServerCompiler;
|
|
321
314
|
};
|
|
322
315
|
export type NormalizedServiceConfig = Omit<ServiceConfig, 'client' | 'server'> & {
|
|
323
316
|
client: NormalizedClientConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.28.1-beta.
|
|
3
|
+
"version": "0.28.1-beta.6",
|
|
4
4
|
"description": "Develop and build your React client-server projects, powered by typescript and webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -75,14 +75,13 @@
|
|
|
75
75
|
"@rspack/core": "1.3.9",
|
|
76
76
|
"@rspack/dev-server": "^1.1.1",
|
|
77
77
|
"@rspack/plugin-react-refresh": "^1.4.1",
|
|
78
|
+
"@statoscope/webpack-plugin": "^5.29.0",
|
|
78
79
|
"@statoscope/stats": "^5.28.1",
|
|
79
80
|
"@statoscope/stats-extension-compressed": "^5.28.1",
|
|
80
81
|
"@statoscope/webpack-model": "^5.29.0",
|
|
81
|
-
"@statoscope/webpack-plugin": "^5.29.0",
|
|
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",
|
|
86
85
|
"@swc/core": "1.11.24",
|
|
87
86
|
"@swc/plugin-transform-imports": "7.0.3",
|
|
88
87
|
"babel-loader": "^9.2.1",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '../logger';
|
|
2
|
-
interface SwcCompileOptions {
|
|
3
|
-
projectPath: string;
|
|
4
|
-
outputPath: string;
|
|
5
|
-
logger: Logger;
|
|
6
|
-
enableSourceMap?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function compile({ projectPath, outputPath, logger, enableSourceMap, }: SwcCompileOptions): Promise<void>;
|
|
9
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compile = compile;
|
|
4
|
-
const rimraf_1 = require("rimraf");
|
|
5
|
-
// @ts-ignore - @swc/cli не имеет типов
|
|
6
|
-
const cli_1 = require("@swc/cli");
|
|
7
|
-
const pretty_time_1 = require("../logger/pretty-time");
|
|
8
|
-
async function compile({ projectPath, outputPath, logger, enableSourceMap = false, }) {
|
|
9
|
-
const start = process.hrtime.bigint();
|
|
10
|
-
logger.message('Start SWC compilation');
|
|
11
|
-
// Очищаем выходную директорию
|
|
12
|
-
rimraf_1.rimraf.sync(outputPath);
|
|
13
|
-
const swcConfig = {
|
|
14
|
-
module: {
|
|
15
|
-
type: 'commonjs',
|
|
16
|
-
},
|
|
17
|
-
jsc: {
|
|
18
|
-
parser: {
|
|
19
|
-
syntax: 'typescript',
|
|
20
|
-
tsx: true,
|
|
21
|
-
},
|
|
22
|
-
target: 'es2020',
|
|
23
|
-
transform: {
|
|
24
|
-
decoratorMetadata: true,
|
|
25
|
-
},
|
|
26
|
-
externalHelpers: false,
|
|
27
|
-
},
|
|
28
|
-
sourceMaps: enableSourceMap,
|
|
29
|
-
};
|
|
30
|
-
const cliOptions = {
|
|
31
|
-
filenames: [projectPath],
|
|
32
|
-
outDir: outputPath,
|
|
33
|
-
watch: false,
|
|
34
|
-
quiet: false,
|
|
35
|
-
sourceMaps: enableSourceMap,
|
|
36
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
37
|
-
stripLeadingPaths: true,
|
|
38
|
-
deleteDirOnStart: false,
|
|
39
|
-
copyFiles: false,
|
|
40
|
-
includeDotfiles: false,
|
|
41
|
-
sync: false,
|
|
42
|
-
workers: 1,
|
|
43
|
-
};
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
const callbacks = {
|
|
46
|
-
onSuccess: (_result) => {
|
|
47
|
-
logger.success(`SWC compiled successfully in ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
48
|
-
resolve();
|
|
49
|
-
},
|
|
50
|
-
onFail: (result) => {
|
|
51
|
-
logger.error(`SWC compilation failed in ${result.duration}ms`);
|
|
52
|
-
if (result.reasons) {
|
|
53
|
-
for (const [filename, error] of result.reasons) {
|
|
54
|
-
logger.error(`${filename}: ${error}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
logger.error(`Error compile, elapsed time ${(0, pretty_time_1.elapsedTime)(start)}`);
|
|
58
|
-
reject(new Error('SWC compilation failed'));
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
try {
|
|
62
|
-
(0, cli_1.swcDir)({
|
|
63
|
-
cliOptions,
|
|
64
|
-
swcOptions: swcConfig,
|
|
65
|
-
callbacks,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
logger.error(`Failed to start SWC compilation: ${error}`);
|
|
70
|
-
reject(error);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
package/dist/common/swc/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '../logger';
|
|
2
|
-
interface SwcWatchOptions {
|
|
3
|
-
projectPath: string;
|
|
4
|
-
outputPath: string;
|
|
5
|
-
logger: Logger;
|
|
6
|
-
onAfterFilesEmitted?: () => void;
|
|
7
|
-
enableSourceMap?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function watch(swcDir: any, { projectPath, outputPath, logger, onAfterFilesEmitted, enableSourceMap, }: SwcWatchOptions): Promise<void>;
|
|
10
|
-
export {};
|
package/dist/common/swc/watch.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.watch = watch;
|
|
4
|
-
const rimraf_1 = require("rimraf");
|
|
5
|
-
const getSwcConfig = () => {
|
|
6
|
-
return {
|
|
7
|
-
jsc: {
|
|
8
|
-
target: 'es2020',
|
|
9
|
-
parser: {
|
|
10
|
-
syntax: 'typescript',
|
|
11
|
-
decorators: false,
|
|
12
|
-
dynamicImport: false,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
sourceMaps: true,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
async function watch(
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
swcDir, { projectPath, outputPath, logger, onAfterFilesEmitted, enableSourceMap = false, }) {
|
|
21
|
-
logger.message('Start SWC compilation in watch mode');
|
|
22
|
-
// Очищаем выходную директорию
|
|
23
|
-
rimraf_1.rimraf.sync(outputPath);
|
|
24
|
-
const swcConfig = getSwcConfig();
|
|
25
|
-
const cliOptions = {
|
|
26
|
-
filenames: [projectPath],
|
|
27
|
-
outDir: outputPath,
|
|
28
|
-
watch: true,
|
|
29
|
-
quiet: false,
|
|
30
|
-
sourceMaps: enableSourceMap,
|
|
31
|
-
extensions: ['.js', '.ts', '.mjs', '.cjs'],
|
|
32
|
-
stripLeadingPaths: true,
|
|
33
|
-
deleteDirOnStart: false,
|
|
34
|
-
copyFiles: false,
|
|
35
|
-
includeDotfiles: false,
|
|
36
|
-
sync: false,
|
|
37
|
-
workers: 1,
|
|
38
|
-
logWatchCompilation: true,
|
|
39
|
-
};
|
|
40
|
-
const callbacks = {
|
|
41
|
-
onSuccess: (result) => {
|
|
42
|
-
if (result.filename) {
|
|
43
|
-
logger.verbose(`Successfully compiled ${result.filename} in ${result.duration}ms`);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
logger.message(`Successfully compiled ${result.compiled || 0} files in ${result.duration}ms`);
|
|
47
|
-
}
|
|
48
|
-
onAfterFilesEmitted?.();
|
|
49
|
-
},
|
|
50
|
-
onFail: (result) => {
|
|
51
|
-
logger.error(`SWC compilation failed in ${result.duration}ms`);
|
|
52
|
-
if (result.reasons) {
|
|
53
|
-
for (const [filename, error] of result.reasons) {
|
|
54
|
-
logger.error(`${filename}: ${error}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
onWatchReady: () => {
|
|
59
|
-
logger.message('SWC watching for file changes');
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
// Запускаем swcDir
|
|
63
|
-
await swcDir({
|
|
64
|
-
cliOptions,
|
|
65
|
-
swcOptions: swcConfig,
|
|
66
|
-
callbacks,
|
|
67
|
-
});
|
|
68
|
-
}
|