@gravity-ui/app-builder 0.12.0 → 0.13.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.
@@ -1,3 +1,3 @@
1
1
  import WebpackDevServer from 'webpack-dev-server';
2
2
  import type { NormalizedServiceConfig } from '../../common/models';
3
- export declare function watchClientCompilation(config: NormalizedServiceConfig, onCompilationEnd: () => void): Promise<WebpackDevServer>;
3
+ export declare function watchClientCompilation(config: NormalizedServiceConfig, onManifestReady: () => void): Promise<WebpackDevServer<import("express").Application, import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>>;
@@ -32,13 +32,18 @@ const fs = __importStar(require("node:fs"));
32
32
  const webpack_1 = __importDefault(require("webpack"));
33
33
  const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
34
34
  const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
35
+ const webpack_assets_manifest_1 = __importDefault(require("webpack-assets-manifest"));
36
+ const utils_1 = require("../../common/utils");
35
37
  const paths_1 = __importDefault(require("../../common/paths"));
36
38
  const logger_1 = require("../../common/logger");
37
39
  const config_1 = require("../../common/webpack/config");
38
- async function watchClientCompilation(config, onCompilationEnd) {
40
+ async function watchClientCompilation(config, onManifestReady) {
39
41
  const clientCompilation = await buildWebpackServer(config);
40
- const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(clientCompilation.compiler);
41
- afterEmit.tap('app-builder: afterEmit', onCompilationEnd);
42
+ const compiler = clientCompilation.compiler;
43
+ if ('compilers' in compiler) {
44
+ throw new Error('Unexpected multi compiler');
45
+ }
46
+ subscribeToManifestReadyEvent(compiler, onManifestReady);
42
47
  return clientCompilation;
43
48
  }
44
49
  async function buildWebpackServer(config) {
@@ -124,3 +129,17 @@ async function buildWebpackServer(config) {
124
129
  }
125
130
  return server;
126
131
  }
132
+ function subscribeToManifestReadyEvent(compiler, onManifestReady) {
133
+ const promises = [];
134
+ const assetsManifestPlugin = compiler.options.plugins.find((plugin) => plugin instanceof webpack_assets_manifest_1.default);
135
+ if (assetsManifestPlugin) {
136
+ const assetsManifestReady = (0, utils_1.deferredPromise)();
137
+ promises.push(assetsManifestReady.promise);
138
+ assetsManifestPlugin.hooks.done.tap('app-builder', assetsManifestReady.resolve);
139
+ }
140
+ const manifestReady = (0, utils_1.deferredPromise)();
141
+ promises.push(manifestReady.promise);
142
+ const { afterEmit } = (0, webpack_manifest_plugin_1.getCompilerHooks)(compiler);
143
+ afterEmit.tap('app-builder', manifestReady.resolve);
144
+ Promise.all(promises).then(() => onManifestReady());
145
+ }
@@ -186,7 +186,7 @@ async function normalizeClientConfig(client, mode) {
186
186
  forkTsChecker: client.disableForkTsChecker ? false : client.forkTsChecker,
187
187
  reactRefresh: client.disableReactRefresh
188
188
  ? false
189
- : client.reactRefresh ?? ((options) => options),
189
+ : (client.reactRefresh ?? ((options) => options)),
190
190
  newJsxTransform: client.newJsxTransform ?? true,
191
191
  publicPathPrefix: client.publicPathPrefix || '',
192
192
  modules: client.modules && remapPaths(client.modules),
@@ -4,3 +4,8 @@ export declare function getCacheDir(): Promise<string>;
4
4
  export declare function getPort({ port }: {
5
5
  port: number;
6
6
  }): Promise<number>;
7
+ export declare function deferredPromise<T>(): {
8
+ promise: Promise<T | undefined>;
9
+ resolve: (value?: T) => void;
10
+ reject: (reason?: unknown) => void;
11
+ };
@@ -7,6 +7,7 @@ exports.createRunFolder = createRunFolder;
7
7
  exports.shouldCompileTarget = shouldCompileTarget;
8
8
  exports.getCacheDir = getCacheDir;
9
9
  exports.getPort = getPort;
10
+ exports.deferredPromise = deferredPromise;
10
11
  const node_fs_1 = __importDefault(require("node:fs"));
11
12
  const node_os_1 = __importDefault(require("node:os"));
12
13
  const paths_1 = __importDefault(require("./paths"));
@@ -27,3 +28,13 @@ async function getPort({ port }) {
27
28
  const { default: getPortDefault, portNumbers } = await import('get-port');
28
29
  return getPortDefault({ port: portNumbers(port, port + 100) });
29
30
  }
31
+ function deferredPromise() {
32
+ let resolve;
33
+ let reject;
34
+ const promise = new Promise((res, rej) => {
35
+ resolve = res;
36
+ reject = rej;
37
+ });
38
+ // @ts-expect-error Promise callback executes synchronously, so resolve and reject are initialized here
39
+ return { promise, resolve, reject };
40
+ }
@@ -127,8 +127,8 @@ function configureDevTool({ isEnvProduction, config }) {
127
127
  function configureWatchOptions({ config }) {
128
128
  const watchOptions = {
129
129
  ...config.watchOptions,
130
- followSymlinks: config.watchOptions?.followSymlinks ??
131
- (!config.symlinks && config.watchOptions?.watchPackages)
130
+ followSymlinks: (config.watchOptions?.followSymlinks ??
131
+ (!config.symlinks && config.watchOptions?.watchPackages))
132
132
  ? true
133
133
  : undefined,
134
134
  };
@@ -320,7 +320,7 @@ function createSassStylesRule(options) {
320
320
  options: {
321
321
  sourceMap: true, // must be always true for work with resolve-url-loader
322
322
  sassOptions: {
323
- includePaths: [paths_1.default.appClient],
323
+ loadPaths: [paths_1.default.appClient],
324
324
  },
325
325
  },
326
326
  });
@@ -517,6 +517,7 @@ function createMomentTimezoneDataPlugin(options = {}) {
517
517
  function configurePlugins(options) {
518
518
  const { isEnvDevelopment, isEnvProduction, config } = options;
519
519
  const excludeFromClean = config.excludeFromClean || [];
520
+ const manifestFile = 'assets-manifest.json';
520
521
  const plugins = [
521
522
  new clean_webpack_plugin_1.CleanWebpackPlugin({
522
523
  verbose: config.verbose,
@@ -530,6 +531,16 @@ function configurePlugins(options) {
530
531
  writeToFileEmit: true,
531
532
  publicPath: '',
532
533
  }),
534
+ new webpack_assets_manifest_1.default(isEnvProduction
535
+ ? {
536
+ entrypoints: true,
537
+ output: manifestFile,
538
+ }
539
+ : {
540
+ entrypoints: true,
541
+ writeToDisk: true,
542
+ output: path.resolve(paths_1.default.appBuild, manifestFile),
543
+ }),
533
544
  createMomentTimezoneDataPlugin(config.momentTz),
534
545
  new webpack.DefinePlugin({
535
546
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
@@ -628,17 +639,6 @@ function configurePlugins(options) {
628
639
  }));
629
640
  }
630
641
  }
631
- const manifestFile = 'assets-manifest.json';
632
- plugins.push(new webpack_assets_manifest_1.default(isEnvProduction
633
- ? {
634
- entrypoints: true,
635
- output: manifestFile,
636
- }
637
- : {
638
- entrypoints: true,
639
- writeToDisk: true,
640
- output: path.resolve(paths_1.default.appBuild, manifestFile),
641
- }));
642
642
  if (config.cdn) {
643
643
  let credentialsGlobal;
644
644
  if (process.env.FRONTEND_S3_ACCESS_KEY_ID && process.env.FRONTEND_S3_SECRET_ACCESS_KEY) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.12.0",
3
+ "version": "0.13.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",
@@ -58,28 +58,28 @@
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",
61
+ "@babel/core": "^7.25.0",
62
+ "@babel/helper-plugin-utils": "^7.25.0",
63
+ "@babel/plugin-transform-class-properties": "^7.25.0",
64
+ "@babel/plugin-transform-dynamic-import": "^7.25.0",
65
+ "@babel/plugin-transform-modules-commonjs": "^7.25.0",
66
+ "@babel/plugin-transform-private-methods": "^7.25.0",
67
+ "@babel/plugin-transform-runtime": "^7.25.0",
68
+ "@babel/preset-env": "^7.25.0",
69
+ "@babel/preset-react": "^7.25.0",
70
+ "@babel/preset-typescript": "^7.25.0",
71
+ "@babel/runtime": "^7.25.0",
72
72
  "@okikio/sharedworker": "^1.0.7",
73
73
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
74
74
  "@statoscope/webpack-plugin": "^5.28.2",
75
75
  "@svgr/core": "^8.1.0",
76
76
  "@svgr/plugin-jsx": "^8.1.0",
77
77
  "@svgr/webpack": "^8.1.0",
78
- "babel-loader": "^9.1.3",
78
+ "babel-loader": "^9.2.1",
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.24.0",
83
83
  "chalk": "^4.1.2",
84
84
  "circular-dependency-plugin": "^5.2.2",
85
85
  "clean-webpack-plugin": "^4.0.0",
@@ -91,20 +91,20 @@
91
91
  "dotenv": "^16.4.5",
92
92
  "execa": "^8.0.1",
93
93
  "fast-glob": "^3.3.2",
94
- "file-type": "^19.0.0",
94
+ "file-type": "^19.5.0",
95
95
  "find-cache-dir": "^5.0.0",
96
96
  "fork-ts-checker-webpack-plugin": "^9.0.2",
97
97
  "fs-extra": "^11.2.0",
98
98
  "get-port": "^7.1.0",
99
99
  "lodash": "^4.17.21",
100
100
  "mime-types": "^2.1.35",
101
- "mini-css-extract-plugin": "^2.9.0",
101
+ "mini-css-extract-plugin": "^2.9.1",
102
102
  "moment-timezone-data-webpack-plugin": "^1.5.1",
103
103
  "nodemon": "^3.1.0",
104
104
  "p-map": "^7.0.2",
105
105
  "p-queue": "^8.0.1",
106
106
  "pino-pretty": "^11.2.0",
107
- "postcss": "^8.4.38",
107
+ "postcss": "^8.4.47",
108
108
  "postcss-loader": "^8.1.1",
109
109
  "postcss-preset-env": "^9.1.3",
110
110
  "react": "^18.3.1",
@@ -112,9 +112,9 @@
112
112
  "react-refresh": "^0.14.2",
113
113
  "resolve-url-loader": "^5.0.0",
114
114
  "rimraf": "^5.0.7",
115
- "sass": "^1.77.5",
116
- "sass-loader": "^14.2.1",
117
- "semver": "^7.6.2",
115
+ "sass": "^1.79.0",
116
+ "sass-loader": "^16.0.0",
117
+ "semver": "^7.6.3",
118
118
  "signal-exit": "^4.1.0",
119
119
  "source-map-loader": "^5.0.0",
120
120
  "strip-ansi": "^6.0.1",
@@ -123,18 +123,18 @@
123
123
  "terser-webpack-plugin": "5.3.10",
124
124
  "ts-node": "10.9.2",
125
125
  "tslib": "^2.6.2",
126
- "typescript": "~5.5.2",
127
- "webpack": "^5.92.0",
126
+ "typescript": "~5.6.0",
127
+ "webpack": "^5.95.0",
128
128
  "webpack-assets-manifest": "^5.2.1",
129
129
  "webpack-bundle-analyzer": "^4.10.2",
130
- "webpack-dev-server": "^5.0.4",
130
+ "webpack-dev-server": "^5.1.0",
131
131
  "webpack-manifest-plugin": "^5.0.0",
132
132
  "worker-loader": "^3.0.8",
133
133
  "yargs": "^17.7.2"
134
134
  },
135
135
  "devDependencies": {
136
- "@commitlint/cli": "^19.3.0",
137
- "@commitlint/config-conventional": "^19.2.2",
136
+ "@commitlint/cli": "^19.5.0",
137
+ "@commitlint/config-conventional": "^19.5.0",
138
138
  "@gravity-ui/eslint-config": "^3.2.0",
139
139
  "@gravity-ui/prettier-config": "^1.1.0",
140
140
  "@gravity-ui/tsconfig": "^1.0.0",
@@ -144,7 +144,7 @@
144
144
  "@types/common-tags": "^1.8.4",
145
145
  "@types/fs-extra": "^11.0.4",
146
146
  "@types/jest": "^29.5.2",
147
- "@types/lodash": "^4.17.6",
147
+ "@types/lodash": "^4.17.10",
148
148
  "@types/mime-types": "^2.1.4",
149
149
  "@types/node": "^18",
150
150
  "@types/nodemon": "^1.19.6",
@@ -155,13 +155,13 @@
155
155
  "@types/yargs": "17.0.11",
156
156
  "babel-plugin-tester": "^11.0.4",
157
157
  "eslint": "^8.57.0",
158
- "husky": "^9.0.11",
158
+ "husky": "^9.1.6",
159
159
  "jest": "^29.5.0",
160
- "lightningcss": "^1.21.5",
160
+ "lightningcss": "^1.27.0",
161
161
  "monaco-editor-webpack-plugin": "^6.0.0",
162
162
  "nano-staged": "^0.8.0",
163
163
  "npm-run-all": "^4.1.5",
164
- "prettier": "3.3.2",
164
+ "prettier": "3.3.3",
165
165
  "ts-jest": "^29.1.2"
166
166
  },
167
167
  "peerDependencies": {