@gravity-ui/app-builder 0.30.0 → 0.30.1

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 (58) hide show
  1. package/dist/cli.js +20 -15
  2. package/dist/commands/build/build-lib.js +8 -5
  3. package/dist/commands/build/build-service/client.js +6 -3
  4. package/dist/commands/build/build-service/index.js +7 -4
  5. package/dist/commands/build/build-service/server.js +17 -11
  6. package/dist/commands/build/index.js +6 -3
  7. package/dist/commands/dev/client.js +63 -34
  8. package/dist/commands/dev/index.js +50 -21
  9. package/dist/commands/dev/server.js +42 -13
  10. package/dist/common/babel/index.js +4 -1
  11. package/dist/common/babel/ui-preset.d.ts +1 -1
  12. package/dist/common/babel/ui-preset.js +1 -0
  13. package/dist/common/child-process/controllable-script.js +32 -5
  14. package/dist/common/child-process/utils.js +30 -4
  15. package/dist/common/command.js +2 -1
  16. package/dist/common/config.js +49 -19
  17. package/dist/common/env.js +5 -3
  18. package/dist/common/library/babel-plugin-replace-paths.js +4 -2
  19. package/dist/common/library/index.js +95 -66
  20. package/dist/common/logger/colors.js +8 -2
  21. package/dist/common/logger/index.js +24 -17
  22. package/dist/common/logger/log-config.js +6 -3
  23. package/dist/common/logger/pretty-time.js +6 -2
  24. package/dist/common/models/index.d.ts +1 -1
  25. package/dist/common/models/index.js +8 -3
  26. package/dist/common/paths.js +28 -3
  27. package/dist/common/s3-upload/compress.js +12 -8
  28. package/dist/common/s3-upload/create-plugin.js +30 -4
  29. package/dist/common/s3-upload/index.js +9 -3
  30. package/dist/common/s3-upload/s3-client.js +37 -11
  31. package/dist/common/s3-upload/upload.js +38 -9
  32. package/dist/common/s3-upload/webpack-plugin.js +9 -5
  33. package/dist/common/swc/compile.js +12 -9
  34. package/dist/common/swc/index.js +7 -2
  35. package/dist/common/swc/utils.js +13 -6
  36. package/dist/common/swc/watch.js +9 -6
  37. package/dist/common/typescript/compile.js +14 -11
  38. package/dist/common/typescript/diagnostic.js +37 -11
  39. package/dist/common/typescript/transformers.js +29 -3
  40. package/dist/common/typescript/utils.js +18 -8
  41. package/dist/common/typescript/watch.js +13 -10
  42. package/dist/common/utils.js +25 -14
  43. package/dist/common/webpack/compile.js +22 -16
  44. package/dist/common/webpack/config.js +113 -80
  45. package/dist/common/webpack/node-externals.js +34 -5
  46. package/dist/common/webpack/progress-plugin.js +6 -3
  47. package/dist/common/webpack/public-path.d.ts +1 -0
  48. package/dist/common/webpack/public-path.js +1 -0
  49. package/dist/common/webpack/rspack.js +5 -1
  50. package/dist/common/webpack/runtime-versioning-plugin.js +3 -1
  51. package/dist/common/webpack/storybook.js +51 -21
  52. package/dist/common/webpack/utils.js +36 -9
  53. package/dist/common/webpack/worker/public-path.worker.d.ts +1 -0
  54. package/dist/common/webpack/worker/public-path.worker.js +1 -0
  55. package/dist/common/webpack/worker/worker-loader.js +34 -4
  56. package/dist/create-cli.js +48 -19
  57. package/dist/index.js +27 -5
  58. package/package.json +1 -2
package/dist/cli.js CHANGED
@@ -1,22 +1,27 @@
1
1
  #!/usr/bin/env node
2
- import semver from 'semver';
3
- import util from 'util';
4
- import { stripIndent } from 'common-tags';
5
- import './common/env';
6
- import logger from './common/logger';
7
- import { createCli } from './create-cli';
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const semver_1 = __importDefault(require("semver"));
8
+ const util_1 = __importDefault(require("util"));
9
+ const common_tags_1 = require("common-tags");
10
+ require("./common/env");
11
+ const logger_1 = __importDefault(require("./common/logger"));
12
+ const create_cli_1 = require("./create-cli");
8
13
  const MIN_NODE_VERSION = '18.0.0';
