@gravity-ui/app-builder 0.30.3 → 0.31.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.
- package/dist/commands/build/build-service/server.js +2 -0
- package/dist/commands/dev/server.js +2 -0
- package/dist/common/models/index.d.ts +8 -0
- package/dist/common/swc/compile.d.ts +4 -3
- package/dist/common/swc/compile.js +6 -2
- package/dist/common/swc/utils.d.ts +7 -1
- package/dist/common/swc/utils.js +14 -2
- package/dist/common/swc/watch.d.ts +4 -3
- package/dist/common/swc/watch.js +6 -2
- package/package.json +1 -1
|
@@ -18,6 +18,8 @@ compile({
|
|
|
18
18
|
logger,
|
|
19
19
|
outputPath: ${JSON.stringify(paths_1.default.appDist)},
|
|
20
20
|
projectPath: ${JSON.stringify(paths_1.default.appServer)},
|
|
21
|
+
additionalPaths: ${JSON.stringify(config.server.swcOptions?.additionalPaths)},
|
|
22
|
+
exclude: ${JSON.stringify(config.server.swcOptions?.exclude)},
|
|
21
23
|
});`;
|
|
22
24
|
}
|
|
23
25
|
function createTypescriptBuildScript(config) {
|
|
@@ -341,6 +341,14 @@ export interface ServerConfig {
|
|
|
341
341
|
* @default 'typescript'
|
|
342
342
|
*/
|
|
343
343
|
compiler?: ServerCompiler;
|
|
344
|
+
/**
|
|
345
|
+
* Additional options for SWC compilation.
|
|
346
|
+
* Works only if `compiler` is 'swc'.
|
|
347
|
+
*/
|
|
348
|
+
swcOptions?: {
|
|
349
|
+
additionalPaths?: string[];
|
|
350
|
+
exclude?: string | string[];
|
|
351
|
+
};
|
|
344
352
|
}
|
|
345
353
|
export interface ServiceConfig {
|
|
346
354
|
target?: 'client' | 'server';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Logger } from '../logger';
|
|
2
|
-
|
|
2
|
+
import type { GetSwcOptionsFromTsconfigOptions } from './utils';
|
|
3
|
+
type SwcCompileOptions = Pick<GetSwcOptionsFromTsconfigOptions, 'additionalPaths' | 'exclude'> & {
|
|
3
4
|
projectPath: string;
|
|
4
5
|
outputPath: string;
|
|
5
6
|
logger: Logger;
|
|
6
|
-
}
|
|
7
|
-
export declare function compile({ projectPath, outputPath, logger }: SwcCompileOptions): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare function compile({ projectPath, outputPath, logger, additionalPaths, exclude, }: SwcCompileOptions): Promise<void>;
|
|
8
9
|
export {};
|
|
@@ -5,10 +5,14 @@ const pretty_time_1 = require("../logger/pretty-time");
|
|
|
5
5
|
// @ts-ignore @swc/cli is not typed
|
|
6
6
|
const cli_1 = require("@swc/cli");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
|
-
async function compile({ projectPath, outputPath, logger }) {
|
|
8
|
+
async function compile({ projectPath, outputPath, logger, additionalPaths, exclude, }) {
|
|
9
9
|
const start = process.hrtime.bigint();
|
|
10
10
|
logger.message('Start compilation');
|
|
11
|
-
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(
|
|
11
|
+
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)({
|
|
12
|
+
projectPath,
|
|
13
|
+
additionalPaths,
|
|
14
|
+
exclude,
|
|
15
|
+
});
|
|
12
16
|
const cliOptions = {
|
|
13
17
|
filenames: directoriesToCompile,
|
|
14
18
|
outDir: outputPath,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export declare const EXTENSIONS_TO_COMPILE: string[];
|
|
2
|
-
export
|
|
2
|
+
export type GetSwcOptionsFromTsconfigOptions = {
|
|
3
|
+
projectPath: string;
|
|
4
|
+
filename?: string;
|
|
5
|
+
additionalPaths?: string[];
|
|
6
|
+
exclude?: string | string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function getSwcOptionsFromTsconfig({ projectPath, filename, additionalPaths, exclude, }: GetSwcOptionsFromTsconfigOptions): {
|
|
3
9
|
swcOptions: import("@swc/types").Options;
|
|
4
10
|
directoriesToCompile: string[];
|
|
5
11
|
};
|
package/dist/common/swc/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.EXTENSIONS_TO_COMPILE = void 0;
|
|
|
7
7
|
exports.getSwcOptionsFromTsconfig = getSwcOptionsFromTsconfig;
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const tsconfig_to_swcconfig_1 = require("tsconfig-to-swcconfig");
|
|
10
|
+
const DEFAULT_EXCLUDE = ['node_modules'];
|
|
10
11
|
exports.EXTENSIONS_TO_COMPILE = ['.js', '.ts', '.mts', '.mjs', '.cjs'];
|
|
11
12
|
function resolvePaths(paths, baseUrl) {
|
|
12
13
|
const entries = [];
|
|
@@ -18,16 +19,27 @@ function resolvePaths(paths, baseUrl) {
|
|
|
18
19
|
}
|
|
19
20
|
return entries;
|
|
20
21
|
}
|
|
21
|
-
function getSwcOptionsFromTsconfig(projectPath, filename = 'tsconfig.json') {
|
|
22
|
+
function getSwcOptionsFromTsconfig({ projectPath, filename = 'tsconfig.json', additionalPaths, exclude, }) {
|
|
22
23
|
const swcOptions = (0, tsconfig_to_swcconfig_1.convert)(filename, projectPath);
|
|
24
|
+
swcOptions.exclude = swcOptions.exclude || [];
|
|
23
25
|
swcOptions.jsc = {
|
|
24
26
|
...swcOptions.jsc,
|
|
25
27
|
// SWC requires absolute path as baseUrl
|
|
26
28
|
baseUrl: projectPath,
|
|
27
29
|
};
|
|
30
|
+
let customExclude = [];
|
|
31
|
+
if (Array.isArray(exclude)) {
|
|
32
|
+
customExclude = exclude;
|
|
33
|
+
}
|
|
34
|
+
else if (exclude) {
|
|
35
|
+
customExclude = [exclude];
|
|
36
|
+
}
|
|
37
|
+
swcOptions.exclude = [...(swcOptions.exclude || []), ...DEFAULT_EXCLUDE, ...customExclude];
|
|
28
38
|
// SWC don't compile referenced files like tsc, so we need collect all directories to compile.
|
|
29
39
|
const paths = swcOptions.jsc.paths || {};
|
|
30
|
-
const directoriesToCompile = [
|
|
40
|
+
const directoriesToCompile = [
|
|
41
|
+
...new Set([projectPath, ...resolvePaths(paths, projectPath), ...(additionalPaths || [])]),
|
|
42
|
+
];
|
|
31
43
|
return {
|
|
32
44
|
swcOptions,
|
|
33
45
|
directoriesToCompile,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Logger } from '../logger';
|
|
2
|
-
|
|
2
|
+
import type { GetSwcOptionsFromTsconfigOptions } from './utils';
|
|
3
|
+
type SwcWatchOptions = Pick<GetSwcOptionsFromTsconfigOptions, 'additionalPaths' | 'exclude'> & {
|
|
3
4
|
outputPath: string;
|
|
4
5
|
logger: Logger;
|
|
5
6
|
onAfterFilesEmitted?: () => void;
|
|
6
|
-
}
|
|
7
|
-
export declare function watch(projectPath: string, { outputPath, logger, onAfterFilesEmitted }: SwcWatchOptions): Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export declare function watch(projectPath: string, { outputPath, logger, onAfterFilesEmitted, additionalPaths, exclude }: SwcWatchOptions): Promise<void>;
|
|
8
9
|
export {};
|
package/dist/common/swc/watch.js
CHANGED
|
@@ -4,9 +4,13 @@ exports.watch = watch;
|
|
|
4
4
|
// @ts-ignore @swc/cli is not typed
|
|
5
5
|
const cli_1 = require("@swc/cli");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted }) {
|
|
7
|
+
async function watch(projectPath, { outputPath, logger, onAfterFilesEmitted, additionalPaths, exclude }) {
|
|
8
8
|
logger.message('Start compilation in watch mode');
|
|
9
|
-
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)(
|
|
9
|
+
const { swcOptions, directoriesToCompile } = (0, utils_1.getSwcOptionsFromTsconfig)({
|
|
10
|
+
projectPath,
|
|
11
|
+
additionalPaths,
|
|
12
|
+
exclude,
|
|
13
|
+
});
|
|
10
14
|
const cliOptions = {
|
|
11
15
|
filenames: directoriesToCompile,
|
|
12
16
|
outDir: outputPath,
|