@gravity-ui/app-builder 0.36.0 → 0.38.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/README.md
CHANGED
|
@@ -156,7 +156,7 @@ All server settings are used only in dev mode:
|
|
|
156
156
|
|
|
157
157
|
- `port` (`number | true`) — specify port that server listens. The port will be used to
|
|
158
158
|
pass through requests from the client to the server. If set to `true`, the port will be selected automatically.
|
|
159
|
-
The server is started with the command `APP_PORT=${port} node dist/
|
|
159
|
+
The server is started with the command `APP_PORT=${port} node dist/${outputPath}/index.js --port ${port}`.
|
|
160
160
|
- `watch` (`string[]`) — by default `app-builder` monitors only `src/server` directory.
|
|
161
161
|
If you need to watch other directories, specify them here.
|
|
162
162
|
- `watchThrottle` (`number`) — use to add an extra throttle, or delay restarting.
|
|
@@ -164,6 +164,8 @@ All server settings are used only in dev mode:
|
|
|
164
164
|
If specified `true`, try to listen on `9229`.
|
|
165
165
|
- `compiler` (`'typescript' | 'swc'`) — choose TypeScript compiler for server code compilation.
|
|
166
166
|
Default is `'typescript'`. Set to `'swc'` for faster compilation with SWC.
|
|
167
|
+
- `outputPath` (`string`) — custom output path for compiled server code relative to `dist` directory.
|
|
168
|
+
Default: `server`. Use this when your `server` entrypoint changed from `dist/server` to a different location (e.g., `package/src/server` for path `dist/package/src/server` in monorepo setups).
|
|
167
169
|
|
|
168
170
|
### Client
|
|
169
171
|
|
|
@@ -233,6 +235,7 @@ With this `{rootDir}/src/ui/tsconfig.json`:
|
|
|
233
235
|
- `ipc` (`string`) — the Unix socket to listen to. If `ipc` and `port` are not defined, then the socket `{rootDir}/dist/run/client.sock` is used.
|
|
234
236
|
- `port` (`number | true`) — specify a port number to listen for requests on. If `true`, the free port will be selected automatically.
|
|
235
237
|
- `webSocketPath` (`string`) — tells clients connected to devServer to use the provided path to connect. Default is `${publicPathPrefix}/build/sockjs-node`.
|
|
238
|
+
- `webSocketClientPort` (`number`) - tells clients to connect to devServer using this port from a browser. Default is `${devServer.port}`
|
|
236
239
|
- `type` (`'https'`) — allow to serve over HTTPS.
|
|
237
240
|
- `options` (`import('https').ServerOptions`) — allow to provide your own certificate.
|
|
238
241
|
- `watchOptions` — a set of options used to customize watch mode, [more](https://webpack.js.org/configuration/watch/#watchoptions)
|
|
@@ -50,7 +50,7 @@ async function buildDevServer(config) {
|
|
|
50
50
|
const bundler = config.client.bundler;
|
|
51
51
|
const logger = new logger_1.Logger('client', config.verbose);
|
|
52
52
|
const { publicPath } = config.client;
|
|
53
|
-
const { webSocketPath = path.normalize(`/${publicPath}/sockjs-node`), writeToDisk, ...devServer } = config.client.devServer || {};
|
|
53
|
+
const { webSocketPath = path.normalize(`/${publicPath}/sockjs-node`), webSocketClientPort, writeToDisk, ...devServer } = config.client.devServer || {};
|
|
54
54
|
const normalizedConfig = { ...config.client, devServer: { ...devServer, webSocketPath } };
|
|
55
55
|
const isSsr = Boolean(normalizedConfig.ssr);
|
|
56
56
|
let webpackConfigs = [];
|
|
@@ -130,7 +130,7 @@ async function buildDevServer(config) {
|
|
|
130
130
|
hot: true,
|
|
131
131
|
client: {
|
|
132
132
|
logging: config.verbose ? 'log' : 'error',
|
|
133
|
-
webSocketURL: { pathname: webSocketPath },
|
|
133
|
+
webSocketURL: { pathname: webSocketPath, port: webSocketClientPort },
|
|
134
134
|
overlay: {
|
|
135
135
|
runtimeErrors: config.verbose,
|
|
136
136
|
warnings: config.verbose,
|
|
@@ -27,14 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.default = default_1;
|
|
30
|
-
const path = __importStar(require("node:path"));
|
|
31
30
|
const fs = __importStar(require("node:fs"));
|
|
32
31
|
const nodemon_1 = __importDefault(require("nodemon"));
|
|
33
32
|
const signal_exit_1 = require("signal-exit");
|
|
34
33
|
const rimraf_1 = require("rimraf");
|
|
35
34
|
const utils_1 = require("../../common/utils");
|
|
36
35
|
const logger_1 = __importDefault(require("../../common/logger"));
|
|
37
|
-
const paths_1 = __importDefault(require("../../common/paths"));
|
|
38
36
|
async function default_1(config) {
|
|
39
37
|
process.env.NODE_ENV = 'development';
|
|
40
38
|
const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
|
|
@@ -55,7 +53,7 @@ async function default_1(config) {
|
|
|
55
53
|
let clientCompiled = !shouldCompileClient;
|
|
56
54
|
let serverCompiled = !shouldCompileServer;
|
|
57
55
|
let needToStartNodemon = shouldCompileServer;
|
|
58
|
-
const serverPath =
|
|
56
|
+
const serverPath = config.server.outputPath;
|
|
59
57
|
const { inspect, inspectBrk } = config.server;
|
|
60
58
|
const startNodemon = () => {
|
|
61
59
|
if (needToStartNodemon && serverCompiled && clientCompiled) {
|
|
@@ -1,33 +1,9 @@
|
|
|
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.watchServerCompilation = watchServerCompilation;
|
|
30
|
-
const path = __importStar(require("node:path"));
|
|
31
7
|
const rimraf_1 = require("rimraf");
|
|
32
8
|
const controllable_script_1 = require("../../common/child-process/controllable-script");
|
|
33
9
|
const paths_1 = __importDefault(require("../../common/paths"));
|
|
@@ -79,7 +55,7 @@ watch(
|
|
|
79
55
|
);`;
|
|
80
56
|
}
|
|
81
57
|
async function watchServerCompilation(config) {
|
|
82
|
-
const serverPath =
|
|
58
|
+
const serverPath = config.server.outputPath;
|
|
83
59
|
rimraf_1.rimraf.sync(serverPath);
|
|
84
60
|
const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
|
|
85
61
|
? createSWCBuildScript(config)
|
package/dist/common/config.js
CHANGED
|
@@ -33,6 +33,7 @@ const cosmiconfig_1 = require("cosmiconfig");
|
|
|
33
33
|
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
34
34
|
const common_tags_1 = require("common-tags");
|
|
35
35
|
const models_1 = require("./models");
|
|
36
|
+
const paths_1 = __importDefault(require("./paths"));
|
|
36
37
|
const utils_1 = require("./utils");
|
|
37
38
|
const logger_1 = __importDefault(require("./logger"));
|
|
38
39
|
function splitPaths(paths) {
|
|
@@ -163,6 +164,7 @@ async function normalizeConfig(userConfig, mode) {
|
|
|
163
164
|
inspect: undefined,
|
|
164
165
|
inspectBrk: undefined,
|
|
165
166
|
compiler: serverConfig.compiler || 'typescript',
|
|
167
|
+
outputPath: path.resolve(paths_1.default.appDist, serverConfig.outputPath ? serverConfig.outputPath : 'server'),
|
|
166
168
|
};
|
|
167
169
|
if (mode === 'dev') {
|
|
168
170
|
if (serverConfig.port === true) {
|
|
@@ -29,6 +29,7 @@ interface DevServerConfig {
|
|
|
29
29
|
ipc?: string;
|
|
30
30
|
port?: number | true;
|
|
31
31
|
webSocketPath?: string;
|
|
32
|
+
webSocketClientPort?: number;
|
|
32
33
|
type?: 'https';
|
|
33
34
|
options?: import('https').ServerOptions;
|
|
34
35
|
writeToDisk?: boolean | ((targetPath: string) => boolean);
|
|
@@ -367,6 +368,13 @@ export interface ServerConfig {
|
|
|
367
368
|
additionalPaths?: string[];
|
|
368
369
|
exclude?: string | string[];
|
|
369
370
|
};
|
|
371
|
+
/**
|
|
372
|
+
* Custom output path for compiled server code.
|
|
373
|
+
* Can be only relative to dist path.
|
|
374
|
+
* @default 'server'
|
|
375
|
+
* @example 'package/src/server'
|
|
376
|
+
*/
|
|
377
|
+
outputPath?: string;
|
|
370
378
|
}
|
|
371
379
|
export interface ServiceConfig {
|
|
372
380
|
target?: 'client' | 'server';
|
|
@@ -424,12 +432,13 @@ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'pu
|
|
|
424
432
|
}) => SwcConfig | Promise<SwcConfig>;
|
|
425
433
|
reactRefresh: NonNullable<ClientConfig['reactRefresh']>;
|
|
426
434
|
};
|
|
427
|
-
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk' | 'compiler'> & {
|
|
435
|
+
export type NormalizedServerConfig = Omit<ServerConfig, 'port' | 'inspect' | 'inspectBrk' | 'compiler' | 'outputPath'> & {
|
|
428
436
|
port?: number;
|
|
429
437
|
verbose?: boolean;
|
|
430
438
|
inspect?: number;
|
|
431
439
|
inspectBrk?: number;
|
|
432
440
|
compiler: ServerCompiler;
|
|
441
|
+
outputPath: string;
|
|
433
442
|
};
|
|
434
443
|
export type NormalizedServiceConfig = Omit<ServiceConfig, 'client' | 'server'> & {
|
|
435
444
|
client: NormalizedClientConfig;
|