@gravity-ui/app-builder 0.5.5 → 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 +19 -0
- package/README.md +2 -0
- package/dist/common/child-process/controllable-script.js +2 -5
- package/dist/common/models/index.d.ts +4 -2
- package/dist/common/utils.d.ts +1 -0
- package/dist/common/utils.js +7 -1
- package/dist/common/webpack/config.js +2 -1
- package/dist/common/webpack/worker/worker-loader.js +33 -16
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
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
|
+
|
|
10
|
+
## [0.5.6](https://github.com/gravity-ui/app-builder/compare/v0.5.5...v0.5.6) (2023-07-21)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add webpack cache option ([#47](https://github.com/gravity-ui/app-builder/issues/47)) ([fb5311a](https://github.com/gravity-ui/app-builder/commit/fb5311a5635dfc95051434fdeb878b4c34c457c2))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* make statoscope config fields optional ([#45](https://github.com/gravity-ui/app-builder/issues/45)) ([1e80938](https://github.com/gravity-ui/app-builder/commit/1e809384b3af358ed4837d57c28928a291e99a4e))
|
|
21
|
+
|
|
3
22
|
## [0.5.5](https://github.com/gravity-ui/app-builder/compare/v0.5.4...v0.5.5) (2023-07-07)
|
|
4
23
|
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -188,6 +188,8 @@ With this `{rootDir}/src/ui/tsconfig.json`:
|
|
|
188
188
|
- `entryFilter` (`string[]`) — filter used entrypoints.
|
|
189
189
|
- `excludeFromClean` (`string[]`) — do not clean provided paths before build.
|
|
190
190
|
- `forkTsCheker` (`false | ForkTsCheckerWebpackPluginOptions`) - config for ForkTsCheckerWebpackPlugin [more](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#options). If `false`, ForkTsCheckerWebpackPlugin will be disabled.
|
|
191
|
+
- `cache` (`boolean | FileCacheOptions | MemoryCacheOptions`) — Cache the generated webpack modules and chunks to improve build speed. [more](https://webpack.js.org/configuration/cache/)
|
|
192
|
+
- `babelCacheDirectory` (`boolean | string`) — Set directory for babel-loader cache (`default: node_modules/.cache/babel-loader``)
|
|
191
193
|
|
|
192
194
|
##### Dev build
|
|
193
195
|
|
|
@@ -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
|
|
@@ -2,7 +2,7 @@ import type { EditorLanguage } from 'monaco-editor-webpack-plugin/out/languages'
|
|
|
2
2
|
import type { EditorFeature } from 'monaco-editor-webpack-plugin/out/features';
|
|
3
3
|
import type { IFeatureDefinition } from 'monaco-editor-webpack-plugin/out/types';
|
|
4
4
|
import type { Options as MomentTzOptions } from 'moment-timezone-data-webpack-plugin';
|
|
5
|
-
import type { Configuration, ResolveOptions, DefinePlugin } from 'webpack';
|
|
5
|
+
import type { Configuration, ResolveOptions, DefinePlugin, FileCacheOptions, MemoryCacheOptions } from 'webpack';
|
|
6
6
|
import type { ServerConfiguration } from 'webpack-dev-server';
|
|
7
7
|
import type { Options as CircularDependenciesOptions } from 'circular-dependency-plugin';
|
|
8
8
|
import type { Config as SvgrConfig } from '@svgr/core';
|
|
@@ -126,7 +126,7 @@ export interface ClientConfig {
|
|
|
126
126
|
entryFilter?: string[];
|
|
127
127
|
excludeFromClean?: string[];
|
|
128
128
|
analyzeBundle?: 'true' | 'statoscope';
|
|
129
|
-
statoscopeConfig?: StatoscopeOptions
|
|
129
|
+
statoscopeConfig?: Partial<StatoscopeOptions>;
|
|
130
130
|
reactProfiling?: boolean;
|
|
131
131
|
/**
|
|
132
132
|
* Disable react-refresh in dev mode
|
|
@@ -165,6 +165,8 @@ export interface ClientConfig {
|
|
|
165
165
|
* use webpack 5 Web Workers [syntax](https://webpack.js.org/guides/web-workers/#syntax)
|
|
166
166
|
*/
|
|
167
167
|
newWebWorkerSyntax?: boolean;
|
|
168
|
+
babelCacheDirectory?: boolean | string;
|
|
169
|
+
cache?: boolean | FileCacheOptions | MemoryCacheOptions;
|
|
168
170
|
}
|
|
169
171
|
interface CdnUploadConfig {
|
|
170
172
|
bucket: string;
|
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;
|
|
@@ -91,6 +91,7 @@ function webpackConfigFactory(webpackMode, config, { logger } = {}) {
|
|
|
91
91
|
snapshot: {
|
|
92
92
|
managedPaths: config.watchOptions?.watchPackages ? [] : undefined,
|
|
93
93
|
},
|
|
94
|
+
cache: config.cache,
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
97
|
exports.webpackConfigFactory = webpackConfigFactory;
|
|
@@ -274,7 +275,7 @@ function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, config, })
|
|
|
274
275
|
isEnvProduction && require.resolve('babel-plugin-lodash'),
|
|
275
276
|
].filter(Boolean),
|
|
276
277
|
sourceType: 'unambiguous',
|
|
277
|
-
cacheDirectory: true,
|
|
278
|
+
cacheDirectory: config.babelCacheDirectory ? config.babelCacheDirectory : true,
|
|
278
279
|
cacheCompression: isEnvProduction,
|
|
279
280
|
compact: isEnvProduction,
|
|
280
281
|
sourceMap: !config.disableSourceMapGeneration,
|
|
@@ -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",
|