@gravity-ui/app-builder 0.10.0-beta.0 → 0.10.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.
@@ -81,36 +81,38 @@ async function buildWebpackServer(config) {
81
81
  if (!listenOn) {
82
82
  options.ipc = path.resolve(paths_1.default.appDist, 'run/client.sock');
83
83
  }
84
- const proxy = options.proxy || [];
85
84
  if (config.client.lazyCompilation) {
86
- proxy.push({
87
- context: ['/build/lazy'],
88
- target: `http://localhost:${config.client.lazyCompilation.port}`,
89
- pathRewrite: { '^/build/lazy': '' },
90
- });
85
+ options.proxy = {
86
+ ...options.proxy,
87
+ '/build/lazy': {
88
+ target: `http://localhost:${config.client.lazyCompilation.port}`,
89
+ pathRewrite: { '^/build/lazy': '' },
90
+ },
91
+ };
91
92
  }
92
93
  if (config.server.port) {
93
- proxy.push({
94
- context: ['/'],
95
- target: `http://localhost:${config.server.port}`,
96
- bypass: (req) => {
97
- if (req.method !== 'GET' && req.method !== 'HEAD') {
98
- return null;
99
- }
100
- const pathname = req.path.replace(/^\//, '');
101
- const filepath = path.resolve(paths_1.default.appDist, 'public', pathname);
102
- if (!fs.existsSync(filepath)) {
103
- return null;
104
- }
105
- const stat = fs.statSync(filepath);
106
- if (!stat.isFile()) {
107
- return null;
108
- }
109
- return req.path;
94
+ options.proxy = {
95
+ ...options.proxy,
96
+ '/': {
97
+ target: `http://localhost:${config.server.port}`,
98
+ bypass: (req) => {
99
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
100
+ return null;
101
+ }
102
+ const pathname = req.path.replace(/^\//, '');
103
+ const filepath = path.resolve(paths_1.default.appDist, 'public', pathname);
104
+ if (!fs.existsSync(filepath)) {
105
+ return null;
106
+ }
107
+ const stat = fs.statSync(filepath);
108
+ if (!stat.isFile()) {
109
+ return null;
110
+ }
111
+ return req.path;
112
+ },
110
113
  },
111
- });
114
+ };
112
115
  }
113
- options.proxy = proxy;
114
116
  const compiler = (0, webpack_1.default)(webpackConfig);
115
117
  const server = new webpack_dev_server_1.default(options, compiler);
116
118
  try {
@@ -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';
@@ -392,6 +392,11 @@ function getCssLoaders({ isEnvDevelopment, isEnvProduction, config }) {
392
392
  esModule: false,
393
393
  sourceMap: !config.disableSourceMapGeneration,
394
394
  importLoaders: 2,
395
+ modules: {
396
+ auto: true,
397
+ localIdentName: '[name]__[local]--[hash:base64:5]',
398
+ exportLocalsConvention: 'camelCase',
399
+ },
395
400
  },
396
401
  });
397
402
  if (!config.transformCssWithLightningCss) {
@@ -812,3 +817,4 @@ function configureOptimization({ config }) {
812
817
  };
813
818
  return optimization;
814
819
  }
820
+ 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) {
@@ -51,7 +51,7 @@ function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
51
51
  }
52
52
  if (stats) {
53
53
  const time = stats.endTime - stats.startTime;
54
- logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
54
+ logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1000000))}`);
55
55
  }
56
56
  else {
57
57
  logger.success(`Client was successfully compiled`);
@@ -3,6 +3,6 @@ declare class WebWorker extends Worker {
3
3
  constructor(url: string | URL, options?: WorkerOptions);
4
4
  }
5
5
  declare class SharedWebWorker extends SharedWorkerPolyfill {
6
- constructor(url: string | URL, options?: WorkerOptions);
6
+ constructor(url: string | URL, options?: string | WorkerOptions);
7
7
  }
8
8
  export { WebWorker as Worker, SharedWebWorker as SharedWorker };
@@ -1,3 +1,4 @@
1
+ // @ts-expect-error ts does not find types in @okikio/sharedworker/@types/index.d.ts
1
2
  import { SharedWorkerPolyfill } from '@okikio/sharedworker';
2
3
  class WebWorker extends Worker {
3
4
  constructor(url, options) {
@@ -2,11 +2,11 @@ export type CliArgs = Awaited<ReturnType<typeof createCli>>;
2
2
  export declare function createCli(argv: string[]): {
3
3
  [x: string]: unknown;
4
4
  verbose: boolean | undefined;
5
+ c: unknown;
5
6
  cdn: string | undefined;
6
7
  env: string[] | undefined;
7
8
  target: "client" | "server" | undefined;
8
9
  inspect: number | undefined;
9
- c: unknown;
10
10
  inspectBrk: number | undefined;
11
11
  "inspect-brk": number | undefined;
12
12
  entryFilter: string[] | undefined;
@@ -30,11 +30,11 @@ export declare function createCli(argv: string[]): {
30
30
  } | Promise<{
31
31
  [x: string]: unknown;
32
32
  verbose: boolean | undefined;
33
+ c: unknown;
33
34
  cdn: string | undefined;
34
35
  env: string[] | undefined;
35
36
  target: "client" | "server" | undefined;
36
37
  inspect: number | undefined;
37
- c: unknown;
38
38
  inspectBrk: number | undefined;
39
39
  "inspect-brk": number | undefined;
40
40
  entryFilter: string[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.10.0-beta.0",
3
+ "version": "0.10.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",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "homepage": "https://github.com/gravity-ui/app-builder#readme",
46
46
  "scripts": {
47
- "prepare": "husky",
47
+ "prepare": "husky install",
48
48
  "lint": "run-p lint:*",
49
49
  "lint:js": "eslint --ext .js,.ts --report-unused-disable-directives .",
50
50
  "lint:other": "npm run prettier -- --check",
@@ -58,20 +58,20 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@aws-sdk/client-s3": "^3.353.0",
61
- "@babel/core": "^7.24.0",
62
- "@babel/helper-plugin-utils": "^7.24.0",
63
- "@babel/plugin-transform-class-properties": "^7.24.0",
64
- "@babel/plugin-transform-dynamic-import": "^7.24.0",
65
- "@babel/plugin-transform-modules-commonjs": "^7.24.0",
66
- "@babel/plugin-transform-private-methods": "^7.24.0",
67
- "@babel/plugin-transform-runtime": "^7.24.0",
68
- "@babel/preset-env": "^7.24.0",
69
- "@babel/preset-react": "^7.24.0",
70
- "@babel/preset-typescript": "^7.24.0",
71
- "@babel/runtime": "^7.24.0",
72
- "@okikio/sharedworker": "^1.0.7",
73
- "@pmmmwh/react-refresh-webpack-plugin": "^0.5.13",
74
- "@statoscope/webpack-plugin": "^5.28.2",
61
+ "@babel/core": "^7.23.4",
62
+ "@babel/helper-plugin-utils": "^7.22.5",
63
+ "@babel/plugin-transform-class-properties": "^7.22.5",
64
+ "@babel/plugin-transform-dynamic-import": "^7.22.0",
65
+ "@babel/plugin-transform-modules-commonjs": "^7.23.4",
66
+ "@babel/plugin-transform-private-methods": "^7.24.1",
67
+ "@babel/plugin-transform-runtime": "^7.22.0",
68
+ "@babel/preset-env": "^7.22.0",
69
+ "@babel/preset-react": "^7.22.0",
70
+ "@babel/preset-typescript": "^7.23.4",
71
+ "@babel/runtime": "^7.23.4",
72
+ "@okikio/sharedworker": "^1.0.4",
73
+ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
74
+ "@statoscope/webpack-plugin": "^5.27.0",
75
75
  "@svgr/core": "^8.1.0",
76
76
  "@svgr/plugin-jsx": "^8.1.0",
77
77
  "@svgr/webpack": "^8.1.0",
@@ -79,92 +79,92 @@
79
79
  "babel-plugin-import": "^1.13.8",
80
80
  "babel-plugin-inline-react-svg": "^2.0.2",
81
81
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
82
- "browserslist": "^4.23.0",
82
+ "browserslist": "^4.21.10",
83
83
  "chalk": "^4.1.2",
84
84
  "circular-dependency-plugin": "^5.2.2",
85
85
  "clean-webpack-plugin": "^4.0.0",
86
86
  "clear": "^0.1.0",
87
87
  "common-tags": "^1.8.2",
88
- "cosmiconfig": "^8.3.6",
88
+ "cosmiconfig": "^8.1.3",
89
89
  "cosmiconfig-typescript-loader": "^5.0.0",
90
- "css-loader": "^7.1.1",
91
- "css-minimizer-webpack-plugin": "^6.0.0",
92
- "dotenv": "^16.4.5",
90
+ "css-loader": "^6.8.1",
91
+ "css-minimizer-webpack-plugin": "^5.0.1",
92
+ "dotenv": "^16.3.1",
93
93
  "execa": "^5.1.1",
94
- "fast-glob": "^3.3.2",
94
+ "fast-glob": "^3.3.1",
95
95
  "file-type": "^16.5.3",
96
96
  "find-cache-dir": "^3.3.2",
97
- "fork-ts-checker-webpack-plugin": "^9.0.2",
98
- "fs-extra": "^11.2.0",
99
- "get-port": "^7.1.0",
97
+ "fork-ts-checker-webpack-plugin": "^8.0.0",
98
+ "fs-extra": "^11.1.1",
99
+ "get-port": "^7.0.0",
100
100
  "lodash": "^4.17.21",
101
101
  "mime-types": "^2.1.35",
102
- "mini-css-extract-plugin": "^2.9.0",
102
+ "mini-css-extract-plugin": "^2.8.1",
103
103
  "moment-timezone-data-webpack-plugin": "^1.5.1",
104
- "nodemon": "^3.1.0",
104
+ "nodemon": "^3.0.1",
105
105
  "p-map": "^4.0.0",
106
106
  "p-queue": "^6.6.2",
107
- "pino-pretty": "^11.0.0",
108
- "postcss": "^8.4.38",
109
- "postcss-loader": "^8.1.1",
107
+ "pino-pretty": "^10.2.0",
108
+ "postcss": "^8.4.23",
109
+ "postcss-loader": "^7.3.3",
110
110
  "postcss-preset-env": "^9.1.3",
111
- "react": "^18.3.1",
112
- "react-dom": "^18.3.1",
113
- "react-refresh": "^0.14.2",
111
+ "react": "^18.2.0",
112
+ "react-dom": "^18.2.0",
113
+ "react-refresh": "^0.14.0",
114
114
  "resolve-url-loader": "^5.0.0",
115
- "rimraf": "^5.0.5",
116
- "sass": "^1.75.0",
117
- "sass-loader": "^14.2.1",
118
- "semver": "^7.6.0",
115
+ "rimraf": "^5.0.1",
116
+ "sass": "^1.69.0",
117
+ "sass-loader": "^13.3.2",
118
+ "semver": "^7.5.4",
119
119
  "signal-exit": "^4.1.0",
120
- "source-map-loader": "^5.0.0",
120
+ "source-map-loader": "^4.0.1",
121
121
  "strip-ansi": "^6.0.1",
122
- "style-loader": "^4.0.0",
123
- "svgo": "^3.2.0",
122
+ "style-loader": "^3.3.3",
123
+ "svgo": "^3.0.2",
124
124
  "terser-webpack-plugin": "5.3.10",
125
125
  "ts-node": "10.9.2",
126
126
  "tslib": "^2.6.2",
127
- "typescript": "^5.4.5",
127
+ "typescript": "^5.3.3",
128
128
  "webpack": "^5.91.0",
129
129
  "webpack-assets-manifest": "^5.2.1",
130
- "webpack-bundle-analyzer": "^4.10.2",
131
- "webpack-dev-server": "^5.0.4",
130
+ "webpack-bundle-analyzer": "^4.10.1",
131
+ "webpack-dev-server": "^4.15.1",
132
132
  "webpack-manifest-plugin": "^5.0.0",
133
133
  "worker-loader": "^3.0.8",
134
134
  "yargs": "^17.7.2"
135
135
  },
136
136
  "devDependencies": {
137
- "@commitlint/cli": "^19.3.0",
138
- "@commitlint/config-conventional": "^19.2.2",
139
- "@gravity-ui/eslint-config": "^3.2.0",
137
+ "@commitlint/cli": "^17.7.1",
138
+ "@commitlint/config-conventional": "^17.7.0",
139
+ "@gravity-ui/eslint-config": "^3.0.0",
140
140
  "@gravity-ui/prettier-config": "^1.1.0",
141
141
  "@gravity-ui/tsconfig": "^1.0.0",
142
142
  "@sentry/webpack-plugin": "^2.7.1",
143
- "@types/babel__helper-plugin-utils": "^7.10.3",
144
- "@types/circular-dependency-plugin": "^5.0.8",
145
- "@types/common-tags": "^1.8.4",
143
+ "@types/babel__helper-plugin-utils": "^7.10.1",
144
+ "@types/circular-dependency-plugin": "^5.0.6",
145
+ "@types/common-tags": "^1.8.2",
146
146
  "@types/find-cache-dir": "^3.2.1",
147
- "@types/fs-extra": "^11.0.4",
147
+ "@types/fs-extra": "^11.0.2",
148
148
  "@types/jest": "^29.5.2",
149
- "@types/lodash": "^4.17.0",
150
- "@types/mime-types": "^2.1.4",
149
+ "@types/lodash": "^4.14.198",
150
+ "@types/mime-types": "^2.1.1",
151
151
  "@types/node": "^18",
152
- "@types/nodemon": "^1.19.6",
153
- "@types/semver": "^7.5.8",
154
- "@types/webpack-assets-manifest": "^5.1.4",
155
- "@types/webpack-bundle-analyzer": "^4.7.0",
156
- "@types/webpack-manifest-plugin": "^3.0.8",
152
+ "@types/nodemon": "^1.19.2",
153
+ "@types/semver": "^7.5.2",
154
+ "@types/webpack-assets-manifest": "^5.1.0",
155
+ "@types/webpack-bundle-analyzer": "^4.6.0",
156
+ "@types/webpack-manifest-plugin": "^3.0.5",
157
157
  "@types/yargs": "17.0.11",
158
158
  "babel-plugin-tester": "^11.0.4",
159
159
  "eslint": "^8.49.0",
160
- "husky": "^9.0.11",
160
+ "husky": "^8.0.3",
161
161
  "jest": "^29.5.0",
162
162
  "lightningcss": "^1.21.5",
163
163
  "monaco-editor-webpack-plugin": "^6.0.0",
164
164
  "nano-staged": "^0.8.0",
165
165
  "npm-run-all": "^4.1.5",
166
- "prettier": "3.2.5",
167
- "ts-jest": "^29.1.2"
166
+ "prettier": "3.0.3",
167
+ "ts-jest": "^29.1.0"
168
168
  },
169
169
  "peerDependencies": {
170
170
  "@sentry/webpack-plugin": "^2.7.1",
@@ -189,5 +189,8 @@
189
189
  "*.{md,yaml,yml,json}": [
190
190
  "prettier --write"
191
191
  ]
192
+ },
193
+ "overrides": {
194
+ "cosmiconfig-typescript-loader": "^5.0.0"
192
195
  }
193
196
  }