9
14
  const { version } = process;
10
- if (!semver.satisfies(version, `>=${MIN_NODE_VERSION}`, {
15
+ if (!semver_1.default.satisfies(version, `>=${MIN_NODE_VERSION}`, {
11
16
  includePrerelease: true,
12
17
  })) {
13
- logger.panic(stripIndent `
18
+ logger_1.default.panic((0, common_tags_1.stripIndent) `
14
19
  App-builder requires Node.js ${MIN_NODE_VERSION} or higher (you have ${version}).
15
20
  Upgrade Node to the latest stable release.
16
21
  `);
17
22
  }
18
- if (semver.prerelease(version)) {
19
- logger.warning(stripIndent `
23
+ if (semver_1.default.prerelease(version)) {
24
+ logger_1.default.warning((0, common_tags_1.stripIndent) `
20
25
  You are currently using a prerelease version of Node (${version}), which is not supported.
21
26
  You can use this for testing, but we do not recommend it in production.
22
27
  Before reporting any bugs, please test with a supported version of Node (>=${MIN_NODE_VERSION}).
@@ -27,13 +32,13 @@ process.on('unhandledRejection', (reason) => {
27
32
  // across versions and crash
28
33
  // reason can be anything, it can be a message, an object, ANYTHING!
29
34
  // we convert it to an error object
30
- const error = reason instanceof Error ? reason : new Error(util.format(reason));
31
- logger.panic('UNHANDLED REJECTION', error);
35
+ const error = reason instanceof Error ? reason : new Error(util_1.default.format(reason));
36
+ logger_1.default.panic('UNHANDLED REJECTION', error);
32
37
  });
33
38
  process.on('uncaughtException', (error) => {
34
- logger.panic('UNHANDLED EXCEPTION', error);
39
+ logger_1.default.panic('UNHANDLED EXCEPTION', error);
35
40
  });
36
41
  process.on('exit', (code) => {
37
- logger.message(`Exit with code: ${code}`);
42
+ logger_1.default.message(`Exit with code: ${code}`);
38
43
  });
39
- createCli(process.argv);
44
+ (0, create_cli_1.createCli)(process.argv);
@@ -1,8 +1,11 @@
1
- import { onExit } from 'signal-exit';
2
- import { ControllableScript } from '../../common/child-process/controllable-script';
3
- export default function (config) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const signal_exit_1 = require("signal-exit");
5
+ const controllable_script_1 = require("../../common/child-process/controllable-script");
6
+ function default_1(config) {
4
7
  return new Promise((resolve, reject) => {
5
- const build = new ControllableScript(`
8
+ const build = new controllable_script_1.ControllableScript(`
6
9
  const {buildLibrary} = require(${JSON.stringify(require.resolve('../../common/library'))});
7
10
  buildLibrary({lib: ${JSON.stringify(config.lib)}});
8
11
  `, null);
@@ -23,7 +26,7 @@ export default function (config) {
23
26
  await build.stop('SIGTERM');
24
27
  process.exit(1);
25
28
  });
26
- onExit((_code, signal) => {
29
+ (0, signal_exit_1.onExit)((_code, signal) => {
27
30
  build.stop(signal);
28
31
  });
29
32
  }, (error) => {
@@ -1,4 +1,7 @@
1
- import { clientCompile } from '../../../common/webpack/compile';
2
- export function buildClient(config) {
3
- return clientCompile(config.client, config.configPath);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildClient = buildClient;
4
+ const compile_1 = require("../../../common/webpack/compile");
5
+ function buildClient(config) {
6
+ return (0, compile_1.clientCompile)(config.client, config.configPath);
4
7
  }
@@ -1,7 +1,10 @@
1
- import { shouldCompileTarget } from '../../../common/utils';
2
- export default function (config) {
3
- const shouldCompileClient = shouldCompileTarget(config.target, 'client');
4
- const shouldCompileServer = shouldCompileTarget(config.target, 'server');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const utils_1 = require("../../../common/utils");
5
+ function default_1(config) {
6
+ const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
7
+ const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
5
8
  const compilations = [];
6
9
  if (shouldCompileClient) {
7
10
  compilations.push((async () => {
@@ -1,7 +1,13 @@
1
- import { onExit } from 'signal-exit';
2
- import { ControllableScript } from '../../../common/child-process/controllable-script';
3
- import paths from '../../../common/paths';
4
- import { createRunFolder } from '../../../common/utils';
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildServer = buildServer;
7
+ const signal_exit_1 = require("signal-exit");
8
+ const controllable_script_1 = require("../../../common/child-process/controllable-script");
9
+ const paths_1 = __importDefault(require("../../../common/paths"));
10
+ const utils_1 = require("../../../common/utils");
5
11
  function createSWCBuildScript(config) {
6
12
  return `
7
13
  const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logger'))});
@@ -10,8 +16,8 @@ const {compile} = require(${JSON.stringify(require.resolve('../../../common/swc/
10
16
  const logger = new Logger('server', ${config.verbose});
11
17
  compile({
12
18
  logger,
13
- outputPath: ${JSON.stringify(paths.appDist)},
14
- projectPath: ${JSON.stringify(paths.appServer)},
19
+ outputPath: ${JSON.stringify(paths_1.default.appDist)},
20
+ projectPath: ${JSON.stringify(paths_1.default.appServer)},
15
21
  });`;
16
22
  }
17
23
  function createTypescriptBuildScript(config) {
@@ -29,12 +35,12 @@ const {Logger} = require(${JSON.stringify(require.resolve('../../../common/logge
29
35
  const {compile} = require(${JSON.stringify(require.resolve('../../../common/typescript/compile'))});
30
36
 
31
37
  const logger = new Logger('server', ${config.verbose});
32
- compile(ts, {logger, projectPath: ${JSON.stringify(paths.appServer)}});`;
38
+ compile(ts, {logger, projectPath: ${JSON.stringify(paths_1.default.appServer)}});`;
33
39
  }
34
- export function buildServer(config) {
35
- createRunFolder(config);
40
+ function buildServer(config) {
41
+ (0, utils_1.createRunFolder)(config);
36
42
  return new Promise((resolve, reject) => {
37
- const build = new ControllableScript(config.server.compiler === 'swc'
43
+ const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
38
44
  ? createSWCBuildScript(config)
39
45
  : createTypescriptBuildScript(config), null);
40
46
  build.start().then(() => {
@@ -54,7 +60,7 @@ export function buildServer(config) {
54
60
  await build.stop('SIGTERM');
55
61
  process.exit(1);
56
62
  });
57
- onExit((_code, signal) => {
63
+ (0, signal_exit_1.onExit)((_code, signal) => {
58
64
  build.stop(signal);
59
65
  });
60
66
  }, (error) => {
@@ -1,7 +1,10 @@
1
- import { isLibraryConfig } from '../../common/models';
2
- export default async function (config) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const models_1 = require("../../common/models");
5
+ async function default_1(config) {
3
6
  process.env.NODE_ENV = 'production';
4
7
  // eslint-disable-next-line security/detect-non-literal-require
5
- const { default: build } = require(isLibraryConfig(config) ? './build-lib' : './build-service');
8
+ const { default: build } = require((0, models_1.isLibraryConfig)(config) ? './build-lib' : './build-service');
6
9
  return build(config);
7
10
  }
@@ -1,17 +1,46 @@
1
- import * as path from 'node:path';
2
- import * as fs from 'node:fs';
3
- import webpack from 'webpack';
4
- import WebpackDevServer from 'webpack-dev-server';
5
- import { getCompilerHooks } from 'webpack-manifest-plugin';
6
- import WebpackAssetsManifest from 'webpack-assets-manifest';
7
- import { deferredPromise, getAppRunPath } from '../../common/utils';
8
- import { getCompilerHooks as getRspackCompilerHooks } from 'rspack-manifest-plugin';
9
- import { rspack, } from '@rspack/core';
10
- import { RspackDevServer } from '@rspack/dev-server';
11
- import paths from '../../common/paths';
12
- import { Logger } from '../../common/logger';
13
- import { rspackConfigFactory, webpackConfigFactory } from '../../common/webpack/config';
14
- export async function watchClientCompilation(config, onManifestReady) {
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.watchClientCompilation = watchClientCompilation;
30
+ const path = __importStar(require("node:path"));
31
+ const fs = __importStar(require("node:fs"));
32
+ const webpack_1 = __importDefault(require("webpack"));
33
+ const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
34
+ const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
35
+ const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
36
+ const utils_1 = require("../../common/utils");
37
+ const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
38
+ const core_1 = require("@rspack/core");
39
+ const dev_server_1 = require("@rspack/dev-server");
40
+ const paths_1 = __importDefault(require("../../common/paths"));
41
+ const logger_1 = require("../../common/logger");
42
+ const config_1 = require("../../common/webpack/config");
43
+ async function watchClientCompilation(config, onManifestReady) {
15
44
  const clientCompilation = await buildDevServer(config);
16
45
  const compiler = clientCompilation.compiler;
17
46
  subscribeToManifestReadyEvent(compiler, onManifestReady);
@@ -19,7 +48,7 @@ export async function watchClientCompilation(config, onManifestReady) {
19
48
  }
20
49
  async function buildDevServer(config) {
21
50
  const bundler = config.client.bundler;
22
- const logger = new Logger('client', config.verbose);
51
+ const logger = new logger_1.Logger('client', config.verbose);
23
52
  const { publicPath } = config.client;
24
53
  const { webSocketPath = path.normalize(`/${publicPath}/sockjs-node`), writeToDisk, ...devServer } = config.client.devServer || {};
25
54
  const normalizedConfig = { ...config.client, devServer: { ...devServer, webSocketPath } };
@@ -28,7 +57,7 @@ async function buildDevServer(config) {
28
57
  let rspackConfigs = [];
29
58
  if (bundler === 'webpack') {
30
59
  webpackConfigs = [
31
- await webpackConfigFactory({
60
+ await (0, config_1.webpackConfigFactory)({
32
61
  webpackMode: "development" /* WebpackMode.Dev */,
33
62
  config: normalizedConfig,
34
63
  configPath: config.configPath,
@@ -36,8 +65,8 @@ async function buildDevServer(config) {
36
65
  }),
37
66
  ];
38
67
  if (isSsr) {
39
- const ssrLogger = new Logger('client(SSR)', config.verbose);
40
- webpackConfigs.push(await webpackConfigFactory({
68
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
69
+ webpackConfigs.push(await (0, config_1.webpackConfigFactory)({
41
70
  webpackMode: "development" /* WebpackMode.Dev */,
42
71
  config: normalizedConfig,
43
72
  configPath: config.configPath,
@@ -48,7 +77,7 @@ async function buildDevServer(config) {
48
77
  }
49
78
  else {
50
79
  rspackConfigs = [
51
- await rspackConfigFactory({
80
+ await (0, config_1.rspackConfigFactory)({
52
81
  webpackMode: "development" /* WebpackMode.Dev */,
53
82
  config: normalizedConfig,
54
83
  configPath: config.configPath,
@@ -56,8 +85,8 @@ async function buildDevServer(config) {
56
85
  }),
57
86
  ];
58
87
  if (isSsr) {
59
- const ssrLogger = new Logger('client(SSR)', config.verbose);
60
- rspackConfigs.push(await rspackConfigFactory({
88
+ const ssrLogger = new logger_1.Logger('client(SSR)', config.verbose);
89
+ rspackConfigs.push(await (0, config_1.rspackConfigFactory)({
61
90
  webpackMode: "development" /* WebpackMode.Dev */,
62
91
  config: normalizedConfig,
63
92
  configPath: config.configPath,
@@ -69,14 +98,14 @@ async function buildDevServer(config) {
69
98
  // Rspack multicompiler dont work with lazy compilation.
70
99
  // Pass a single config to avoid multicompiler when SSR disabled.
71
100
  const compiler = bundler === 'rspack'
72
- ? rspack(isSsr ? rspackConfigs : rspackConfigs[0])
73
- : webpack(webpackConfigs);
74
- const staticFolder = path.resolve(paths.appDist, 'public');
101
+ ? (0, core_1.rspack)(isSsr ? rspackConfigs : rspackConfigs[0])
102
+ : (0, webpack_1.default)(webpackConfigs);
103
+ const staticFolder = path.resolve(paths_1.default.appDist, 'public');
75
104
  const options = {
76
105
  static: staticFolder,
77
106
  setupMiddlewares(middlewares) {
78
107
  if (config.client.lazyCompilation && bundler === 'rspack') {
79
- const lazyCompilationMiddleware = rspack.experiments.lazyCompilationMiddleware(compiler, rspackConfigs[0]?.experiments?.lazyCompilation);
108
+ const lazyCompilationMiddleware = core_1.rspack.experiments.lazyCompilationMiddleware(compiler, rspackConfigs[0]?.experiments?.lazyCompilation);
80
109
  return [lazyCompilationMiddleware, ...middlewares];
81
110
  }
82
111
  return middlewares;
@@ -88,7 +117,7 @@ async function buildDevServer(config) {
88
117
  if (writeToDisk === true) {
89
118
  return true;
90
119
  }
91
- if (isSsr && target.startsWith(paths.appSsrBuild)) {
120
+ if (isSsr && target.startsWith(paths_1.default.appSsrBuild)) {
92
121
  return true;
93
122
  }
94
123
  if (typeof writeToDisk === 'function') {
@@ -123,7 +152,7 @@ async function buildDevServer(config) {
123
152
  };
124
153
  const listenOn = options.port || options.ipc;
125
154
  if (!listenOn) {
126
- options.ipc = path.resolve(getAppRunPath(config), 'client.sock');
155
+ options.ipc = path.resolve((0, utils_1.getAppRunPath)(config), 'client.sock');
127
156
  }
128
157
  const proxy = options.proxy || [];
129
158
  if (config.client.lazyCompilation && bundler !== 'rspack') {
@@ -155,10 +184,10 @@ async function buildDevServer(config) {
155
184
  options.proxy = proxy;
156
185
  let server;
157
186
  if (bundler === 'rspack') {
158
- server = new RspackDevServer(options, compiler);
187
+ server = new dev_server_1.RspackDevServer(options, compiler);
159
188
  }
160
189
  else {
161
- server = new WebpackDevServer(options, compiler);
190
+ server = new webpack_dev_server_1.default(options, compiler);
162
191
  }
163
192
  try {
164
193
  await server.start();
@@ -185,21 +214,21 @@ function subscribeToManifestReadyEvent(compiler, onManifestReady) {
185
214
  throw new Error('Something goes wrong!');
186
215
  }
187
216
  if (!isRspackCompiler(currentCompiler)) {
188
- const assetsManifestPlugin = config.plugins.find((plugin) => plugin instanceof WebpackAssetsManifest);
217
+ const assetsManifestPlugin = config.plugins.find((plugin) => plugin instanceof webpack_assets_manifest_1.default);
189
218
  if (assetsManifestPlugin) {
190
- const assetsManifestReady = deferredPromise();
219
+ const assetsManifestReady = (0, utils_1.deferredPromise)();
191
220
  promises.push(assetsManifestReady.promise);
192
221
  assetsManifestPlugin.hooks.done.tap('app-builder', assetsManifestReady.resolve);
193
222
  }
194
223
  }
195
- const manifestReady = deferredPromise();
224
+ const manifestReady = (0, utils_1.deferredPromise)();
196
225
  promises.push(manifestReady.promise);
197
226
  if (isRspackCompiler(currentCompiler)) {
198
- const { afterEmit } = getRspackCompilerHooks(currentCompiler);
227
+ const { afterEmit } = (0, rspack_manifest_plugin_1.getCompilerHooks)(currentCompiler);
199
228
  afterEmit.tap('app-builder', manifestReady.resolve);
200
229
  }
201
230
  else {
202
- const { afterEmit } = getCompilerHooks(currentCompiler);
231
+ const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(currentCompiler);
203
232
  afterEmit.tap('app-builder', manifestReady.resolve);
204
233
  }
205
234
  }
@@ -1,40 +1,69 @@
1
- import * as path from 'node:path';
2
- import * as fs from 'node:fs';
3
- import nodemon from 'nodemon';
4
- import { onExit } from 'signal-exit';
5
- import { rimraf } from 'rimraf';
6
- import { getAppRunPath, shouldCompileTarget } from '../../common/utils';
7
- import logger from '../../common/logger';
8
- import paths from '../../common/paths';
9
- export default async function (config) {
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.default = default_1;
30
+ const path = __importStar(require("node:path"));
31
+ const fs = __importStar(require("node:fs"));
32
+ const nodemon_1 = __importDefault(require("nodemon"));
33
+ const signal_exit_1 = require("signal-exit");
34
+ const rimraf_1 = require("rimraf");
35
+ const utils_1 = require("../../common/utils");
36
+ const logger_1 = __importDefault(require("../../common/logger"));
37
+ const paths_1 = __importDefault(require("../../common/paths"));
38
+ async function default_1(config) {
10
39
  process.env.NODE_ENV = 'development';
11
- const shouldCompileClient = shouldCompileTarget(config.target, 'client');
12
- const shouldCompileServer = shouldCompileTarget(config.target, 'server');
13
- const appRunPath = getAppRunPath(config);
40
+ const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
41
+ const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
42
+ const appRunPath = (0, utils_1.getAppRunPath)(config);
14
43
  if (shouldCompileClient && shouldCompileServer) {
15
44
  try {
16
45
  fs.accessSync(appRunPath, fs.constants.W_OK | fs.constants.X_OK); // eslint-disable-line no-bitwise
17
- rimraf.sync(appRunPath);
46
+ rimraf_1.rimraf.sync(appRunPath);
18
47
  }
19
48
  catch (error) {
20
- logger.warning(`Failed to remove appRun path [${appRunPath}]: ${error}`);
49
+ logger_1.default.warning(`Failed to remove appRun path [${appRunPath}]: ${error}`);
21
50
  }
22
51
  }
23
52
  let clientCompiled = !shouldCompileClient;
24
53
  let serverCompiled = !shouldCompileServer;
25
54
  let needToStartNodemon = shouldCompileServer;
26
- const serverPath = path.resolve(paths.appDist, 'server');
55
+ const serverPath = path.resolve(paths_1.default.appDist, 'server');
27
56
  const { inspect, inspectBrk } = config.server;
28
57
  const startNodemon = () => {
29
58
  if (needToStartNodemon && serverCompiled && clientCompiled) {
30
- logger.message('Starting application at', serverPath);
59
+ logger_1.default.message('Starting application at', serverPath);
31
60
  const nodeArgs = ['--enable-source-maps'];
32
61
  if (inspect || inspectBrk) {
33
62
  nodeArgs.push(`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`);
34
63
  }
35
64
  const serverWatch = config.server.watch ?? [];
36
65
  const delay = config.server.watchThrottle;
37
- const nodemonInstance = nodemon({
66
+ const nodemonInstance = (0, nodemon_1.default)({
38
67
  ext: 'js json',
39
68
  script: `${serverPath}/index.js`,
40
69
  args: ['--dev', config.server.port ? `--port=${config.server.port}` : ''],
@@ -64,24 +93,24 @@ export default async function (config) {
64
93
  if (shouldCompileClient) {
65
94
  const { watchClientCompilation } = await import('./client.js');
66
95
  clientCompilation = await watchClientCompilation(config, () => {
67
- logger.success('Manifest was compiled successfully');
96
+ logger_1.default.success('Manifest was compiled successfully');
68
97
  clientCompiled = true;
69
98
  startNodemon();
70
99
  });
71
100
  }
72
101
  process.on('SIGINT', async () => {
73
- logger.success('\nCleaning up...');
102
+ logger_1.default.success('\nCleaning up...');
74
103
  await serverCompilation?.stop('SIGINT');
75
104
  await clientCompilation?.stop();
76
105
  process.exit(1);
77
106
  });
78
107
  process.on('SIGTERM', async () => {
79
- logger.success('\nCleaning up...');
108
+ logger_1.default.success('\nCleaning up...');
80
109
  await serverCompilation?.stop('SIGTERM');
81
110
  await clientCompilation?.stop();
82
111
  process.exit(1);
83
112
  });
84
- onExit((_code, signal) => {
113
+ (0, signal_exit_1.onExit)((_code, signal) => {
85
114
  serverCompilation?.stop(signal);
86
115
  clientCompilation?.stop();
87
116
  });
@@ -1,8 +1,37 @@
1
- import * as path from 'node:path';
2
- import { rimraf } from 'rimraf';
3
- import { ControllableScript } from '../../common/child-process/controllable-script';
4
- import { createRunFolder } from '../../common/utils';
5
- import paths from '../../common/paths';
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.watchServerCompilation = watchServerCompilation;
30
+ const path = __importStar(require("node:path"));
31
+ const rimraf_1 = require("rimraf");
32
+ const controllable_script_1 = require("../../common/child-process/controllable-script");
33
+ const utils_1 = require("../../common/utils");
34
+ const paths_1 = __importDefault(require("../../common/paths"));
6
35
  function createTypescriptBuildScript(config) {
7
36
  return `
8
37
  let ts;
@@ -20,7 +49,7 @@ const {watch} = require(${JSON.stringify(require.resolve('../../common/typescrip
20
49
  const logger = new Logger('server', ${config.verbose});
21
50
  watch(
22
51
  ts,
23
- ${JSON.stringify(paths.appServer)},
52
+ ${JSON.stringify(paths_1.default.appServer)},
24
53
  {
25
54
  logger,
26
55
  onAfterFilesEmitted: () => {
@@ -37,9 +66,9 @@ const {watch} = require(${JSON.stringify(require.resolve('../../common/swc/watch
37
66
 
38
67
  const logger = new Logger('server', ${config.verbose});
39
68
  watch(
40
- ${JSON.stringify(paths.appServer)},
69
+ ${JSON.stringify(paths_1.default.appServer)},
41
70
  {
42
- outputPath: ${JSON.stringify(paths.appDist)},
71
+ outputPath: ${JSON.stringify(paths_1.default.appDist)},
43
72
  logger,
44
73
  onAfterFilesEmitted: () => {
45
74
  process.send({type: 'Emitted'});
@@ -47,11 +76,11 @@ watch(
47
76
  }
48
77
  );`;
49
78
  }
50
- export async function watchServerCompilation(config) {
51
- const serverPath = path.resolve(paths.appDist, 'server');
52
- rimraf.sync(serverPath);
53
- createRunFolder(config);
54
- const build = new ControllableScript(config.server.compiler === 'swc'
79
+ async function watchServerCompilation(config) {
80
+ const serverPath = path.resolve(paths_1.default.appDist, 'server');
81
+ rimraf_1.rimraf.sync(serverPath);
82
+ (0, utils_1.createRunFolder)(config);
83
+ const build = new controllable_script_1.ControllableScript(config.server.compiler === 'swc'
55
84
  ? createSWCBuildScript(config)
56
85
  : createTypescriptBuildScript(config), null);
57
86
  await build.start();
@@ -1,4 +1,7 @@
1
- export function babelPreset(config) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.babelPreset = babelPreset;
4
+ function babelPreset(config) {
2
5
  return [
3
6
  require.resolve('./ui-preset'),
4
7
  {
@@ -1 +1 @@
1
- declare function getOption<T>(value: T, defaultValue: T): T;
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  function getOption(value, defaultValue) {
3
4
  if (typeof value === 'undefined') {
4
5
  return defaultValue;
@@ -1,7 +1,33 @@
1
- import { tmpNameSync } from './utils';
2
- import * as fs from 'fs-extra';
3
- import { getCacheDir } from '../utils';
4
- export class ControllableScript {
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ControllableScript = void 0;
27
+ const utils_1 = require("./utils");
28
+ const fs = __importStar(require("fs-extra"));
29
+ const utils_2 = require("../utils");
30
+ class ControllableScript {
5
31
  isRunning = false;
6
32
  process;
7
33
  script = '';
@@ -12,7 +38,7 @@ export class ControllableScript {
12
38
  }
13
39
  async start() {
14
40
  const args = [];
15
- const tmpFileName = tmpNameSync(await getCacheDir());
41
+ const tmpFileName = (0, utils_1.tmpNameSync)(await (0, utils_2.getCacheDir)());
16
42
  fs.outputFileSync(tmpFileName, this.script);
17
43
  this.isRunning = true;
18
44
  // Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
@@ -97,3 +123,4 @@ export class ControllableScript {
97
123
  this.process.send(msg);
98
124
  }
99
125
  }
126
+ exports.ControllableScript = ControllableScript;