@gravity-ui/app-builder 0.9.4 → 0.9.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.
@@ -20,5 +20,8 @@ export declare const enum WebpackMode {
20
20
  export declare function webpackConfigFactory(webpackMode: WebpackMode, config: NormalizedClientConfig, { logger }?: {
21
21
  logger?: Logger;
22
22
  }): Promise<webpack.Configuration>;
23
- export declare function configureModuleRules(helperOptions: HelperOptions): webpack.RuleSetRule[];
23
+ export declare function configureModuleRules(helperOptions: HelperOptions, additionalRules?: NonNullable<webpack.RuleSetRule['oneOf']>): webpack.RuleSetRule[];
24
24
  export declare function configureResolve({ isEnvProduction, config, tsLinkedPackages, }: HelperOptions): webpack.ResolveOptions;
25
+ type Optimization = NonNullable<webpack.Configuration['optimization']>;
26
+ export declare function configureOptimization({ config }: HelperOptions): Optimization;
27
+ export {};
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.configureResolve = exports.configureModuleRules = exports.webpackConfigFactory = void 0;
29
+ exports.configureOptimization = exports.configureResolve = exports.configureModuleRules = exports.webpackConfigFactory = void 0;
30
30
  /* eslint-disable complexity */
31
31
  const path = __importStar(require("node:path"));
32
32
  const fs = __importStar(require("node:fs"));
@@ -100,7 +100,7 @@ async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
100
100
  return webpackConfig;
101
101
  }
102
102
  exports.webpackConfigFactory = webpackConfigFactory;
103
- function configureModuleRules(helperOptions) {
103
+ function configureModuleRules(helperOptions, additionalRules = []) {
104
104
  const jsLoader = createJavaScriptLoader(helperOptions);
105
105
  return [
106
106
  ...createSourceMapRules(!helperOptions.config.disableSourceMapGeneration),
@@ -113,6 +113,7 @@ function configureModuleRules(helperOptions) {
113
113
  createIconsRule(helperOptions), // workaround for https://github.com/webpack/webpack/issues/9309
114
114
  createIconsRule(helperOptions, jsLoader),
115
115
  ...createAssetsRules(helperOptions),
116
+ ...additionalRules,
116
117
  ...createFallbackRules(helperOptions),
117
118
  ],
118
119
  },
@@ -197,11 +198,10 @@ function configureExperiments({ config, isEnvProduction, }) {
197
198
  };
198
199
  }
199
200
  function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
200
- let alias = config.alias || {};
201
- alias = Object.entries(alias).reduce((result, [key, value]) => {
202
- result[key] = path.resolve(paths_1.default.app, value);
203
- return result;
204
- }, {});
201
+ const alias = { ...config.alias };
202
+ for (const [key, value] of Object.entries(alias)) {
203
+ alias[key] = path.resolve(paths_1.default.app, value);
204
+ }
205
205
  if (isEnvProduction && config.reactProfiling) {
206
206
  alias['react-dom$'] = 'react-dom/profiling';
207
207
  alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
@@ -812,3 +812,4 @@ function configureOptimization({ config }) {
812
812
  };
813
813
  return optimization;
814
814
  }
815
+ exports.configureOptimization = configureOptimization;
@@ -3,11 +3,15 @@ import type { ClientConfig } from '../models';
3
3
  import type * as Webpack from 'webpack';
4
4
  type Mode = `${WebpackMode}`;
5
5
  export declare function configureServiceWebpackConfig(mode: Mode, storybookConfig: Webpack.Configuration): Promise<Webpack.Configuration>;
6
- export declare function configureWebpackConfigForStorybook(mode: Mode, userConfig?: ClientConfig): Promise<{
6
+ type ModuleRule = NonNullable<NonNullable<Webpack.Configuration['module']>['rules']>[number];
7
+ export declare function configureWebpackConfigForStorybook(mode: Mode, userConfig?: ClientConfig, storybookModuleRules?: ModuleRule[]): Promise<{
7
8
  module: {
8
9
  rules: Webpack.RuleSetRule[];
9
10
  };
10
11
  resolve: Webpack.ResolveOptions;
11
12
  plugins: (false | "" | 0 | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | Webpack.WebpackPluginInstance | null | undefined)[];
13
+ optimization: {
14
+ minimizer: (false | "" | 0 | "..." | Webpack.WebpackPluginInstance | ((this: Webpack.Compiler, compiler: Webpack.Compiler) => void) | null | undefined)[] | undefined;
15
+ };
12
16
  }>;
13
17
  export {};
@@ -48,7 +48,7 @@ async function configureServiceWebpackConfig(mode, storybookConfig) {
48
48
  else {
49
49
  options = serviceConfig.client;
50
50
  }
51
- const webpackConfig = await configureWebpackConfigForStorybook(mode, options);
51
+ const webpackConfig = await configureWebpackConfigForStorybook(mode, options, storybookConfig.module?.rules);
52
52
  return {
53
53
  ...storybookConfig,
54
54
  plugins: [...(storybookConfig.plugins ?? []), ...webpackConfig.plugins],
@@ -67,15 +67,23 @@ async function configureServiceWebpackConfig(mode, storybookConfig) {
67
67
  ...(storybookConfig.resolve?.extensions ?? []),
68
68
  ...(webpackConfig.resolve.extensions || []),
69
69
  ],
70
+ fallback: {
71
+ ...storybookConfig.resolve?.fallback,
72
+ ...webpackConfig.resolve.fallback,
73
+ },
70
74
  },
71
75
  module: {
72
76
  ...storybookConfig.module,
73
77
  rules: webpackConfig.module.rules,
74
78
  },
79
+ optimization: {
80
+ ...storybookConfig.optimization,
81
+ ...webpackConfig.optimization,
82
+ },
75
83
  };
76
84
  }
77
85
  exports.configureServiceWebpackConfig = configureServiceWebpackConfig;
78
- async function configureWebpackConfigForStorybook(mode, userConfig = {}) {
86
+ async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybookModuleRules = []) {
79
87
  const isEnvDevelopment = mode === "development" /* WebpackMode.Dev */;
80
88
  const isEnvProduction = mode === "production" /* WebpackMode.Prod */;
81
89
  const config = await (0, config_2.normalizeConfig)({
@@ -92,10 +100,13 @@ async function configureWebpackConfigForStorybook(mode, userConfig = {}) {
92
100
  };
93
101
  return {
94
102
  module: {
95
- rules: (0, config_1.configureModuleRules)(helperOptions),
103
+ rules: (0, config_1.configureModuleRules)(helperOptions, storybookModuleRules.filter((rule) => rule !== '...')),
96
104
  },
97
105
  resolve: (0, config_1.configureResolve)(helperOptions),
98
106
  plugins: configurePlugins(helperOptions),
107
+ optimization: {
108
+ minimizer: (0, config_1.configureOptimization)(helperOptions).minimizer,
109
+ },
99
110
  };
100
111
  }
101
112
  exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
@@ -116,7 +127,7 @@ function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
116
127
  publicPath: '/',
117
128
  }));
118
129
  }
119
- if (isEnvDevelopment) {
130
+ if (isEnvDevelopment && !config.disableReactRefresh) {
120
131
  plugins.push(new react_refresh_webpack_plugin_1.default());
121
132
  }
122
133
  if (isEnvProduction) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.9.4",
3
+ "version": "0.9.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",