@gravity-ui/app-builder 0.15.1-beta.4 → 0.15.1-beta.5

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.
@@ -207,6 +207,7 @@ export interface ClientConfig {
207
207
  moduleType?: 'commonjs' | 'esm';
208
208
  };
209
209
  bundler?: Bundler;
210
+ codeLoader?: 'babel' | 'swc';
210
211
  }
211
212
  export interface CdnUploadConfig {
212
213
  bucket: string;
@@ -40,12 +40,12 @@ const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checke
40
40
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
41
41
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
42
42
  const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
43
+ const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
43
44
  const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
44
45
  const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
45
46
  const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
46
47
  const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
47
48
  const core_1 = require("@rspack/core");
48
- const rspack_manifest_plugin_1 = require("rspack-manifest-plugin");
49
49
  const rspack_1 = require("./rspack");
50
50
  const ts_checker_rspack_plugin_1 = require("ts-checker-rspack-plugin");
51
51
  const plugin_react_refresh_1 = __importDefault(require("@rspack/plugin-react-refresh"));
@@ -370,6 +370,53 @@ function configureOutput(options) {
370
370
  };
371
371
  }
372
372
  function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, configType, config, isSsr, }) {
373
+ if (config.codeLoader === 'swc') {
374
+ return {
375
+ loader: 'builtin:swc-loader',
376
+ options: {
377
+ sourceMaps: !config.disableSourceMapGeneration,
378
+ env: {
379
+ loose: true,
380
+ bugfixes: true,
381
+ },
382
+ module: {
383
+ type: 'es6',
384
+ },
385
+ assumptions: {
386
+ setPublicClassFields: true,
387
+ privateFieldsAsProperties: true,
388
+ },
389
+ jsc: {
390
+ parser: {
391
+ syntax: 'typescript',
392
+ tsx: true,
393
+ },
394
+ transform: {
395
+ react: {
396
+ runtime: config.newJsxTransform ? 'automatic' : 'classic',
397
+ development: isEnvDevelopment,
398
+ refresh: !isSsr && isEnvDevelopment && config.reactRefresh !== false,
399
+ useBuiltIns: true,
400
+ },
401
+ },
402
+ experimental: {
403
+ plugins: !isSsr && isEnvProduction
404
+ ? [
405
+ [
406
+ '@swc/plugin-transform-imports',
407
+ {
408
+ lodash: {
409
+ transform: 'lodash/{{member}}',
410
+ },
411
+ },
412
+ ],
413
+ ]
414
+ : [],
415
+ },
416
+ },
417
+ },
418
+ };
419
+ }
373
420
  const plugins = [];
374
421
  if (!isSsr) {
375
422
  if (isEnvDevelopment && config.reactRefresh !== false) {
@@ -492,7 +539,7 @@ function createStylesRule(options) {
492
539
  function getCssLoaders({ isEnvDevelopment, isEnvProduction, config, isSsr }, additionalRules) {
493
540
  const isRspack = config.bundler === 'rspack';
494
541
  const loaders = [];
495
- if (!config.transformCssWithLightningCss) {
542
+ if (!config.transformCssWithLightningCss && config.bundler !== 'rspack') {
496
543
  loaders.push({
497
544
  loader: require.resolve('postcss-loader'),
498
545
  options: {
@@ -768,11 +815,24 @@ const commonBundlerPlugins = {
768
815
  rspack: progress_plugin_1.RspackProgressPlugin,
769
816
  webpack: progress_plugin_1.WebpackProgressPlugin,
770
817
  },
818
+ ManifestPlugin: {
819
+ rspack: rspack_manifest_plugin_1.RspackManifestPlugin,
820
+ webpack: webpack_manifest_plugin_1.WebpackManifestPlugin,
821
+ },
822
+ TsCheckerRspackPlugin: {
823
+ rspack: ts_checker_rspack_plugin_1.TsCheckerRspackPlugin,
824
+ webpack: fork_ts_checker_webpack_plugin_1.default,
825
+ },
826
+ CSSExtractPlugin: {
827
+ rspack: core_1.CssExtractRspackPlugin,
828
+ webpack: mini_css_extract_plugin_1.default,
829
+ },
771
830
  };
772
831
  function configureCommonPlugins(options) {
773
832
  const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
774
833
  const excludeFromClean = config.excludeFromClean || [];
775
834
  const bundler = config.bundler;
835
+ const forkTsCheckerOptions = getForkTsCheckerOptions(options);
776
836
  const plugins = [
777
837
  new clean_webpack_plugin_1.CleanWebpackPlugin({
778
838
  verbose: config.verbose,
@@ -782,10 +842,17 @@ function configureCommonPlugins(options) {
782
842
  ...excludeFromClean,
783
843
  ],
784
844
  }),
845
+ new commonBundlerPlugins['ManifestPlugin'][bundler]({
846
+ writeToFileEmit: true,
847
+ publicPath: '',
848
+ }),
785
849
  new commonBundlerPlugins['DefinePlugin'][bundler](getDefinitions(options)),
786
850
  ...(options.logger
787
851
  ? [new commonBundlerPlugins['ProgressPlugin'][bundler]({ logger: options.logger })]
788
852
  : []),
853
+ ...(forkTsCheckerOptions
854
+ ? [new commonBundlerPlugins['TsCheckerRspackPlugin'][bundler](forkTsCheckerOptions)]
855
+ : []),
789
856
  ];
790
857
  if (config.detectCircularDependencies) {
791
858
  let circularPluginOptions = {
@@ -806,6 +873,9 @@ function configureCommonPlugins(options) {
806
873
  }));
807
874
  }
808
875
  }
876
+ if (isEnvProduction || isSsr || config.ssr) {
877
+ plugins.push(new commonBundlerPlugins['CSSExtractPlugin'][bundler](getCssExtractPluginOptions(options)));
878
+ }
809
879
  if (!isSsr) {
810
880
  const contextReplacements = getContextReplacements(options);
811
881
  contextReplacements.forEach(({ resourceRegExp, newResource }) => plugins.push(new commonBundlerPlugins['ContextReplacementPlugin'][bundler](resourceRegExp, newResource)));
@@ -851,13 +921,8 @@ function configureCommonPlugins(options) {
851
921
  }
852
922
  function configureWebpackPlugins(options) {
853
923
  const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
854
- const forkTsCheckerOptions = getForkTsCheckerOptions(options);
855
924
  const webpackPlugins = [
856
925
  ...configureCommonPlugins(options),
857
- new webpack_manifest_plugin_1.WebpackManifestPlugin({
858
- writeToFileEmit: true,
859
- publicPath: '',
860
- }),
861
926
  new webpack_assets_manifest_1.default(isEnvProduction
862
927
  ? {
863
928
  entrypoints: true,
@@ -869,11 +934,7 @@ function configureWebpackPlugins(options) {
869
934
  output: path.resolve(options.buildDirectory, assetsManifestFile),
870
935
  }),
871
936
  ...(process.env.WEBPACK_PROFILE === 'true' ? [new webpack.debug.ProfilingPlugin()] : []),
872
- ...(forkTsCheckerOptions ? [new fork_ts_checker_webpack_plugin_1.default(forkTsCheckerOptions)] : []),
873
937
  ];
874
- if (isEnvProduction || isSsr || config.ssr) {
875
- webpackPlugins.push(new mini_css_extract_plugin_1.default(getCssExtractPluginOptions(options)));
876
- }
877
938
  if (isEnvProduction) {
878
939
  if (config.analyzeBundle === 'rsdoctor') {
879
940
  const { RsdoctorWebpackPlugin } = require('@rsdoctor/webpack-plugin');
@@ -894,23 +955,18 @@ function configureWebpackPlugins(options) {
894
955
  }
895
956
  function configureRspackPlugins(options) {
896
957
  const { isEnvDevelopment, isEnvProduction, config, isSsr } = options;
897
- const forkTsCheckerOptions = getForkTsCheckerOptions(options);
898
958
  const rspackPlugins = [
899
959
  ...configureCommonPlugins(options),
900
960
  new rspack_manifest_plugin_1.RspackManifestPlugin({
901
961
  fileName: isEnvProduction
902
962
  ? assetsManifestFile
903
- : path.resolve(paths_1.default.appBuild, assetsManifestFile),
963
+ : path.resolve(options.buildDirectory, assetsManifestFile),
904
964
  writeToFileEmit: true,
905
965
  useLegacyEmit: true,
906
966
  publicPath: '',
907
967
  generate: rspack_1.generateAssetsManifest,
908
968
  }),
909
- ...(forkTsCheckerOptions ? [new ts_checker_rspack_plugin_1.TsCheckerRspackPlugin(forkTsCheckerOptions)] : []),
910
969
  ];
911
- if (isEnvProduction || isSsr || config.ssr) {
912
- rspackPlugins.push(new core_1.CssExtractRspackPlugin(getCssExtractPluginOptions(options)));
913
- }
914
970
  if (isEnvProduction) {
915
971
  if (config.analyzeBundle === 'rsdoctor') {
916
972
  const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.15.1-beta.4",
3
+ "version": "0.15.1-beta.5",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -79,6 +79,7 @@
79
79
  "@svgr/core": "^8.1.0",
80
80
  "@svgr/plugin-jsx": "^8.1.0",
81
81
  "@svgr/webpack": "^8.1.0",
82
+ "@swc/plugin-transform-imports": "^6.1.0",
82
83
  "babel-loader": "^9.2.1",
83
84
  "babel-plugin-import": "^1.13.8",
84
85
  "babel-plugin-inline-react-svg": "^2.0.2",