@gravity-ui/app-builder 0.44.0 → 0.44.1-beta.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/dist/common/config.js
CHANGED
|
@@ -238,6 +238,7 @@ async function normalizeClientConfig(client, mode) {
|
|
|
238
238
|
lazyCompilation: undefined,
|
|
239
239
|
bundler: client.bundler || 'webpack',
|
|
240
240
|
javaScriptLoader: client.javaScriptLoader || 'babel',
|
|
241
|
+
reactCompiler: client.reactCompiler ?? false,
|
|
241
242
|
};
|
|
242
243
|
if (mode === 'dev') {
|
|
243
244
|
if (client.lazyCompilation) {
|
|
@@ -17,6 +17,7 @@ import type { UploadOptions } from '../s3-upload/upload';
|
|
|
17
17
|
import type { TerserOptions } from 'terser-webpack-plugin';
|
|
18
18
|
import type { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
|
|
19
19
|
import type { moduleFederationPlugin } from '@module-federation/enhanced';
|
|
20
|
+
import type { PluginOptions as ReactCompilerOptions } from 'babel-plugin-react-compiler';
|
|
20
21
|
type Bundler = 'webpack' | 'rspack';
|
|
21
22
|
type JavaScriptLoader = 'babel' | 'swc';
|
|
22
23
|
type ServerCompiler = 'typescript' | 'swc';
|
|
@@ -233,6 +234,24 @@ export interface ClientConfig {
|
|
|
233
234
|
disableReactRefresh?: boolean;
|
|
234
235
|
/** Disable or configure react-refresh in dev mode */
|
|
235
236
|
reactRefresh?: false | ((options: ReactRefreshPluginOptions) => ReactRefreshPluginOptions);
|
|
237
|
+
/**
|
|
238
|
+
* Enable React Compiler (babel-plugin-react-compiler).
|
|
239
|
+
*
|
|
240
|
+
* For React 17/18 set `target` and install `react-compiler-runtime`:
|
|
241
|
+
* ```ts
|
|
242
|
+
* reactCompiler: { target: '18' }
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* For gradual adoption use `sources` to limit compilation to specific files:
|
|
246
|
+
* ```ts
|
|
247
|
+
* // compile only files inside a specific directory
|
|
248
|
+
* reactCompiler: { sources: (filename) => filename.includes('/src/features/my-feature/') }
|
|
249
|
+
*
|
|
250
|
+
* // or pass an array of directory paths
|
|
251
|
+
* reactCompiler: { sources: ['src/features/new-feature', 'src/components/Button'] }
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
reactCompiler?: boolean | ReactCompilerOptions;
|
|
236
255
|
/**
|
|
237
256
|
* Detect modules with circular dependencies
|
|
238
257
|
*/
|
|
@@ -384,7 +403,8 @@ export interface ServiceConfig {
|
|
|
384
403
|
verbose?: boolean;
|
|
385
404
|
configPath?: string;
|
|
386
405
|
}
|
|
387
|
-
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'publicPath' | 'assetsManifestFile' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker' | 'disableReactRefresh' | 'transformCssWithLightningCss'> & {
|
|
406
|
+
export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'publicPath' | 'assetsManifestFile' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker' | 'disableReactRefresh' | 'transformCssWithLightningCss' | 'reactCompiler'> & {
|
|
407
|
+
reactCompiler: boolean | ReactCompilerOptions;
|
|
388
408
|
bundler: Bundler;
|
|
389
409
|
javaScriptLoader: JavaScriptLoader;
|
|
390
410
|
/**
|
|
@@ -512,17 +512,26 @@ async function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, confi
|
|
|
512
512
|
],
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
const swcLoader = {
|
|
516
516
|
loader: 'builtin:swc-loader',
|
|
517
517
|
options: rspackSwcConfig,
|
|
518
518
|
};
|
|
519
|
+
return config.reactCompiler
|
|
520
|
+
? [swcLoader, createReactCompilerBabelLoader(config)]
|
|
521
|
+
: [swcLoader];
|
|
519
522
|
}
|
|
520
|
-
|
|
523
|
+
const swcLoader = {
|
|
521
524
|
loader: require.resolve('swc-loader'),
|
|
522
525
|
options: swcConfig,
|
|
523
526
|
};
|
|
527
|
+
return config.reactCompiler
|
|
528
|
+
? [swcLoader, createReactCompilerBabelLoader(config)]
|
|
529
|
+
: [swcLoader];
|
|
524
530
|
}
|
|
525
531
|
const plugins = [];
|
|
532
|
+
if (config.reactCompiler) {
|
|
533
|
+
plugins.push(getReactCompilerPlugin(config.reactCompiler));
|
|
534
|
+
}
|
|
526
535
|
if (!isSsr) {
|
|
527
536
|
if (isEnvDevelopment && config.reactRefresh !== false) {
|
|
528
537
|
plugins.push([
|
|
@@ -547,17 +556,45 @@ async function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, confi
|
|
|
547
556
|
presets: [(0, babel_1.babelPreset)({ newJsxTransform: config.newJsxTransform, isSsr })],
|
|
548
557
|
plugins,
|
|
549
558
|
}, { configType, isSsr });
|
|
559
|
+
return [
|
|
560
|
+
{
|
|
561
|
+
loader: require.resolve('babel-loader'),
|
|
562
|
+
options: {
|
|
563
|
+
sourceType: 'unambiguous',
|
|
564
|
+
...babelTransformOptions,
|
|
565
|
+
babelrc: false,
|
|
566
|
+
configFile: false,
|
|
567
|
+
compact: isEnvProduction,
|
|
568
|
+
sourceMaps: !config.disableSourceMapGeneration,
|
|
569
|
+
cacheCompression: isEnvProduction,
|
|
570
|
+
cacheDirectory: config.babelCacheDirectory ? config.babelCacheDirectory : true,
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
function getReactCompilerPlugin(reactCompiler) {
|
|
576
|
+
return [
|
|
577
|
+
require.resolve('babel-plugin-react-compiler'),
|
|
578
|
+
typeof reactCompiler === 'object' ? reactCompiler : {},
|
|
579
|
+
];
|
|
580
|
+
}
|
|
581
|
+
function createReactCompilerBabelLoader(config) {
|
|
550
582
|
return {
|
|
551
583
|
loader: require.resolve('babel-loader'),
|
|
552
584
|
options: {
|
|
553
|
-
|
|
554
|
-
|
|
585
|
+
plugins: [
|
|
586
|
+
getReactCompilerPlugin(config.reactCompiler),
|
|
587
|
+
require.resolve('@babel/plugin-syntax-jsx'),
|
|
588
|
+
[
|
|
589
|
+
require.resolve('@babel/plugin-syntax-typescript'),
|
|
590
|
+
{ isTSX: true, allExtensions: true },
|
|
591
|
+
],
|
|
592
|
+
],
|
|
555
593
|
babelrc: false,
|
|
556
594
|
configFile: false,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
cacheCompression:
|
|
560
|
-
cacheDirectory: config.babelCacheDirectory ? config.babelCacheDirectory : true,
|
|
595
|
+
sourceType: 'unambiguous',
|
|
596
|
+
cacheDirectory: true,
|
|
597
|
+
cacheCompression: false,
|
|
561
598
|
},
|
|
562
599
|
};
|
|
563
600
|
}
|
|
@@ -612,7 +649,7 @@ async function createWorkerRule(options) {
|
|
|
612
649
|
return {
|
|
613
650
|
test: /\.worker\.[jt]sx?$/,
|
|
614
651
|
exclude: /node_modules/,
|
|
615
|
-
use: [...ruleset, await createJavaScriptLoader(options)],
|
|
652
|
+
use: [...ruleset, ...(await createJavaScriptLoader(options))],
|
|
616
653
|
};
|
|
617
654
|
}
|
|
618
655
|
function createSassStylesRule(options) {
|
|
@@ -738,7 +775,7 @@ function createIconsRule({ isEnvProduction, config, isSsr }, jsLoader) {
|
|
|
738
775
|
...(jsLoader
|
|
739
776
|
? {
|
|
740
777
|
use: [
|
|
741
|
-
jsLoader,
|
|
778
|
+
...jsLoader,
|
|
742
779
|
{
|
|
743
780
|
loader: require.resolve('@svgr/webpack'),
|
|
744
781
|
options: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/app-builder",
|
|
3
|
-
"version": "0.44.0",
|
|
3
|
+
"version": "0.44.1-beta.0",
|
|
4
4
|
"description": "Develop and build your React client-server projects, powered by typescript and webpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@swc/plugin-transform-imports": "12.0.1",
|
|
75
75
|
"babel-loader": "^9.2.1",
|
|
76
76
|
"babel-plugin-import": "^1.13.8",
|
|
77
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
77
78
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
78
79
|
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
79
80
|
"babel-plugin-tsconfig-paths-module-resolver": "^1.0.4",
|
|
@@ -173,7 +174,8 @@
|
|
|
173
174
|
"peerDependencies": {
|
|
174
175
|
"@sentry/webpack-plugin": "^2.7.1",
|
|
175
176
|
"lightningcss": "^1.21.5",
|
|
176
|
-
"monaco-editor-webpack-plugin": "*"
|
|
177
|
+
"monaco-editor-webpack-plugin": "*",
|
|
178
|
+
"react-compiler-runtime": "*"
|
|
177
179
|
},
|
|
178
180
|
"peerDependenciesMeta": {
|
|
179
181
|
"lightningcss": {
|
|
@@ -184,6 +186,9 @@
|
|
|
184
186
|
},
|
|
185
187
|
"@sentry/webpack-plugin": {
|
|
186
188
|
"optional": true
|
|
189
|
+
},
|
|
190
|
+
"react-compiler-runtime": {
|
|
191
|
+
"optional": true
|
|
187
192
|
}
|
|
188
193
|
},
|
|
189
194
|
"nano-staged": {
|