@gravity-ui/app-builder 0.4.1 → 0.4.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.2](https://github.com/gravity-ui/app-builder/compare/v0.4.1...v0.4.2) (2023-05-25)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **build:** add to build all source files ([#24](https://github.com/gravity-ui/app-builder/issues/24)) ([9dfc536](https://github.com/gravity-ui/app-builder/commit/9dfc5360786d6462b01bcb5f96c9936ece05a4eb))
9
+ * **dev:** delete run folder only on full build ([#25](https://github.com/gravity-ui/app-builder/issues/25)) ([f491489](https://github.com/gravity-ui/app-builder/commit/f491489e92583b4cbba327d7ee86ba42cd0add97))
10
+
3
11
  ## [0.4.1](https://github.com/gravity-ui/app-builder/compare/v0.4.0...v0.4.1) (2023-05-19)
4
12
 
5
13
 
@@ -40,7 +40,6 @@ function default_1(config) {
40
40
  return buildServer(config);
41
41
  })());
42
42
  }
43
- // createRunFolder();
44
43
  return Promise.all(compilations);
45
44
  }
46
45
  exports.default = default_1;
@@ -26,9 +26,10 @@ 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
+ const node_path_1 = __importDefault(require("node:path"));
29
30
  const nodemon_1 = __importDefault(require("nodemon"));
30
- const path_1 = __importDefault(require("path"));
31
31
  const signal_exit_1 = __importDefault(require("signal-exit"));
32
+ const rimraf_1 = require("rimraf");
32
33
  const utils_1 = require("../../common/utils");
33
34
  const logger_1 = __importDefault(require("../../common/logger"));
34
35
  const paths_1 = __importDefault(require("../../common/paths"));
@@ -36,10 +37,13 @@ async function default_1(config) {
36
37
  process.env.NODE_ENV = 'development';
37
38
  const shouldCompileClient = (0, utils_1.shouldCompileTarget)(config.target, 'client');
38
39
  const shouldCompileServer = (0, utils_1.shouldCompileTarget)(config.target, 'server');
40
+ if (shouldCompileClient && shouldCompileServer) {
41
+ rimraf_1.rimraf.sync(paths_1.default.appRun);
42
+ }
39
43
  let clientCompiled = !shouldCompileClient;
40
44
  let serverCompiled = !shouldCompileServer;
41
45
  let needToStartNodemon = shouldCompileServer;
42
- const serverPath = path_1.default.resolve(paths_1.default.appDist, 'server');
46
+ const serverPath = node_path_1.default.resolve(paths_1.default.appDist, 'server');
43
47
  const { inspect, inspectBrk } = config.server;
44
48
  const startNodemon = () => {
45
49
  if (needToStartNodemon && serverCompiled && clientCompiled) {
@@ -4,15 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.watchServerCompilation = void 0;
7
- const path_1 = __importDefault(require("path"));
7
+ const node_path_1 = __importDefault(require("node:path"));
8
8
  const rimraf_1 = require("rimraf");
9
9
  const controllable_script_1 = require("../../common/child-process/controllable-script");
10
10
  const utils_1 = require("../../common/utils");
11
11
  const paths_1 = __importDefault(require("../../common/paths"));
12
12
  function watchServerCompilation(config) {
13
- const serverPath = path_1.default.resolve(paths_1.default.appDist, 'server');
13
+ const serverPath = node_path_1.default.resolve(paths_1.default.appDist, 'server');
14
14
  rimraf_1.rimraf.sync(serverPath);
15
- rimraf_1.rimraf.sync(paths_1.default.appRun);
16
15
  (0, utils_1.createRunFolder)();
17
16
  const build = new controllable_script_1.ControllableScript(`
18
17
  const ts = require('typescript');
@@ -0,0 +1 @@
1
+ export function keepAlive(options: any): () => void;
@@ -0,0 +1,62 @@
1
+ /* eslint-env browser */
2
+ /* global __resourceQuery */
3
+ 'use strict';
4
+ if (typeof EventSource !== 'function') {
5
+ throw new Error("Environment doesn't support lazy compilation (requires EventSource)");
6
+ }
7
+ const urlBase = new URL(decodeURIComponent(__resourceQuery.slice(1))).pathname;
8
+ let activeEventSource;
9
+ const activeKeys = new Map();
10
+ const errorHandlers = new Set();
11
+ const updateEventSource = function updateEventSource() {
12
+ if (activeEventSource)
13
+ activeEventSource.close();
14
+ if (activeKeys.size) {
15
+ activeEventSource = new EventSource('/build/lazy' + urlBase + Array.from(activeKeys.keys()).join('@'));
16
+ activeEventSource.onerror = function (event) {
17
+ errorHandlers.forEach(function (onError) {
18
+ onError(new Error('Problem communicating active modules to the server: ' +
19
+ event.message +
20
+ ' ' +
21
+ event.filename +
22
+ ':' +
23
+ event.lineno +
24
+ ':' +
25
+ event.colno +
26
+ ' ' +
27
+ event.error));
28
+ });
29
+ };
30
+ }
31
+ else {
32
+ activeEventSource = undefined;
33
+ }
34
+ };
35
+ exports.keepAlive = function (options) {
36
+ const data = options.data;
37
+ const onError = options.onError;
38
+ const active = options.active;
39
+ const module = options.module;
40
+ errorHandlers.add(onError);
41
+ const value = activeKeys.get(data) || 0;
42
+ activeKeys.set(data, value + 1);
43
+ if (value === 0) {
44
+ updateEventSource();
45
+ }
46
+ if (!active && !module.hot) {
47
+ console.log('Hot Module Replacement is not enabled. Waiting for process restart...');
48
+ }
49
+ return function () {
50
+ errorHandlers.delete(onError);
51
+ setTimeout(function () {
52
+ const value = activeKeys.get(data);
53
+ if (value === 1) {
54
+ activeKeys.delete(data);
55
+ updateEventSource();
56
+ }
57
+ else {
58
+ activeKeys.set(data, value - 1);
59
+ }
60
+ }, 1000);
61
+ };
62
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -51,7 +51,7 @@
51
51
  "typecheck": "tsc --noEmit",
52
52
  "test": "jest",
53
53
  "build": "npm run build:clean && npm run build:compile",
54
- "build:compile": "tsc --module commonjs --verbatimModuleSyntax false",
54
+ "build:compile": "tsc -p tsconfig.production.json",
55
55
  "build:clean": "rimraf dist",
56
56
  "prepublishOnly": "npm run build"
57
57
  },