@gravity-ui/app-builder 0.6.0 → 0.6.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 +19 -0
- package/README.md +1 -0
- package/dist/common/child-process/controllable-script.d.ts +0 -1
- package/dist/common/child-process/controllable-script.js +6 -5
- package/dist/common/library/index.js +1 -0
- package/dist/common/models/index.d.ts +2 -0
- package/dist/common/s3-upload/s3-client.js +15 -4
- package/dist/common/webpack/config.js +56 -33
- package/package.json +12 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.2](https://github.com/gravity-ui/app-builder/compare/v0.6.1...v0.6.2) (2023-07-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **build-lib:** correctly transform svg icons ([#53](https://github.com/gravity-ui/app-builder/issues/53)) ([9c9d3a6](https://github.com/gravity-ui/app-builder/commit/9c9d3a626ea6375a9edf93462fe0f7b367046b16))
|
|
9
|
+
|
|
10
|
+
## [0.6.1](https://github.com/gravity-ui/app-builder/compare/v0.6.0...v0.6.1) (2023-07-24)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **css:** use Lightning CSS ([#52](https://github.com/gravity-ui/app-builder/issues/52)) ([d16cd09](https://github.com/gravity-ui/app-builder/commit/d16cd09067276eee9b0952f2c198e6e4e6365c3d))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **s3-client:** add charset to content type ([#50](https://github.com/gravity-ui/app-builder/issues/50)) ([8b1a944](https://github.com/gravity-ui/app-builder/commit/8b1a944d675e0f1b88f80fa43d0929148ce82a05))
|
|
21
|
+
|
|
3
22
|
## [0.6.0](https://github.com/gravity-ui/app-builder/compare/v0.5.6...v0.6.0) (2023-07-23)
|
|
4
23
|
|
|
5
24
|
|
package/README.md
CHANGED
|
@@ -232,6 +232,7 @@ With this `{rootDir}/src/ui/tsconfig.json`:
|
|
|
232
232
|
- `highlight.js` (`string[]`) — list of language names to include, e.g. `['javascript', 'python', 'bash']`;
|
|
233
233
|
- `locale`: (`string[]=['ru']`) — list of `moment.js` or `day.js` locales to include, e.g. `['de', 'es']`. Locale `En` is always present.
|
|
234
234
|
- `safari10` (`boolean`) — Enables `safari10` terser's option. [Terser options](https://github.com/terser/terser#minify-options)
|
|
235
|
+
- `transformCssWithLightningCss` (`boolean`) — use [Lighting CSS](https://lightningcss.dev) to transform and minimize css instead of PostCSS and cssnano
|
|
235
236
|
|
|
236
237
|
##### Monaco editor support
|
|
237
238
|
|
|
@@ -32,14 +32,13 @@ class ControllableScript {
|
|
|
32
32
|
constructor(script, debugInfo) {
|
|
33
33
|
this.isRunning = false;
|
|
34
34
|
this.script = '';
|
|
35
|
-
this.tmpFileName = '';
|
|
36
35
|
this.script = script;
|
|
37
36
|
this.debugInfo = debugInfo;
|
|
38
37
|
}
|
|
39
38
|
start() {
|
|
40
39
|
const args = [];
|
|
41
|
-
|
|
42
|
-
fs.outputFileSync(
|
|
40
|
+
const tmpFileName = (0, utils_1.tmpNameSync)((0, utils_2.getCacheDir)());
|
|
41
|
+
fs.outputFileSync(tmpFileName, this.script);
|
|
43
42
|
this.isRunning = true;
|
|
44
43
|
// Passing --inspect isn't necessary for the child process to launch a port, but it allows some editors to automatically attach
|
|
45
44
|
if (this.debugInfo) {
|
|
@@ -50,7 +49,7 @@ class ControllableScript {
|
|
|
50
49
|
args.push(`--inspect=${this.debugInfo.port}`);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
|
-
this.process = execa.node(
|
|
52
|
+
this.process = execa.node(tmpFileName, args, {
|
|
54
53
|
env: {
|
|
55
54
|
...process.env,
|
|
56
55
|
},
|
|
@@ -60,6 +59,9 @@ class ControllableScript {
|
|
|
60
59
|
this.process.on('unhandledRejection', () => {
|
|
61
60
|
this.stop('SIGABRT');
|
|
62
61
|
});
|
|
62
|
+
this.process.on('exit', () => {
|
|
63
|
+
fs.unlinkSync(tmpFileName);
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
async stop(signal = null, code) {
|
|
65
67
|
if (!this.process) {
|
|
@@ -96,7 +98,6 @@ class ControllableScript {
|
|
|
96
98
|
this.process.removeAllListeners();
|
|
97
99
|
}
|
|
98
100
|
this.process = undefined;
|
|
99
|
-
fs.unlinkSync(this.tmpFileName);
|
|
100
101
|
resolve();
|
|
101
102
|
});
|
|
102
103
|
});
|
|
@@ -259,6 +259,7 @@ function buildLibrary(config) {
|
|
|
259
259
|
try {
|
|
260
260
|
const component = await (0, core_1.transform)(fs_1.default.readFileSync(iconFile, 'utf-8'), {
|
|
261
261
|
jsxRuntime: config.lib.newJsxTransform ? 'automatic' : 'classic',
|
|
262
|
+
plugins: [require.resolve('@svgr/plugin-jsx')],
|
|
262
263
|
});
|
|
263
264
|
babel.transform(component, {
|
|
264
265
|
filename: iconFile,
|
|
@@ -167,6 +167,8 @@ export interface ClientConfig {
|
|
|
167
167
|
newWebWorkerSyntax?: boolean;
|
|
168
168
|
babelCacheDirectory?: boolean | string;
|
|
169
169
|
cache?: boolean | FileCacheOptions | MemoryCacheOptions;
|
|
170
|
+
/** Use [Lighting CSS](https://lightningcss.dev) to transform and minimize css instead of PostCSS and cssnano*/
|
|
171
|
+
transformCssWithLightningCss?: boolean;
|
|
170
172
|
}
|
|
171
173
|
interface CdnUploadConfig {
|
|
172
174
|
bucket: string;
|
|
@@ -84,16 +84,27 @@ async function detectContentTypeFromBuffer(buffer) {
|
|
|
84
84
|
if (!type) {
|
|
85
85
|
throw Error('Cannot detect content type for buffer');
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
let contentType = type.mime;
|
|
88
|
+
// use default charset for content type
|
|
89
|
+
const charset = mime.charset(contentType);
|
|
90
|
+
if (charset) {
|
|
91
|
+
contentType += `; charset=${charset.toLowerCase()}`;
|
|
92
|
+
}
|
|
93
|
+
return contentType;
|
|
88
94
|
}
|
|
89
95
|
function detectContentTypeFromExt(filePath) {
|
|
90
96
|
// Compressed file Content-type must be the same as original file Content-type
|
|
91
97
|
if (filePath.endsWith('.br') || filePath.endsWith('.gz')) {
|
|
92
98
|
filePath = filePath.slice(0, -3);
|
|
93
99
|
}
|
|
94
|
-
|
|
95
|
-
if (!
|
|
100
|
+
let contentType = mime.lookup(filePath);
|
|
101
|
+
if (!contentType) {
|
|
96
102
|
throw Error(`Cannot detect content type for file ${filePath}`);
|
|
97
103
|
}
|
|
98
|
-
|
|
104
|
+
// use default charset for content type
|
|
105
|
+
const charset = mime.charset(contentType);
|
|
106
|
+
if (charset) {
|
|
107
|
+
contentType += `; charset=${charset.toLowerCase()}`;
|
|
108
|
+
}
|
|
109
|
+
return contentType;
|
|
99
110
|
}
|
|
@@ -36,9 +36,7 @@ const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
|
|
36
36
|
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
37
37
|
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
38
38
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
39
|
-
const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
|
|
40
39
|
const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
41
|
-
const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
|
|
42
40
|
const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
|
|
43
41
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
44
42
|
const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
|
|
@@ -348,16 +346,20 @@ function createStylesRule({ isEnvDevelopment, isEnvProduction, config, }) {
|
|
|
348
346
|
importLoaders: 2,
|
|
349
347
|
},
|
|
350
348
|
});
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
349
|
+
if (!config.transformCssWithLightningCss) {
|
|
350
|
+
loaders.push({
|
|
351
|
+
loader: require.resolve('postcss-loader'),
|
|
352
|
+
options: {
|
|
353
|
+
sourceMap: !config.disableSourceMapGeneration,
|
|
354
|
+
postcssOptions: {
|
|
355
|
+
config: false,
|
|
356
|
+
plugins: [
|
|
357
|
+
[require.resolve('postcss-preset-env'), { enableClientSidePolyfills: false }],
|
|
358
|
+
],
|
|
359
|
+
},
|
|
358
360
|
},
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
361
363
|
loaders.push({
|
|
362
364
|
loader: require.resolve('resolve-url-loader'),
|
|
363
365
|
options: {
|
|
@@ -609,16 +611,6 @@ function configurePlugins(options) {
|
|
|
609
611
|
chunkFilename: 'css/[name].[contenthash:8].chunk.css',
|
|
610
612
|
ignoreOrder: true,
|
|
611
613
|
}));
|
|
612
|
-
plugins.push(new css_minimizer_webpack_plugin_1.default({
|
|
613
|
-
minimizerOptions: {
|
|
614
|
-
preset: [
|
|
615
|
-
'default',
|
|
616
|
-
{
|
|
617
|
-
svgo: false,
|
|
618
|
-
},
|
|
619
|
-
],
|
|
620
|
-
},
|
|
621
|
-
}));
|
|
622
614
|
if (config.analyzeBundle === 'true') {
|
|
623
615
|
plugins.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
624
616
|
openAnalyzer: false,
|
|
@@ -691,7 +683,7 @@ function configurePlugins(options) {
|
|
|
691
683
|
}
|
|
692
684
|
return plugins;
|
|
693
685
|
}
|
|
694
|
-
function configureOptimization({
|
|
686
|
+
function configureOptimization({ config }) {
|
|
695
687
|
const configVendors = config.vendors ?? [];
|
|
696
688
|
const vendorsList = [
|
|
697
689
|
'react',
|
|
@@ -708,7 +700,6 @@ function configureOptimization({ isEnvProduction, config, }) {
|
|
|
708
700
|
...configVendors,
|
|
709
701
|
];
|
|
710
702
|
const optimization = {
|
|
711
|
-
minimize: isEnvProduction && !config.reactProfiling,
|
|
712
703
|
splitChunks: {
|
|
713
704
|
chunks: 'all',
|
|
714
705
|
cacheGroups: {
|
|
@@ -721,16 +712,48 @@ function configureOptimization({ isEnvProduction, config, }) {
|
|
|
721
712
|
},
|
|
722
713
|
},
|
|
723
714
|
runtimeChunk: 'single',
|
|
715
|
+
minimizer: [
|
|
716
|
+
(compiler) => {
|
|
717
|
+
// CssMinimizerWebpackPlugin works with MiniCSSExtractPlugin, so only relevant for production builds.
|
|
718
|
+
// Lazy load the CssMinimizerPlugin plugin
|
|
719
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
720
|
+
if (config.transformCssWithLightningCss) {
|
|
721
|
+
const lightningCss = require('lightningcss');
|
|
722
|
+
const browserslist = require('browserslist');
|
|
723
|
+
new CssMinimizerPlugin({
|
|
724
|
+
minify: CssMinimizerPlugin.lightningCssMinify,
|
|
725
|
+
minimizerOptions: {
|
|
726
|
+
targets: lightningCss.browserslistToTargets(browserslist()),
|
|
727
|
+
},
|
|
728
|
+
}).apply(compiler);
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
new CssMinimizerPlugin({
|
|
732
|
+
minimizerOptions: {
|
|
733
|
+
preset: [
|
|
734
|
+
'default',
|
|
735
|
+
{
|
|
736
|
+
svgo: false,
|
|
737
|
+
},
|
|
738
|
+
],
|
|
739
|
+
},
|
|
740
|
+
}).apply(compiler);
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
(compiler) => {
|
|
744
|
+
// Lazy load the Terser plugin
|
|
745
|
+
const TerserPlugin = require('terser-webpack-plugin');
|
|
746
|
+
new TerserPlugin({
|
|
747
|
+
terserOptions: {
|
|
748
|
+
compress: {
|
|
749
|
+
passes: 2,
|
|
750
|
+
},
|
|
751
|
+
safari10: config.safari10,
|
|
752
|
+
mangle: !config.reactProfiling,
|
|
753
|
+
},
|
|
754
|
+
}).apply(compiler);
|
|
755
|
+
},
|
|
756
|
+
],
|
|
724
757
|
};
|
|
725
|
-
if (config.safari10) {
|
|
726
|
-
const TerserPlugin = require('terser-webpack-plugin');
|
|
727
|
-
optimization.minimizer = [
|
|
728
|
-
new TerserPlugin({
|
|
729
|
-
terserOptions: {
|
|
730
|
-
safari10: true,
|
|
731
|
-
},
|
|
732
|
-
}),
|
|
733
|
-
];
|
|
734
|
-
}
|
|
735
758
|
return optimization;
|
|
736
759
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -69,11 +69,13 @@
|
|
|
69
69
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
|
|
70
70
|
"@statoscope/webpack-plugin": "^5.26.2",
|
|
71
71
|
"@svgr/core": "^8.0.0",
|
|
72
|
+
"@svgr/plugin-jsx": "^8.0.1",
|
|
72
73
|
"@svgr/webpack": "^8.0.1",
|
|
73
74
|
"babel-loader": "^9.1.2",
|
|
74
75
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
75
76
|
"babel-plugin-lodash": "^3.3.4",
|
|
76
77
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
78
|
+
"browserslist": "^4.21.9",
|
|
77
79
|
"chalk": "^4.1.2",
|
|
78
80
|
"circular-dependency-plugin": "^5.2.2",
|
|
79
81
|
"clean-webpack-plugin": "^4.0.0",
|
|
@@ -82,8 +84,8 @@
|
|
|
82
84
|
"cosmiconfig": "^8.1.3",
|
|
83
85
|
"cosmiconfig-typescript-loader": "^4.3.0",
|
|
84
86
|
"css-loader": "^6.8.1",
|
|
85
|
-
"css-minimizer-webpack-plugin": "^5.0.
|
|
86
|
-
"dotenv": "^16.1
|
|
87
|
+
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
88
|
+
"dotenv": "^16.3.1",
|
|
87
89
|
"execa": "^5.1.1",
|
|
88
90
|
"fast-glob": "^3.2.12",
|
|
89
91
|
"file-type": "^16.5.3",
|
|
@@ -91,11 +93,12 @@
|
|
|
91
93
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
92
94
|
"fs-extra": "^11.1.1",
|
|
93
95
|
"get-port": "^5.1.1",
|
|
96
|
+
"lightningcss": "^1.21.5",
|
|
94
97
|
"lodash": "^4.17.21",
|
|
95
98
|
"mime-types": "^2.1.35",
|
|
96
99
|
"mini-css-extract-plugin": "^2.7.6",
|
|
97
100
|
"moment-timezone-data-webpack-plugin": "^1.5.1",
|
|
98
|
-
"nodemon": "^
|
|
101
|
+
"nodemon": "^3.0.1",
|
|
99
102
|
"p-map": "^4.0.0",
|
|
100
103
|
"p-queue": "^6.6.2",
|
|
101
104
|
"pino-pretty": "^10.0.0",
|
|
@@ -109,16 +112,17 @@
|
|
|
109
112
|
"rimraf": "^5.0.0",
|
|
110
113
|
"sass": "^1.62.1",
|
|
111
114
|
"sass-loader": "^13.3.1",
|
|
112
|
-
"semver": "^7.5.
|
|
115
|
+
"semver": "^7.5.4",
|
|
113
116
|
"signal-exit": "^3.0.7",
|
|
114
117
|
"source-map-loader": "^4.0.1",
|
|
115
118
|
"strip-ansi": "^6.0.1",
|
|
116
119
|
"style-loader": "^3.3.3",
|
|
117
120
|
"svgo": "^3.0.2",
|
|
121
|
+
"terser-webpack-plugin": "5.3.9",
|
|
118
122
|
"ts-node": "10.9.1",
|
|
119
|
-
"tslib": "^2.
|
|
120
|
-
"typescript": "^5.1.
|
|
121
|
-
"webpack": "^5.
|
|
123
|
+
"tslib": "^2.6.0",
|
|
124
|
+
"typescript": "^5.1.6",
|
|
125
|
+
"webpack": "^5.88.1",
|
|
122
126
|
"webpack-assets-manifest": "^5.1.0",
|
|
123
127
|
"webpack-bundle-analyzer": "^4.9.0",
|
|
124
128
|
"webpack-dev-server": "^4.15.0",
|