@gravity-ui/app-builder 0.10.0 → 0.11.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.
Files changed (57) hide show
  1. package/dist/cli.js +3 -5
  2. package/dist/commands/build/build-lib.js +23 -20
  3. package/dist/commands/build/build-service/client.js +1 -2
  4. package/dist/commands/build/build-service/index.js +1 -1
  5. package/dist/commands/build/build-service/server.js +23 -21
  6. package/dist/commands/build/index.js +1 -1
  7. package/dist/commands/dev/client.js +31 -33
  8. package/dist/commands/dev/index.js +3 -3
  9. package/dist/commands/dev/server.d.ts +1 -1
  10. package/dist/commands/dev/server.js +3 -4
  11. package/dist/common/babel/index.js +1 -2
  12. package/dist/common/child-process/controllable-script.d.ts +2 -4
  13. package/dist/common/child-process/controllable-script.js +4 -4
  14. package/dist/common/child-process/utils.js +1 -2
  15. package/dist/common/config.js +61 -36
  16. package/dist/common/library/babel-plugin-replace-paths.js +1 -0
  17. package/dist/common/library/index.js +1 -2
  18. package/dist/common/logger/colors.d.ts +2 -2
  19. package/dist/common/logger/index.d.ts +4 -6
  20. package/dist/common/logger/index.js +9 -6
  21. package/dist/common/logger/log-config.js +2 -2
  22. package/dist/common/logger/pretty-time.js +2 -3
  23. package/dist/common/models/index.d.ts +13 -18
  24. package/dist/common/models/index.js +3 -4
  25. package/dist/common/s3-upload/compress.js +2 -3
  26. package/dist/common/s3-upload/s3-client.d.ts +0 -1
  27. package/dist/common/s3-upload/s3-client.js +8 -14
  28. package/dist/common/s3-upload/upload.js +9 -6
  29. package/dist/common/typescript/compile.js +2 -3
  30. package/dist/common/typescript/diagnostic.js +1 -2
  31. package/dist/common/typescript/transformers.js +4 -3
  32. package/dist/common/typescript/utils.d.ts +4 -1
  33. package/dist/common/typescript/utils.js +31 -7
  34. package/dist/common/typescript/watch.js +2 -2
  35. package/dist/common/utils.d.ts +1 -1
  36. package/dist/common/utils.js +7 -8
  37. package/dist/common/webpack/compile.js +1 -2
  38. package/dist/common/webpack/config.d.ts +2 -7
  39. package/dist/common/webpack/config.js +14 -57
  40. package/dist/common/webpack/lazy-client.js +4 -4
  41. package/dist/common/webpack/progress-plugin.js +1 -0
  42. package/dist/common/webpack/storybook.js +2 -3
  43. package/dist/common/webpack/utils.js +3 -4
  44. package/dist/common/webpack/worker/web-worker.d.mts +1 -1
  45. package/dist/common/webpack/worker/web-worker.mjs +0 -1
  46. package/dist/common/webpack/worker/worker-loader.js +5 -1
  47. package/dist/create-cli.d.ts +2 -2
  48. package/dist/create-cli.js +17 -25
  49. package/package.json +67 -72
  50. package/dist/common/links/link.d.ts +0 -1
  51. package/dist/common/links/link.js +0 -132
  52. package/dist/common/links/unlink.d.ts +0 -3
  53. package/dist/common/links/unlink.js +0 -95
  54. package/dist/common/package.d.ts +0 -19
  55. package/dist/common/package.js +0 -65
  56. package/dist/common/tempData.d.ts +0 -13
  57. package/dist/common/tempData.js +0 -67
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ const common_tags_1 = require("common-tags");
10
10
  require("./common/env");
11
11
  const logger_1 = __importDefault(require("./common/logger"));
12
12
  const create_cli_1 = require("./create-cli");
13
- const MIN_NODE_VERSION = '14.15.0';
13
+ const MIN_NODE_VERSION = '18.0.0';
14
14
  const { version } = process;
