@gravity-ui/app-builder 0.5.6 → 0.6.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/gravity-ui/app-builder/compare/v0.5.6...v0.6.0) (2023-07-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add caching to worker loader ([#48](https://github.com/gravity-ui/app-builder/issues/48)) ([c7db4fb](https://github.com/gravity-ui/app-builder/commit/c7db4fb2786729a173e5fbe0f62c679639b9a99a))
|
|
9
|
+
|
|
3
10
|
## [0.5.6](https://github.com/gravity-ui/app-builder/compare/v0.5.5...v0.5.6) (2023-07-21)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -22,15 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.ControllableScript = void 0;
|
|
30
27
|
const utils_1 = require("./utils");
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
28
|
const fs = __importStar(require("fs-extra"));
|
|
33
29
|
const execa = __importStar(require("execa"));
|
|
30
|
+
const utils_2 = require("../utils");
|
|
34
31
|
class ControllableScript {
|
|
35
32
|
constructor(script, debugInfo) {
|
|
36
33
|
this.isRunning = false;
|
|
@@ -41,7 +38,7 @@ class ControllableScript {
|
|
|
41
38
|
}
|
|
42
39
|
start() {
|
|
43
40
|
const args = [];
|
|
44
|
-
this.tmpFileName = (0, utils_1.tmpNameSync)(
|
|
41
|
+
this.tmpFileName = (0, utils_1.tmpNameSync)((0, utils_2.getCacheDir)());
|
|
45
42
|
fs.outputFileSync(this.tmpFileName, this.script);
|
|
46
43
|
this.isRunning = true;
|
|
47
44
|
// Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
|
package/dist/common/utils.d.ts
CHANGED
package/dist/common/utils.js
CHANGED
|
@@ -3,8 +3,10 @@ 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.shouldCompileTarget = exports.createRunFolder = void 0;
|
|
6
|
+
exports.getCacheDir = exports.shouldCompileTarget = exports.createRunFolder = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const find_cache_dir_1 = __importDefault(require("find-cache-dir"));
|
|
8
10
|
const paths_1 = __importDefault(require("./paths"));
|
|
9
11
|
function createRunFolder() {
|
|
10
12
|
const runPath = paths_1.default.appRun;
|
|
@@ -17,3 +19,7 @@ function shouldCompileTarget(target, targetName) {
|
|
|
17
19
|
return target === undefined || target === targetName;
|
|
18
20
|
}
|
|
19
21
|
exports.shouldCompileTarget = shouldCompileTarget;
|
|
22
|
+
function getCacheDir() {
|
|
23
|
+
return (0, find_cache_dir_1.default)({ name: '@gravity-ui/app-builder', create: true }) || os_1.default.tmpdir();
|
|
24
|
+
}
|
|
25
|
+
exports.getCacheDir = getCacheDir;
|
|
@@ -11,6 +11,7 @@ const WebWorkerTemplatePlugin_1 = __importDefault(require("webpack/lib/webworker
|
|
|
11
11
|
const FetchCompileWasmPlugin_1 = __importDefault(require("webpack/lib/web/FetchCompileWasmPlugin"));
|
|
12
12
|
const FetchCompileAsyncWasmPlugin_1 = __importDefault(require("webpack/lib/web/FetchCompileAsyncWasmPlugin"));
|
|
13
13
|
const paths_1 = __importDefault(require("../../paths"));
|
|
14
|
+
const pluginId = 'APP_BUILDER_WORKER_LOADER';
|
|
14
15
|
const publicPath = node_path_1.default.resolve(__dirname, 'public-path.worker.js');
|
|
15
16
|
const pitch = function (request) {
|
|
16
17
|
this.cacheable(false);
|
|
@@ -18,7 +19,7 @@ const pitch = function (request) {
|
|
|
18
19
|
throw new Error('Something went wrong');
|
|
19
20
|
}
|
|
20
21
|
const compilerOptions = this._compiler.options;
|
|
21
|
-
const logger = this.getLogger(
|
|
22
|
+
const logger = this.getLogger(pluginId);
|
|
22
23
|
if (compilerOptions.output.globalObject === 'window') {
|
|
23
24
|
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
25
|
}
|
|
@@ -67,23 +68,39 @@ const pitch = function (request) {
|
|
|
67
68
|
.join('\n');
|
|
68
69
|
return cb(new Error('Child compilation failed:\n' + errorDetails));
|
|
69
70
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
sourceMap.sources = sourceMap.sources.map((pathname) => pathname.replace(/webpack:\/\/[^/]+\//, 'webpack://'));
|
|
71
|
+
const cache = workerCompiler.getCache(pluginId);
|
|
72
|
+
const cacheIdent = request;
|
|
73
|
+
const cacheETag = cache.getLazyHashedEtag(compilation.assets[filename]);
|
|
74
|
+
return cache.get(cacheIdent, cacheETag, (getCacheError, cacheContent) => {
|
|
75
|
+
if (getCacheError) {
|
|
76
|
+
return cb(getCacheError);
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
for (const [assetName, asset] of Object.entries(compilation.assets)) {
|
|
81
|
-
if ([filename, mapFile].includes(assetName)) {
|
|
82
|
-
continue;
|
|
78
|
+
if (cacheContent) {
|
|
79
|
+
return cb(null, cacheContent.content, cacheContent.map);
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const content = compilation.assets[filename]?.source();
|
|
82
|
+
const mapFile = `${filename}.map`;
|
|
83
|
+
let map = compilation.assets[mapFile]?.source();
|
|
84
|
+
if (map) {
|
|
85
|
+
const sourceMap = JSON.parse(map.toString());
|
|
86
|
+
if (Array.isArray(sourceMap.sources)) {
|
|
87
|
+
sourceMap.sources = sourceMap.sources.map((pathname) => pathname.replace(/webpack:\/\/[^/]+\//, 'webpack://'));
|
|
88
|
+
}
|
|
89
|
+
map = JSON.stringify(sourceMap);
|
|
90
|
+
}
|
|
91
|
+
for (const [assetName, asset] of Object.entries(compilation.assets)) {
|
|
92
|
+
if ([filename, mapFile].includes(assetName)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
workerCompiler.parentCompilation?.emitAsset(assetName, asset, compilation.assetsInfo.get(assetName));
|
|
96
|
+
}
|
|
97
|
+
return cache.store(cacheIdent, cacheETag, { content, map: map?.toString() }, (storeCacheError) => {
|
|
98
|
+
if (storeCacheError) {
|
|
99
|
+
return cb(storeCacheError);
|
|
100
|
+
}
|
|
101
|
+
return cb(null, content, map?.toString());
|
|
102
|
+
});
|
|
103
|
+
});
|
|
87
104
|
});
|
|
88
105
|
};
|
|
89
106
|
exports.pitch = pitch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"execa": "^5.1.1",
|
|
88
88
|
"fast-glob": "^3.2.12",
|
|
89
89
|
"file-type": "^16.5.3",
|
|
90
|
+
"find-cache-dir": "^3.3.2",
|
|
90
91
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
91
92
|
"fs-extra": "^11.1.1",
|
|
92
93
|
"get-port": "^5.1.1",
|
|
@@ -133,6 +134,7 @@
|
|
|
133
134
|
"@gravity-ui/tsconfig": "^1.0.0",
|
|
134
135
|
"@types/circular-dependency-plugin": "^5.0.5",
|
|
135
136
|
"@types/common-tags": "^1.8.1",
|
|
137
|
+
"@types/find-cache-dir": "^3.2.1",
|
|
136
138
|
"@types/fs-extra": "^11.0.1",
|
|
137
139
|
"@types/jest": "^29.5.2",
|
|
138
140
|
"@types/lodash": "^4.14.195",
|