@gravity-ui/app-builder 0.35.0 → 0.35.2-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/README.md CHANGED
@@ -523,6 +523,7 @@ Module Federation is a Webpack 5 feature that enables micro-frontend architectur
523
523
  - Enables loading different versions of the same remote in different environments
524
524
  - Works with both `remotes` and `originalRemotes` configurations
525
525
 
526
+ - `isolateAssets` (`boolean`) - put all assets to a folder with the name of Module Federation app name
526
527
  - `isolateStyles` (`object`) — CSS style isolation settings to prevent conflicts between micro-frontends.
527
528
  - `getPrefix` (`(entryName: string) => string`) — function to generate CSS class prefix.
528
529
  - `prefixSelector` (`(prefix: string, selector: string, prefixedSelector: string, filePath: string) => string`) — function to add prefix to CSS selectors.
@@ -2,6 +2,6 @@ import type { LibraryConfig, NormalizedServiceConfig, ServiceConfig } from './mo
2
2
  import type { CliArgs } from '../create-cli';
3
3
  export declare function getProjectConfig(command: string, { env, storybook, ...argv }: Partial<CliArgs> & {
4
4
  storybook?: boolean;
5
- }): Promise<LibraryConfig | NormalizedServiceConfig>;
5
+ }): Promise<NormalizedServiceConfig | LibraryConfig>;
6
6
  export declare function normalizeConfig(userConfig: ServiceConfig, mode?: 'dev' | 'build' | string): Promise<NormalizedServiceConfig>;
7
7
  export declare function normalizeConfig(userConfig: LibraryConfig, mode?: 'dev' | 'build' | string): Promise<LibraryConfig>;
@@ -195,7 +195,7 @@ async function normalizeClientConfig(client, mode) {
195
195
  const cdnConfig = Array.isArray(client.cdn) ? client.cdn[0] : client.cdn;
196
196
  let publicPath = client.publicPath || path.normalize(`${client.publicPathPrefix || ''}/build/`);
197
197
  let browserPublicPath = (mode !== 'dev' && cdnConfig?.publicPath) || publicPath;
198
- if (client.moduleFederation) {
198
+ if ((0, utils_1.hasMFAssetsIsolation)(client.moduleFederation)) {
199
199
  publicPath = `${publicPath}${client.moduleFederation.name}/`;
200
200
  browserPublicPath = `${browserPublicPath}${client.moduleFederation.name}/`;
201
201
  }
@@ -118,6 +118,12 @@ export type ModuleFederationConfig = Omit<moduleFederationPlugin.ModuleFederatio
118
118
  */
119
119
  prefixSelector: (prefix: string, selector: string, prefixedSelector: string, filePath: string) => string;
120
120
  };
121
+ /**
122
+ * Put all assets to a folder with the name of Module Federation app name
123
+ *
124
+ * @default true
125
+ */
126
+ isolateAssets?: boolean;
121
127
  };
122
128
  export type WebWorkerHandle = 'loader' | 'cdn-compat' | 'none';