15
15
  if (!semver_1.default.satisfies(version, `>=${MIN_NODE_VERSION}`, {
16
16
  includePrerelease: true,
@@ -32,10 +32,8 @@ process.on('unhandledRejection', (reason) => {
32
32
  // across versions and crash
33
33
  // reason can be anything, it can be a message, an object, ANYTHING!
34
34
  // we convert it to an error object
35
- if (!(reason instanceof Error)) {
36
- reason = new Error(util_1.default.format(reason));
37
- }
38
- logger_1.default.panic('UNHANDLED REJECTION', reason);
35
+ const error = reason instanceof Error ? reason : new Error(util_1.default.format(reason));
36
+ logger_1.default.panic('UNHANDLED REJECTION', error);
39
37
  });
40
38
  process.on('uncaughtException', (error) => {
41
39
  logger_1.default.panic('UNHANDLED EXCEPTION', error);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  const signal_exit_1 = require("signal-exit");
4
5
  const controllable_script_1 = require("../../common/child-process/controllable-script");
5
6
  function default_1(config) {
@@ -8,26 +9,28 @@ function default_1(config) {
8
9
  const {buildLibrary} = require(${JSON.stringify(require.resolve('../../common/library'))});
9
10
  buildLibrary({lib: ${JSON.stringify(config.lib)}});
10
11
  `, null);
11
- build.start();
12
- build.onExit((code) => {
13
- if (code) {
14
- reject(new Error('Error build library'));
15
- }
16
- else {
17
- resolve(true);
18
- }
19
- });
20
- process.on('SIGINT', async () => {
21
- await build.stop('SIGINT');
22
- process.exit(1);
23
- });
24
- process.on('SIGTERM', async () => {
25
- await build.stop('SIGTERM');
26
- process.exit(1);
27
- });
28
- (0, signal_exit_1.onExit)((_code, signal) => {
29
- build.stop(signal);
12
+ build.start().then(() => {
13
+ build.onExit((code) => {
14
+ if (code) {
15
+ reject(new Error('Error build library'));
16
+ }
17
+ else {
18
+ resolve(true);
19
+ }
20
+ });
21
+ process.on('SIGINT', async () => {
22
+ await build.stop('SIGINT');
23
+ process.exit(1);
24
+ });
25
+ process.on('SIGTERM', async () => {
26
+ await build.stop('SIGTERM');
27
+ process.exit(1);
28
+ });
29
+ (0, signal_exit_1.onExit)((_code, signal) => {
30
+ build.stop(signal);
31
+ });
32
+ }, (error) => {
33
+ reject(error);
30
34
  });
31
35
  });
32
36
  }
33
- exports.default = default_1;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildClient = void 0;
3
+ exports.buildClient = buildClient;
4
4
  const compile_1 = require("../../../common/webpack/compile");
5
5
  function buildClient(config) {
6
6
  return (0, compile_1.webpackCompile)(config.client);
7
7
  }
8
- exports.buildClient = buildClient;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  const utils_1 = require("../../../common/utils");
4
5
  function default_1(config) {
5
6
  const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
@@ -19,4 +20,3 @@ function default_1(config) {
19
20
  }
20
21
  return Promise.all(compilations);
21
22
  }
22
- exports.default = default_1;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildServer = void 0;
6
+ exports.buildServer = buildServer;
7
7
  const signal_exit_1 = require("signal-exit");
8
8
  const controllable_script_1 = require("../../../common/child-process/controllable-script");
9
9
  const paths_1 = __importDefault(require("../../../common/paths"));
@@ -27,26 +27,28 @@ function buildServer(config) {
27
27
  const logger = new Logger('server', ${config.verbose});
28
28
  compile(ts, {logger, projectPath: ${JSON.stringify(paths_1.default.appServer)}});
29
29
  `, null);
30
- build.start();
31
- build.onExit((code) => {
32
- if (code) {
33
- reject(new Error('Error compile server'));
34
- }
35
- else {
36
- resolve();
37
- }
38
- });
39
- process.on('SIGINT', async () => {
40
- await build.stop('SIGINT');
41
- process.exit(1);
42
- });
43
- process.on('SIGTERM', async () => {
44
- await build.stop('SIGTERM');
45
- process.exit(1);
46
- });
47
- (0, signal_exit_1.onExit)((_code, signal) => {
48
- build.stop(signal);
30
+ build.start().then(() => {
31
+ build.onExit((code) => {
32
+ if (code) {
33
+ reject(new Error('Error compile server'));
34
+ }
35
+ else {
36
+ resolve();
37
+ }
38
+ });
39
+ process.on('SIGINT', async () => {
40
+ await build.stop('SIGINT');
41
+ process.exit(1);
42
+ });
43
+ process.on('SIGTERM', async () => {
44
+ await build.stop('SIGTERM');
45
+ process.exit(1);
46
+ });
47
+ (0, signal_exit_1.onExit)((_code, signal) => {
48
+ build.stop(signal);
49
+ });
50
+ }, (error) => {
51
+ reject(error);
49
52
  });
50
53
  });
51
54
  }
52
- exports.buildServer = buildServer;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
3
4
  const models_1 = require("../../common/models");
4
5
  async function default_1(config) {
5
6
  process.env.NODE_ENV = 'production';
@@ -7,4 +8,3 @@ async function default_1(config) {
7
8
  const { default: build } = require((0, models_1.isLibraryConfig)(config) ? './build-lib' : './build-service');
8
9
  return build(config);
9
10
  }
10
- exports.default = default_1;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.watchClientCompilation = void 0;
29
+ exports.watchClientCompilation = watchClientCompilation;
30
30
  const path = __importStar(require("node:path"));
31
31
  const fs = __importStar(require("node:fs"));
32
32
  const webpack_1 = __importDefault(require("webpack"));
@@ -41,17 +41,19 @@ async function watchClientCompilation(config, onCompilationEnd) {
41
41
  afterEmit.tap('app-builder: afterEmit', onCompilationEnd);
42
42
  return clientCompilation;
43
43
  }
44
- exports.watchClientCompilation = watchClientCompilation;
45
44
  async function buildWebpackServer(config) {
46
45
  const logger = new logger_1.Logger('webpack', config.verbose);
47
- const { webSocketPath = path.normalize(`/${config.client.publicPathPrefix}/build/sockjs-node`), ...devServer } = config.client.devServer || {};
46
+ const { webSocketPath = path.normalize(`/${config.client.publicPathPrefix}/build/sockjs-node`), writeToDisk, ...devServer } = config.client.devServer || {};
48
47
  const normalizedConfig = { ...config.client, devServer: { ...devServer, webSocketPath } };
49
48
  const webpackConfig = await (0, config_1.webpackConfigFactory)("development" /* WebpackMode.Dev */, normalizedConfig, { logger });
49
+ const publicPath = path.normalize(config.client.publicPathPrefix + '/build/');
50
+ const staticFolder = path.resolve(paths_1.default.appDist, 'public');
50
51
  const options = {
51
- static: path.resolve(paths_1.default.appDist, 'public'),
52
+ static: staticFolder,
52
53
  devMiddleware: {
53
- publicPath: path.normalize(config.client.publicPathPrefix + '/build/'),
54
+ publicPath,
54
55
  stats: 'errors-warnings',
56
+ writeToDisk,
55
57
  },
56
58
  liveReload: false,
57
59
  hot: true,
@@ -81,45 +83,41 @@ async function buildWebpackServer(config) {
81
83
  if (!listenOn) {
82
84
  options.ipc = path.resolve(paths_1.default.appDist, 'run/client.sock');
83
85
  }
86
+ const proxy = options.proxy || [];
84
87
  if (config.client.lazyCompilation) {
85
- options.proxy = {
86
- ...options.proxy,
87
- '/build/lazy': {
88
- target: `http://localhost:${config.client.lazyCompilation.port}`,
89
- pathRewrite: { '^/build/lazy': '' },
90
- },
91
- };
88
+ proxy.push({
89
+ context: ['/build/lazy'],
90
+ target: `http://localhost:${config.client.lazyCompilation.port}`,
91
+ pathRewrite: { '^/build/lazy': '' },
92
+ });
92
93
  }
93
94
  if (config.server.port) {
94
- options.proxy = {
95
- ...options.proxy,
96
- '/': {
97
- target: `http://localhost:${config.server.port}`,
98
- bypass: (req) => {
99
- if (req.method !== 'GET' && req.method !== 'HEAD') {
100
- return null;
101
- }
102
- const pathname = req.path.replace(/^\//, '');
103
- const filepath = path.resolve(paths_1.default.appDist, 'public', pathname);
104
- if (!fs.existsSync(filepath)) {
105
- return null;
106
- }
107
- const stat = fs.statSync(filepath);
108
- if (!stat.isFile()) {
109
- return null;
110
- }
111
- return req.path;
112
- },
113
- },
95
+ // if server port is specified, proxy to it
96
+ const filter = (pathname, req) => {
97
+ // do not proxy build files
98
+ if (pathname.startsWith(publicPath)) {
99
+ return false;
100
+ }
101
+ // do not proxy static files
102
+ const filepath = path.resolve(staticFolder, pathname.replace(/^\//, ''));
103
+ if (req.method === 'GET' && fs.existsSync(filepath) && fs.statSync(filepath).isFile()) {
104
+ return false;
105
+ }
106
+ return true;
114
107
  };
108
+ proxy.push({
109
+ context: (...args) => filter(...args),
110
+ target: `http://localhost:${config.server.port}`,
111
+ });
115
112
  }
113
+ options.proxy = proxy;
116
114
  const compiler = (0, webpack_1.default)(webpackConfig);
117
115
  const server = new webpack_dev_server_1.default(options, compiler);
118
116
  try {
119
117
  await server.start();
120
118
  }
121
119
  catch (e) {
122
- logger.logError(e);
120
+ logger.logError('Cannot start webpack dev server', e);
123
121
  }
124
122
  if (options.ipc && typeof options.ipc === 'string') {
125
123
  fs.chmod(options.ipc, 0o666, (e) => logger.logError('', e));
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.default = default_1;
29
30
  const path = __importStar(require("node:path"));
30
31
  const nodemon_1 = __importDefault(require("nodemon"));
31
32
  const signal_exit_1 = require("signal-exit");
@@ -70,9 +71,9 @@ async function default_1(config) {
70
71
  let serverCompilation;
71
72
  if (shouldCompileServer) {
72
73
  const { watchServerCompilation } = await import('./server.js');
73
- serverCompilation = watchServerCompilation(config);
74
+ serverCompilation = await watchServerCompilation(config);
74
75
  serverCompilation.onMessage((msg) => {
75
- if (msg.type === 'Emitted') {
76
+ if (typeof msg === 'object' && 'type' in msg && msg.type === 'Emitted') {
76
77
  serverCompiled = true;
77
78
  startNodemon();
78
79
  }
@@ -104,4 +105,3 @@ async function default_1(config) {
104
105
  clientCompilation?.stop();
105
106
  });
106
107
  }
107
- exports.default = default_1;
@@ -1,3 +1,3 @@
1
1
  import { ControllableScript } from '../../common/child-process/controllable-script';
2
2
  import type { NormalizedServiceConfig } from '../../common/models';
3
- export declare function watchServerCompilation(config: NormalizedServiceConfig): ControllableScript;
3
+ export declare function watchServerCompilation(config: NormalizedServiceConfig): Promise<ControllableScript>;
@@ -26,13 +26,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.watchServerCompilation = void 0;
29
+ exports.watchServerCompilation = watchServerCompilation;
30
30
  const path = __importStar(require("node:path"));
31
31
  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 watchServerCompilation(config) {
35
+ async function watchServerCompilation(config) {
36
36
  const serverPath = path.resolve(paths_1.default.appDist, 'server');
37
37
  rimraf_1.rimraf.sync(serverPath);
38
38
  (0, utils_1.createRunFolder)();
@@ -62,7 +62,6 @@ function watchServerCompilation(config) {
62
62
  }
63
63
  );
64
64
  `, null);
65
- build.start();
65
+ await build.start();
66
66
  return build;
67
67
  }
68
- exports.watchServerCompilation = watchServerCompilation;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.babelPreset = void 0;
3
+ exports.babelPreset = babelPreset;
4
4
  function babelPreset(config) {
5
5
  return [
6
6
  require.resolve('./ui-preset'),
@@ -14,4 +14,3 @@ function babelPreset(config) {
14
14
  },
15
15
  ];
16
16
  }
17
- exports.babelPreset = babelPreset;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { Serializable } from 'child_process';
4
2
  interface IDebugInfo {
5
3
  break?: boolean;
@@ -11,9 +9,9 @@ export declare class ControllableScript {
11
9
  private script;
12
10
  private debugInfo;
13
11
  constructor(script: string, debugInfo: IDebugInfo | null);
14
- start(): void;
12
+ start(): Promise<void>;
15
13
  stop(signal?: NodeJS.Signals | null, code?: number): Promise<void>;
16
- onMessage(callback: (msg: any) => void): void;
14
+ onMessage(callback: (msg: Serializable) => void): void;
17
15
  onExit(callback: (code: number | null, signal: NodeJS.Signals | null) => void): void;
18
16
  send(msg: Serializable): void;
19
17
  }
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ControllableScript = void 0;
27
27
  const utils_1 = require("./utils");
28
28
  const fs = __importStar(require("fs-extra"));
29
- const execa = __importStar(require("execa"));
30
29
  const utils_2 = require("../utils");
31
30
  class ControllableScript {
32
31
  isRunning = false;
@@ -37,9 +36,9 @@ class ControllableScript {
37
36
  this.script = script;
38
37
  this.debugInfo = debugInfo;
39
38
  }
40
- start() {
39
+ async start() {
41
40
  const args = [];
42
- const tmpFileName = (0, utils_1.tmpNameSync)((0, utils_2.getCacheDir)());
41
+ const tmpFileName = (0, utils_1.tmpNameSync)(await (0, utils_2.getCacheDir)());
43
42
  fs.outputFileSync(tmpFileName, this.script);
44
43
  this.isRunning = true;
45
44
  // Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
@@ -51,7 +50,8 @@ class ControllableScript {
51
50
  args.push(`--inspect=${this.debugInfo.port}`);
52
51
  }
53
52
  }
54
- this.process = execa.node(tmpFileName, args, {
53
+ const { execaNode } = await import('execa');
54
+ this.process = execaNode(tmpFileName, args, {
55
55
  env: {
56
56
  ...process.env,
57
57
  },
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.tmpNameSync = void 0;
26
+ exports.tmpNameSync = tmpNameSync;
27
27
  const crypto = __importStar(require("node:crypto"));
28
28
  const path = __importStar(require("node:path"));
29
29
  const fs = __importStar(require("fs-extra"));
@@ -61,4 +61,3 @@ function tmpNameSync(tmpDir, retries = 3) {
61
61
  } while (tries-- > 0);
62
62
  throw new Error('Could not get a unique tmp filename, max tries reached');
63
63
  }
64
- exports.tmpNameSync = tmpNameSync;
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.normalizeConfig = exports.getProjectConfig = void 0;
29
+ exports.getProjectConfig = getProjectConfig;
30
+ exports.normalizeConfig = normalizeConfig;
30
31
  const path = __importStar(require("node:path"));
31
32
  const lodash_1 = __importDefault(require("lodash"));
32
33
  const cosmiconfig_1 = require("cosmiconfig");
@@ -102,6 +103,13 @@ async function getProjectConfig(command, { env, storybook, ...argv }) {
102
103
  else {
103
104
  cfg = explorer.search();
104
105
  }
106
+ const config = { verbose: false, ...(await cfg?.config) };
107
+ if ((0, models_1.isLibraryConfig)(config)) {
108
+ return normalizeConfig({
109
+ ...config,
110
+ ...omitUndefined({ verbose: argv.verbose }),
111
+ });
112
+ }
105
113
  const client = {
106
114
  analyzeBundle: argv.analyzeBundle,
107
115
  disableForkTsChecker: argv.disableForkTsChecker,
@@ -115,13 +123,6 @@ async function getProjectConfig(command, { env, storybook, ...argv }) {
115
123
  inspect: argv.inspect,
116
124
  inspectBrk: argv.inspectBrk,
117
125
  };
118
- const config = { verbose: false, ...(await cfg?.config) };
119
- if ((0, models_1.isLibraryConfig)(config)) {
120
- return normalizeConfig({
121
- ...config,
122
- ...omitUndefined({ verbose: argv.verbose }),
123
- });
124
- }
125
126
  const projectConfig = {
126
127
  ...config,
127
128
  ...omitUndefined({ target: argv.target, verbose: argv.verbose }),
@@ -138,48 +139,75 @@ async function getProjectConfig(command, { env, storybook, ...argv }) {
138
139
  };
139
140
  return normalizeConfig(projectConfig, command);
140
141
  }
141
- exports.getProjectConfig = getProjectConfig;
142
142
  async function normalizeConfig(userConfig, mode) {
143
143
  if ((0, models_1.isServiceConfig)(userConfig)) {
144
- const config = lodash_1.default.cloneDeep(userConfig);
145
- const client = typeof config.client === 'object' ? config.client : (config.client = {});
146
- await normalizeClientConfig(client, mode);
144
+ const clientConfig = typeof userConfig.client === 'object' ? userConfig.client : {};
145
+ const client = await normalizeClientConfig(clientConfig, mode);
147
146
  client.verbose = userConfig.verbose;
148
- const server = typeof config.server === 'object' ? config.server : (config.server = {});
149
- server.watch = server.watch && remapPaths(server.watch);
150
- server.verbose = userConfig.verbose;
147
+ const serverConfig = typeof userConfig.server === 'object' ? userConfig.server : {};
148
+ const server = {
149
+ ...serverConfig,
150
+ watch: serverConfig.watch && remapPaths(serverConfig.watch),
151
+ verbose: userConfig.verbose,
152
+ port: undefined,
153
+ inspect: undefined,
154
+ inspectBrk: undefined,
155
+ };
151
156
  if (mode === 'dev') {
152
- if (server.port === true) {
157
+ if (serverConfig.port === true) {
153
158
  server.port = await (0, utils_1.getPort)({ port: 3000 });
154
159
  }
160
+ else {
161
+ server.port = serverConfig.port;
162
+ }
163
+ if (serverConfig.inspect !== undefined) {
164
+ server.inspect = serverConfig.inspect === true ? 9229 : serverConfig.inspect;
165
+ }
166
+ if (serverConfig.inspectBrk !== undefined) {
167
+ server.inspectBrk =
168
+ serverConfig.inspectBrk === true ? 9229 : serverConfig.inspectBrk;
169
+ }
155
170
  }
171
+ const config = {
172
+ ...userConfig,
173
+ client,
174
+ server,
175
+ };
156
176
  return config;
157
177
  }
158
178
  const config = lodash_1.default.cloneDeep(userConfig);
159
179
  config.lib.newJsxTransform = config.lib.newJsxTransform ?? true;
160
180
  return config;
161
181
  }
162
- exports.normalizeConfig = normalizeConfig;
163
182
  async function normalizeClientConfig(client, mode) {
164
- client.newJsxTransform = client.newJsxTransform ?? true;
165
- client.publicPathPrefix = client.publicPathPrefix || '';
166
- client.modules = client.modules && remapPaths(client.modules);
167
- client.includes = client.includes && remapPaths(client.includes);
168
- client.images = client.images && remapPaths(client.images);
169
- client.hiddenSourceMap = client.hiddenSourceMap ?? true;
170
- client.svgr = client.svgr ?? {};
171
- client.entryFilter = client.entryFilter && splitPaths(client.entryFilter);
172
- client.webpack = typeof client.webpack === 'function' ? client.webpack : (config) => config;
173
- client.babel = typeof client.babel === 'function' ? client.babel : (config) => config;
183
+ const normalizedConfig = {
184
+ ...client,
185
+ forkTsChecker: client.disableForkTsChecker ? false : client.forkTsChecker,
186
+ newJsxTransform: client.newJsxTransform ?? true,
187
+ publicPathPrefix: client.publicPathPrefix || '',
188
+ modules: client.modules && remapPaths(client.modules),
189
+ includes: client.includes && remapPaths(client.includes),
190
+ images: client.images && remapPaths(client.images),
191
+ hiddenSourceMap: client.hiddenSourceMap ?? true,
192
+ svgr: client.svgr ?? {},
193
+ entryFilter: client.entryFilter && splitPaths(client.entryFilter),
194
+ webpack: typeof client.webpack === 'function' ? client.webpack : (config) => config,
195
+ babel: typeof client.babel === 'function' ? client.babel : (config) => config,
196
+ devServer: undefined,
197
+ lazyCompilation: undefined,
198
+ };
174
199
  if (mode === 'dev') {
175
200
  if (client.lazyCompilation) {
176
201
  if (client.lazyCompilation === true) {
177
- client.lazyCompilation = {
202
+ normalizedConfig.lazyCompilation = {
178
203
  port: await (0, utils_1.getPort)({ port: 6000 }),
179
204
  };
180
205
  }
181
- else if (!client.lazyCompilation.port) {
182
- client.lazyCompilation.port = await (0, utils_1.getPort)({ port: 6000 });
206
+ else {
207
+ normalizedConfig.lazyCompilation = client.lazyCompilation;
208
+ }
209
+ if (!normalizedConfig.lazyCompilation.port) {
210
+ normalizedConfig.lazyCompilation.port = await (0, utils_1.getPort)({ port: 6000 });
183
211
  }
184
212
  }
185
213
  const devServer = client.devServer?.port
@@ -191,7 +219,7 @@ async function normalizeClientConfig(client, mode) {
191
219
  }
192
220
  : { port: undefined, ipc: client.devServer?.ipc };
193
221
  const { type, options, ...other } = client.devServer ?? {};
194
- client.devServer = {
222
+ normalizedConfig.devServer = {
195
223
  ...other,
196
224
  ...devServer,
197
225
  server: {
@@ -199,10 +227,7 @@ async function normalizeClientConfig(client, mode) {
199
227
  options,
200
228
  },
201
229
  };
202
- delete client.cdn;
203
- }
204
- else {
205
- delete client.devServer;
206
- delete client.lazyCompilation;
230
+ delete normalizedConfig.cdn;
207
231
  }
232
+ return normalizedConfig;
208
233
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable no-param-reassign */
3
4
  const helper_plugin_utils_1 = require("@babel/helper-plugin-utils");
4
5
  const svgPathRe = /^\.\.\/(.*)\/assets\/(.*)\.svg$/;
5
6
  exports.default = (0, helper_plugin_utils_1.declare)(function (api) {
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.buildLibrary = void 0;
29
+ exports.buildLibrary = buildLibrary;
30
30
  const path = __importStar(require("node:path"));
31
31
  const fs = __importStar(require("node:fs"));
32
32
  const childProcess = __importStar(require("node:child_process"));
@@ -334,4 +334,3 @@ function buildLibrary(config) {
334
334
  copyToCjs(file, paths_1.default.src);
335
335
  });
336
336
  }
337
- exports.buildLibrary = buildLibrary;
@@ -1,12 +1,12 @@
1
1
  import chalk from 'chalk';
2
2
  export declare const colors: chalk.Chalk & chalk.ChalkFunction & {
3
- supportsColor: false | chalk.ColorSupport;
3
+ supportsColor: chalk.ColorSupport | false;
4
4
  Level: chalk.Level;
5
5
  Color: ("black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright");
6
6
  ForegroundColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
7
7
  BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright";
8
8
  Modifiers: "bold" | "reset" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "visible";
9
9
  stderr: chalk.Chalk & {
10
- supportsColor: false | chalk.ColorSupport;
10
+ supportsColor: chalk.ColorSupport | false;
11
11
  };
12
12
  };
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- import type { ExecException } from 'child_process';
3
1
  export interface BaseLogger {
4
2
  message: (msg: string) => void;
5
3
  warning: (msg: string) => void;
@@ -9,14 +7,14 @@ export interface BaseLogger {
9
7
  }
10
8
  export declare class Logger implements BaseLogger {
11
9
  colors: import("chalk").Chalk & import("chalk").ChalkFunction & {
12
- supportsColor: false | import("chalk").ColorSupport;
10
+ supportsColor: import("chalk").ColorSupport | false;
13
11
  Level: import("chalk").Level;
14
12
  Color: ("black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright");
15
13
  ForegroundColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
16
14
  BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright";
17
15
  Modifiers: "bold" | "reset" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "visible";
18
16
  stderr: import("chalk").Chalk & {
19
- supportsColor: false | import("chalk").ColorSupport;
17
+ supportsColor: import("chalk").ColorSupport | false;
20
18
  };
21
19
  };
22
20
  private _verbose;
@@ -37,8 +35,8 @@ export declare class Logger implements BaseLogger {
37
35
  success: (...args: string[]) => void;
38
36
  warning: (...args: string[]) => void;
39
37
  error: (...args: string[]) => void;
40
- logError: (errorMeta: string, error?: Error | ExecException | null) => void;
41
- panic: (errorMeta: string, error?: Error) => never;
38
+ logError: (errorMeta: string, error?: unknown) => void;
39
+ panic: (errorMeta: string, error?: unknown) => never;
42
40
  setVerbose: (verbose: boolean) => void;
43
41
  get isVerbose(): boolean;
44
42
  verbose: (...args: string[]) => void;