@gravity-ui/app-builder 0.4.0 → 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 +15 -0
- package/dist/commands/build/build-service/index.js +0 -1
- package/dist/commands/dev/index.js +6 -2
- package/dist/commands/dev/server.js +2 -3
- package/dist/common/webpack/lazy-client.d.ts +1 -0
- package/dist/common/webpack/lazy-client.js +62 -0
- package/dist/common/webpack/worker/worker-loader.js +17 -20
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
|
|
11
|
+
## [0.4.1](https://github.com/gravity-ui/app-builder/compare/v0.4.0...v0.4.1) (2023-05-19)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **worker-loader:** correctly get main worker asset ([#22](https://github.com/gravity-ui/app-builder/issues/22)) ([31984c9](https://github.com/gravity-ui/app-builder/commit/31984c9c057a915233db3d9aed470ce6d4040db4))
|
|
17
|
+
|
|
3
18
|
## [0.4.0](https://github.com/gravity-ui/app-builder/compare/v0.3.0...v0.4.0) (2023-05-19)
|
|
4
19
|
|
|
5
20
|
|
|
@@ -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 =
|
|
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
|
|
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 =
|
|
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
|
+
};
|
|
@@ -23,12 +23,13 @@ const pitch = function (request) {
|
|
|
23
23
|
logger.warn('Warning (app-builder-worker-loader): output.globalObject is set to "window". It should be set to "self" or "this" to support HMR in Workers.');
|
|
24
24
|
}
|
|
25
25
|
const isEnvProduction = compilerOptions.mode === 'production';
|
|
26
|
-
const filename =
|
|
26
|
+
const filename = 'worker.js';
|
|
27
|
+
const chunkFilename = isEnvProduction
|
|
27
28
|
? 'js/[name].[contenthash:8].worker.js'
|
|
28
29
|
: 'js/[name].worker.js';
|
|
29
30
|
const workerOptions = {
|
|
30
31
|
filename,
|
|
31
|
-
chunkFilename
|
|
32
|
+
chunkFilename,
|
|
32
33
|
publicPath: compilerOptions.output.publicPath,
|
|
33
34
|
globalObject: 'self',
|
|
34
35
|
devtoolNamespace: node_path_1.default.resolve('/', node_path_1.default.relative(paths_1.default.app, this.resource)),
|
|
@@ -66,27 +67,23 @@ const pitch = function (request) {
|
|
|
66
67
|
.join('\n');
|
|
67
68
|
return cb(new Error('Child compilation failed:\n' + errorDetails));
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
if (Array.isArray(sourceMap.sources)) {
|
|
77
|
-
sourceMap.sources = sourceMap.sources.map((pathname) => pathname.replace(/webpack:\/\/[^/]+\//, 'webpack://'));
|
|
78
|
-
}
|
|
79
|
-
map = JSON.stringify(sourceMap);
|
|
70
|
+
const contents = compilation.assets[filename]?.source();
|
|
71
|
+
const mapFile = `${filename}.map`;
|
|
72
|
+
let map = compilation.assets[mapFile]?.source();
|
|
73
|
+
if (map) {
|
|
74
|
+
const sourceMap = JSON.parse(map.toString());
|
|
75
|
+
if (Array.isArray(sourceMap.sources)) {
|
|
76
|
+
sourceMap.sources = sourceMap.sources.map((pathname) => pathname.replace(/webpack:\/\/[^/]+\//, 'webpack://'));
|
|
80
77
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
map = JSON.stringify(sourceMap);
|
|
79
|
+
}
|
|
80
|
+
for (const [assetName, asset] of Object.entries(compilation.assets)) {
|
|
81
|
+
if ([filename, mapFile].includes(assetName)) {
|
|
82
|
+
continue;
|
|
86
83
|
}
|
|
87
|
-
|
|
84
|
+
workerCompiler.parentCompilation?.emitAsset(assetName, asset, compilation.assetsInfo.get(assetName));
|
|
88
85
|
}
|
|
89
|
-
return cb(null,
|
|
86
|
+
return cb(null, contents, map?.toString());
|
|
90
87
|
});
|
|
91
88
|
};
|
|
92
89
|
exports.pitch = pitch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.4.
|
|
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
|
|
54
|
+
"build:compile": "tsc -p tsconfig.production.json",
|
|
55
55
|
"build:clean": "rimraf dist",
|
|
56
56
|
"prepublishOnly": "npm run build"
|
|
57
57
|
},
|