123
129
  export interface ClientConfig {
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.createS3UploadPlugins = createS3UploadPlugins;
27
27
  const path = __importStar(require("node:path"));
28
28
  const webpack_plugin_1 = require("./webpack-plugin");
29
+ const utils_1 = require("../utils");
29
30
  function createS3UploadPlugins(config, logger) {
30
31
  const plugins = [];
31
32
  let credentialsGlobal;
@@ -51,7 +52,7 @@ function createS3UploadPlugins(config, logger) {
51
52
  };
52
53
  }
53
54
  let targetPath = cdn.prefix;
54
- if (config.moduleFederation && targetPath !== undefined) {
55
+ if ((0, utils_1.hasMFAssetsIsolation)(config.moduleFederation) && targetPath !== undefined) {
55
56
  targetPath = path.join(targetPath, config.moduleFederation.name);
56
57
  }
57
58
  plugins.push(new webpack_plugin_1.S3UploadPlugin({
@@ -1,4 +1,5 @@
1
- import type { NormalizedServiceConfig } from './models';
1
+ import type { ModuleFederationConfig, NormalizedServiceConfig } from './models';
2
+ export declare function hasMFAssetsIsolation(mfConfig: ModuleFederationConfig | undefined): mfConfig is ModuleFederationConfig;
2
3
  export declare function getAppRunPath(config: NormalizedServiceConfig): string;
3
4
  export declare function createRunFolder(config: NormalizedServiceConfig): void;
4
5
  export declare function shouldCompileTarget(target: 'client' | 'server' | undefined, targetName: string): boolean;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.hasMFAssetsIsolation = hasMFAssetsIsolation;
6
7
  exports.getAppRunPath = getAppRunPath;
7
8
  exports.createRunFolder = createRunFolder;
8
9
  exports.shouldCompileTarget = shouldCompileTarget;
@@ -13,8 +14,13 @@ const node_fs_1 = __importDefault(require("node:fs"));
13
14
  const node_os_1 = __importDefault(require("node:os"));
14
15
  const node_path_1 = __importDefault(require("node:path"));
15
16
  const paths_1 = __importDefault(require("./paths"));
17
+ function hasMFAssetsIsolation(mfConfig) {
18
+ return mfConfig?.name ? mfConfig.isolateAssets !== false : false;
19
+ }
16
20
  function getAppRunPath(config) {
17
- return node_path_1.default.resolve(paths_1.default.appRun, config.client.moduleFederation?.name || '');
21
+ return node_path_1.default.resolve(paths_1.default.appRun, hasMFAssetsIsolation(config.client.moduleFederation)
22
+ ? config.client.moduleFederation?.name
23
+ : '');
18
24
  }
19
25
  function createRunFolder(config) {
20
26
  const appRunPath = getAppRunPath(config);
@@ -57,13 +57,14 @@ const s3_upload_1 = require("../s3-upload");
57
57
  const log_config_1 = require("../logger/log-config");
58
58
  const utils_2 = require("../typescript/utils");
59
59
  const node_externals_1 = require("./node-externals");
60
+ const utils_3 = require("../utils");
60
61
  const imagesSizeLimit = 2048;
61
62
  const fontSizeLimit = 8192;
62
63
  function getHelperOptions({ webpackMode, config, logger, isSsr = false, configPath, }) {
63
64
  const isEnvDevelopment = webpackMode === "development" /* WebpackMode.Dev */;
64
65
  const isEnvProduction = webpackMode === "production" /* WebpackMode.Prod */;
65
66
  let buildDirectory = config.outputPath || (isSsr ? paths_1.default.appSsrBuild : paths_1.default.appBuild);
66
- if (config.moduleFederation) {
67
+ if ((0, utils_3.hasMFAssetsIsolation)(config.moduleFederation)) {
67
68
  buildDirectory = path.resolve(buildDirectory, config.moduleFederation.name);
68
69
  }
69
70
  return {
@@ -11,7 +11,7 @@ const generateAssetsManifest = (seed, files, entries) => {
11
11
  ...previous,
12
12
  [name]: {
13
13
  assets: {
14
- js: entries[name].filter((file) => file.endsWith('.js')),
14
+ js: entries[name].filter((file) => file.endsWith('.js') && !file.endsWith('.hot-update.js')),
15
15
  css: entries[name].filter((file) => file.endsWith('.css')),
16
16
  },
17
17
  },
@@ -3,8 +3,8 @@ export declare function createCli(argv: string[]): {
3
3
  [x: string]: unknown;
4
4
  verbose: boolean | undefined;
5
5
  cdn: string | undefined;
6
- env: string[] | undefined;
7
6
  target: "client" | "server" | undefined;
7
+ env: string[] | undefined;
8
8
  c: unknown;
9
9
  inspect: number | undefined;
10
10
  inspectBrk: number | undefined;
@@ -33,8 +33,8 @@ export declare function createCli(argv: string[]): {
33
33
  [x: string]: unknown;
34
34
  verbose: boolean | undefined;
35
35
  cdn: string | undefined;
36
- env: string[] | undefined;
37
36
  target: "client" | "server" | undefined;
37
+ env: string[] | undefined;
38
38
  c: unknown;
39
39
  inspect: number | undefined;
40
40
  inspectBrk: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.35.0",
3
+ "version": "0.35.2-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",