@gravity-ui/app-builder 0.29.3-beta.0 → 0.30.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.
Files changed (64) hide show
  1. package/README.md +138 -0
  2. package/dist/cli.js +17 -22
  3. package/dist/commands/build/build-lib.js +5 -8
  4. package/dist/commands/build/build-service/client.js +3 -6
  5. package/dist/commands/build/build-service/index.js +4 -7
  6. package/dist/commands/build/build-service/server.js +11 -17
  7. package/dist/commands/build/index.js +3 -6
  8. package/dist/commands/dev/client.js +34 -63
  9. package/dist/commands/dev/index.js +26 -47
  10. package/dist/commands/dev/server.js +13 -42
  11. package/dist/common/babel/index.js +1 -4
  12. package/dist/common/babel/ui-preset.d.ts +1 -1
  13. package/dist/common/babel/ui-preset.js +0 -1
  14. package/dist/common/child-process/controllable-script.js +5 -32
  15. package/dist/common/child-process/utils.js +4 -30
  16. package/dist/common/command.js +1 -2
  17. package/dist/common/config.js +36 -45
  18. package/dist/common/env.js +3 -5
  19. package/dist/common/library/babel-plugin-replace-paths.js +2 -4
  20. package/dist/common/library/index.js +66 -95
  21. package/dist/common/logger/colors.js +2 -8
  22. package/dist/common/logger/index.js +17 -24
  23. package/dist/common/logger/log-config.js +3 -6
  24. package/dist/common/logger/pretty-time.js +2 -6
  25. package/dist/common/models/index.d.ts +66 -1
  26. package/dist/common/models/index.js +3 -8
  27. package/dist/common/paths.js +3 -28
  28. package/dist/common/s3-upload/compress.js +8 -12
  29. package/dist/common/s3-upload/create-plugin.js +9 -7
  30. package/dist/common/s3-upload/index.js +3 -9
  31. package/dist/common/s3-upload/s3-client.js +11 -37
  32. package/dist/common/s3-upload/upload.js +9 -38
  33. package/dist/common/s3-upload/webpack-plugin.js +5 -9
  34. package/dist/common/swc/compile.js +9 -12
  35. package/dist/common/swc/index.js +2 -7
  36. package/dist/common/swc/utils.js +6 -13
  37. package/dist/common/swc/watch.js +6 -9
  38. package/dist/common/typescript/compile.js +11 -14
  39. package/dist/common/typescript/diagnostic.js +11 -37
  40. package/dist/common/typescript/transformers.js +3 -29
  41. package/dist/common/typescript/utils.js +8 -18
  42. package/dist/common/typescript/watch.js +10 -13
  43. package/dist/common/utils.d.ts +3 -1
  44. package/dist/common/utils.js +16 -22
  45. package/dist/common/webpack/compile.js +16 -22
  46. package/dist/common/webpack/config.d.ts +0 -2
  47. package/dist/common/webpack/config.js +187 -137
  48. package/dist/common/webpack/node-externals.js +5 -34
  49. package/dist/common/webpack/progress-plugin.js +3 -6
  50. package/dist/common/webpack/public-path.d.ts +0 -1
  51. package/dist/common/webpack/public-path.js +1 -1
  52. package/dist/common/webpack/rspack.js +1 -5
  53. package/dist/common/webpack/runtime-versioning-plugin.d.ts +5 -0
  54. package/dist/common/webpack/runtime-versioning-plugin.js +20 -0
  55. package/dist/common/webpack/storybook.js +21 -53
  56. package/dist/common/webpack/utils.js +9 -36
  57. package/dist/common/webpack/worker/public-path.worker.d.ts +0 -1
  58. package/dist/common/webpack/worker/public-path.worker.js +2 -1
  59. package/dist/common/webpack/worker/worker-loader.js +4 -34
  60. package/dist/create-cli.d.ts +2 -2
  61. package/dist/create-cli.js +19 -48
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +5 -27
  64. package/package.json +9 -6
@@ -1,47 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.buildLibrary = buildLibrary;
30
- const path = __importStar(require("node:path"));
31
- const fs = __importStar(require("node:fs"));
32
- const childProcess = __importStar(require("node:child_process"));
33
- const node_url_1 = require("node:url");
34
- const babel = __importStar(require("@babel/core"));
35
- const fast_glob_1 = require("fast-glob");
36
- const rimraf_1 = require("rimraf");
37
- const sass_1 = __importDefault(require("sass"));
38
- const postcss_1 = __importDefault(require("postcss"));
39
- const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
40
- const core_1 = require("@svgr/core");
41
- const paths_1 = __importDefault(require("../../common/paths"));
42
- const logger_1 = __importDefault(require("../../common/logger"));
43
- const babel_1 = require("../babel");
44
- function getFilePath(filePath, { ext, dir } = { dir: paths_1.default.src }) {
1
+ import * as path from 'node:path';
2
+ import * as fs from 'node:fs';
3
+ import * as childProcess from 'node:child_process';
4
+ import { fileURLToPath, pathToFileURL } from 'node:url';
5
+ import * as babel from '@babel/core';
6
+ import { globStream } from 'fast-glob';
7
+ import { rimraf } from 'rimraf';
8
+ import sass from 'sass';
9
+ import postcss from 'postcss';
10
+ import postcssPresetEnv from 'postcss-preset-env';
11
+ import { transform } from '@svgr/core';
12
+ import paths from '../../common/paths';
13
+ import logger from '../../common/logger';
14
+ import { babelPreset } from '../babel';
15
+ function getFilePath(filePath, { ext, dir } = { dir: paths.src }) {
45
16
  let filePathWithExt = filePath;
46
17
  if (ext) {
47
18
  filePathWithExt = filePath.replace(path.extname(filePath), `.${ext}`);
@@ -52,21 +23,21 @@ function errorHandlerFactory(msg) {
52
23
  return (err) => {
53
24
  if (err) {
54
25
  if (msg) {
55
- logger_1.default.error(msg);
26
+ logger.error(msg);
56
27
  }
57
- logger_1.default.error(err.toString());
28
+ logger.error(err.toString());
58
29
  throw err;
59
30
  }
60
31
  };
61
32
  }
62
- function copyToCjs(file, inputDir = paths_1.default.libBuildEsm) {
33
+ function copyToCjs(file, inputDir = paths.libBuildEsm) {
63
34
  const esmFile = getFilePath(file, { dir: inputDir });
64
- const cjsFile = getFilePath(file, { dir: paths_1.default.libBuildCjs });
35
+ const cjsFile = getFilePath(file, { dir: paths.libBuildCjs });
65
36
  const cjsDir = path.dirname(cjsFile);
66
37
  fs.mkdirSync(cjsDir, { recursive: true });
67
38
  fs.copyFile(esmFile, cjsFile, errorHandlerFactory(`Failed to copy file to cjs ${esmFile}`));
68
39
  }
69
- function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.src, compiledDir = paths_1.default.libBuildCjs) {
40
+ function compileToCjs(code, file, inputSourceMap, sourceDir = paths.src, compiledDir = paths.libBuildCjs) {
70
41
  const sourceFile = getFilePath(file, { dir: sourceDir });
71
42
  const compiledCjsFile = getFilePath(file, { dir: compiledDir, ext: 'js' });
72
43
  const compiledCjsDir = path.dirname(compiledCjsFile);
@@ -85,8 +56,8 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.sr
85
56
  inputSourceMap,
86
57
  }, (err, transformedCjs) => {
87
58
  if (err) {
88
- logger_1.default.error(`Source compilation errors for ${sourceFile}`);
89
- logger_1.default.error(err.toString());
59
+ logger.error(`Source compilation errors for ${sourceFile}`);
60
+ logger.error(err.toString());
90
61
  throw err;
91
62
  }
92
63
  else if (transformedCjs) {
@@ -100,7 +71,7 @@ function compileToCjs(code, file, inputSourceMap, sourceDir = paths_1.default.sr
100
71
  });
101
72
  }
102
73
  function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
103
- const origStylesStream = (0, fast_glob_1.globStream)(['**/*.{sass,scss,css}', ...additionalGlobs], {
74
+ const origStylesStream = globStream(['**/*.{sass,scss,css}', ...additionalGlobs], {
104
75
  cwd: inputDir,
105
76
  });
106
77
  origStylesStream.on('data', (file) => {
@@ -116,24 +87,24 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
116
87
  }
117
88
  });
118
89
  origStylesStream.on('finish', () => {
119
- const globs = outputDir === paths_1.default.libBuildEsm
90
+ const globs = outputDir === paths.libBuildEsm
120
91
  ? ['**/*.{sass,scss,css}', '!cjs/**/*']
121
92
  : ['**/*.{sass,scss,css}'];
122
- const stylesStream = (0, fast_glob_1.globStream)(globs, { cwd: outputDir });
93
+ const stylesStream = globStream(globs, { cwd: outputDir });
123
94
  stylesStream.on('data', async (file) => {
124
95
  const origScssFile = getFilePath(file, { dir: inputDir });
125
96
  const scssFile = getFilePath(file, { dir: outputDir });
126
97
  const cssFile = getFilePath(file, { dir: outputDir, ext: 'css' });
127
98
  const sourceMapFile = getFilePath(file, { dir: outputDir, ext: 'css.map' });
128
99
  try {
129
- const sassTransformed = sass_1.default.compile(scssFile, {
100
+ const sassTransformed = sass.compile(scssFile, {
130
101
  sourceMap: true,
131
102
  sourceMapIncludeSources: true,
132
103
  importers: [
133
104
  {
134
105
  findFileUrl(url) {
135
106
  if (url.startsWith('~')) {
136
- return (0, node_url_1.pathToFileURL)(getFilePath(url.substring(1), { dir: paths_1.default.appNodeModules }));
107
+ return pathToFileURL(getFilePath(url.substring(1), { dir: paths.appNodeModules }));
137
108
  }
138
109
  throw new Error(`Unrecognized import ${url} in ${origScssFile}`);
139
110
  },
@@ -144,11 +115,11 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
144
115
  const sourceMap = sassTransformed.sourceMap;
145
116
  if (sourceMap) {
146
117
  sourceMap.sources = sourceMap.sources.map((url) => {
147
- return path.relative(path.dirname(scssFile), (0, node_url_1.fileURLToPath)(url));
118
+ return path.relative(path.dirname(scssFile), fileURLToPath(url));
148
119
  });
149
120
  }
150
- const postcssTransformed = await (0, postcss_1.default)([
151
- (0, postcss_preset_env_1.default)({ enableClientSidePolyfills: false }),
121
+ const postcssTransformed = await postcss([
122
+ postcssPresetEnv({ enableClientSidePolyfills: false }),
152
123
  ]).process(sassTransformed.css, {
153
124
  to: path.basename(cssFile),
154
125
  from: path.basename(scssFile),
@@ -165,7 +136,7 @@ function compileStyles(inputDir, outputDir, onFinish, additionalGlobs = []) {
165
136
  }
166
137
  }
167
138
  catch (sassErr) {
168
- logger_1.default.error(`Style compilation errors for ${scssFile}`);
139
+ logger.error(`Style compilation errors for ${scssFile}`);
169
140
  throw sassErr;
170
141
  }
171
142
  });
@@ -178,19 +149,19 @@ const svgoPreset = {
178
149
  name: 'preset-default',
179
150
  params: { overrides: { removeViewBox: false } },
180
151
  };
181
- function buildLibrary(config) {
152
+ export function buildLibrary(config) {
182
153
  const internalGlobs = config.lib?.internalDirs?.map((dir) => `!${dir}/**/*`) ?? [];
183
- rimraf_1.rimraf.sync(paths_1.default.libBuild);
184
- const tsConfigFilePath = path.resolve(paths_1.default.app, 'tsconfig.publish.json');
154
+ rimraf.sync(paths.libBuild);
155
+ const tsConfigFilePath = path.resolve(paths.app, 'tsconfig.publish.json');
185
156
  // sources compilation
186
- const sourceStream = (0, fast_glob_1.globStream)(['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', ...internalGlobs], {
187
- cwd: paths_1.default.src,
157
+ const sourceStream = globStream(['**/*.{js,jsx,ts,tsx}', '!**/*.d.ts', ...internalGlobs], {
158
+ cwd: paths.src,
188
159
  });
189
160
  sourceStream.on('data', (file) => {
190
161
  const sourceFile = getFilePath(file);
191
- const compiledFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js' });
162
+ const compiledFile = getFilePath(file, { dir: paths.libBuildEsm, ext: 'js' });
192
163
  const compiledDir = path.dirname(compiledFile);
193
- const sourcemapFile = getFilePath(file, { dir: paths_1.default.libBuildEsm, ext: 'js.map' });
164
+ const sourcemapFile = getFilePath(file, { dir: paths.libBuildEsm, ext: 'js.map' });
194
165
  const sourcemapUrl = `// #sourceMappingURL=${path.basename(sourcemapFile)}`;
195
166
  const source = fs.readFileSync(sourceFile, 'utf-8');
196
167
  fs.mkdirSync(compiledDir, { recursive: true });
@@ -198,7 +169,7 @@ function buildLibrary(config) {
198
169
  babelrc: false,
199
170
  configFile: false,
200
171
  filename: sourceFile,
201
- presets: [(0, babel_1.babelPreset)(config.lib)],
172
+ presets: [babelPreset(config.lib)],
202
173
  plugins: [
203
174
  [
204
175
  require.resolve('babel-plugin-inline-react-svg'),
@@ -228,8 +199,8 @@ function buildLibrary(config) {
228
199
  sourceMaps: true,
229
200
  }, (err, transformed) => {
230
201
  if (err) {
231
- logger_1.default.error(`Source compilation errors for ${sourceFile}`);
232
- logger_1.default.error(err.toString());
202
+ logger.error(`Source compilation errors for ${sourceFile}`);
203
+ logger.error(err.toString());
233
204
  throw err;
234
205
  }
235
206
  else if (transformed) {
@@ -244,28 +215,28 @@ function buildLibrary(config) {
244
215
  });
245
216
  });
246
217
  // type definitions compilation and type checking
247
- const tscExec = path.resolve(paths_1.default.appNodeModules, 'typescript/bin/tsc');
218
+ const tscExec = path.resolve(paths.appNodeModules, 'typescript/bin/tsc');
248
219
  // eslint-disable-next-line security/detect-child-process
249
220
  childProcess.exec(`${tscExec} -p ${tsConfigFilePath} --declaration --emitDeclarationOnly --outDir build/esm`, (error, stdout, stderr) => {
250
- logger_1.default.message(stdout);
251
- logger_1.default.error(stderr);
221
+ logger.message(stdout);
222
+ logger.error(stderr);
252
223
  if (!error && !stderr) {
253
- logger_1.default.message('Typechecking successfully completed');
254
- const typingsStream = (0, fast_glob_1.globStream)(['**/*.d.ts', '!cjs/**/*'], {
255
- cwd: paths_1.default.libBuildEsm,
224
+ logger.message('Typechecking successfully completed');
225
+ const typingsStream = globStream(['**/*.d.ts', '!cjs/**/*'], {
226
+ cwd: paths.libBuildEsm,
256
227
  });
257
228
  typingsStream.on('data', copyToCjs);
258
229
  }
259
230
  else {
260
- logger_1.default.error('Errors during library typechecking. Aborting...');
231
+ logger.error('Errors during library typechecking. Aborting...');
261
232
  process.exit(1);
262
233
  }
263
234
  });
264
235
  // css compilation
265
- compileStyles(paths_1.default.libGlobalStyles, paths_1.default.libCompiledGlobalStyles, () => {
266
- compileStyles(paths_1.default.src, paths_1.default.libBuildEsm, () => {
267
- const stylesStream = (0, fast_glob_1.globStream)(['**/*.{css,css.map}'], {
268
- cwd: paths_1.default.libBuildEsm,
236
+ compileStyles(paths.libGlobalStyles, paths.libCompiledGlobalStyles, () => {
237
+ compileStyles(paths.src, paths.libBuildEsm, () => {
238
+ const stylesStream = globStream(['**/*.{css,css.map}'], {
239
+ cwd: paths.libBuildEsm,
269
240
  });
270
241
  stylesStream.on('data', copyToCjs);
271
242
  }, internalGlobs);
@@ -281,15 +252,15 @@ function buildLibrary(config) {
281
252
  export default icon;
282
253
  `;
283
254
  const svgoRegEx = /assets\/icons/;
284
- const iconsStream = (0, fast_glob_1.globStream)(['**/*.svg', ...internalGlobs], { cwd: paths_1.default.libAssets });
255
+ const iconsStream = globStream(['**/*.svg', ...internalGlobs], { cwd: paths.libAssets });
285
256
  iconsStream.on('data', async (file) => {
286
- const iconFile = getFilePath(file, { dir: paths_1.default.libAssets });
287
- const componentFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'js' });
257
+ const iconFile = getFilePath(file, { dir: paths.libAssets });
258
+ const componentFile = getFilePath(file, { dir: paths.libCompiledAssetsEsm, ext: 'js' });
288
259
  const componentDir = path.dirname(componentFile);
289
- const componentDefFile = getFilePath(file, { dir: paths_1.default.libCompiledAssetsEsm, ext: 'd.ts' });
260
+ const componentDefFile = getFilePath(file, { dir: paths.libCompiledAssetsEsm, ext: 'd.ts' });
290
261
  if (svgoRegEx.test(iconFile)) {
291
262
  try {
292
- const component = await (0, core_1.transform)(fs.readFileSync(iconFile, 'utf-8'), {
263
+ const component = await transform(fs.readFileSync(iconFile, 'utf-8'), {
293
264
  jsxRuntime: config.lib.newJsxTransform ? 'automatic' : 'classic',
294
265
  plugins: [require.resolve('@svgr/plugin-jsx')],
295
266
  });
@@ -297,12 +268,12 @@ function buildLibrary(config) {
297
268
  babelrc: false,
298
269
  configFile: false,
299
270
  filename: iconFile,
300
- presets: [(0, babel_1.babelPreset)(config.lib)],
271
+ presets: [babelPreset(config.lib)],
301
272
  sourceMaps: true,
302
273
  }, (err, transformed) => {
303
274
  if (err) {
304
- logger_1.default.error(`Icons compilation errors for ${iconFile}`);
305
- logger_1.default.error(err.toString());
275
+ logger.error(`Icons compilation errors for ${iconFile}`);
276
+ logger.error(err.toString());
306
277
  throw err;
307
278
  }
308
279
  else if (transformed) {
@@ -310,13 +281,13 @@ function buildLibrary(config) {
310
281
  fs.mkdirSync(componentDir, { recursive: true });
311
282
  fs.writeFile(componentFile, transformed.code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
312
283
  fs.writeFile(componentDefFile, iconBaseDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
313
- compileToCjs(transformed.code, file, transformed.map, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
284
+ compileToCjs(transformed.code, file, transformed.map, paths.libAssets, paths.libCompiledAssetsCjs);
314
285
  }
315
286
  }
316
287
  });
317
288
  }
318
289
  catch (err) {
319
- logger_1.default.error(`Svgo compilation errors for ${iconFile}`);
290
+ logger.error(`Svgo compilation errors for ${iconFile}`);
320
291
  throw err;
321
292
  }
322
293
  }
@@ -326,17 +297,17 @@ function buildLibrary(config) {
326
297
  fs.mkdirSync(componentDir, { recursive: true });
327
298
  fs.writeFile(componentFile, code, errorHandlerFactory(`Icons compilation has failed on writing ${componentFile}`));
328
299
  fs.writeFile(componentDefFile, iconSvgoDefinition, errorHandlerFactory(`Icons compilations has failed on writing ${componentFile}`));
329
- compileToCjs(code, file, undefined, paths_1.default.libAssets, paths_1.default.libCompiledAssetsCjs);
300
+ compileToCjs(code, file, undefined, paths.libAssets, paths.libCompiledAssetsCjs);
330
301
  }
331
302
  });
332
303
  // file assets copying
333
- const assetsStream = (0, fast_glob_1.globStream)(['**/*.json', '!**/tsconfig.json', '**/*.d.ts', ...internalGlobs], { cwd: paths_1.default.src });
304
+ const assetsStream = globStream(['**/*.json', '!**/tsconfig.json', '**/*.d.ts', ...internalGlobs], { cwd: paths.src });
334
305
  assetsStream.on('data', (file) => {
335
306
  const assetFile = getFilePath(file);
336
- const copiedAssetFile = getFilePath(file, { dir: paths_1.default.libBuildEsm });
307
+ const copiedAssetFile = getFilePath(file, { dir: paths.libBuildEsm });
337
308
  const assetDir = path.dirname(copiedAssetFile);
338
309
  fs.mkdirSync(assetDir, { recursive: true });
339
310
  fs.copyFile(assetFile, copiedAssetFile, errorHandlerFactory(`Failed to copy file ${assetFile}`));
340
- copyToCjs(file, paths_1.default.src);
311
+ copyToCjs(file, paths.src);
341
312
  });
342
313
  }
@@ -1,8 +1,2 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.colors = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- exports.colors = chalk_1.default;
1
+ import chalk from 'chalk';
2
+ export const colors = chalk;
@@ -1,19 +1,13 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Logger = void 0;
7
- const colors_1 = require("./colors");
8
- const pretty_time_1 = require("./pretty-time");
9
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
1
+ import { colors } from './colors';
2
+ import { elapsedTime } from './pretty-time';
3
+ import stripAnsi from 'strip-ansi';
10
4
  const allColors = [
11
- colors_1.colors.cyan.bold,
12
- colors_1.colors.blue.bold,
13
- colors_1.colors.yellow.bold,
14
- colors_1.colors.magenta.bold,
15
- colors_1.colors.green.bold,
16
- colors_1.colors.grey.bold,
5
+ colors.cyan.bold,
6
+ colors.blue.bold,
7
+ colors.yellow.bold,
8
+ colors.magenta.bold,
9
+ colors.green.bold,
10
+ colors.grey.bold,
17
11
  ];
18
12
  function selectColor(namespace) {
19
13
  let hash = 0;
@@ -23,14 +17,14 @@ function selectColor(namespace) {
23
17
  hash |= 0; // Convert to 32bit integer
24
18
  /* eslint-enable no-bitwise */
25
19
  }
26
- return allColors[Math.abs(hash) % allColors.length] ?? colors_1.colors.green.bold;
20
+ return allColors[Math.abs(hash) % allColors.length] ?? colors.green.bold;
27
21
  }
28
- class Logger {
29
- colors = colors_1.colors;
22
+ export class Logger {
23
+ colors = colors;
30
24
  _verbose = false;
31
25
  _namespace = '';
32
26
  _timestamp = BigInt(0);
33
- _color = colors_1.colors.black;
27
+ _color = colors.black;
34
28
  constructor(namespace = '', verbose = false) {
35
29
  this._verbose = verbose;
36
30
  if (namespace) {
@@ -42,13 +36,13 @@ class Logger {
42
36
  return;
43
37
  }
44
38
  const prefix = this._namespace ? this._color(`[${this._namespace}]`) + ' ' : '';
45
- const postfix = this._timestamp > 0 ? ' ' + this._color(`+${(0, pretty_time_1.elapsedTime)(this._timestamp)}`) : '';
39
+ const postfix = this._timestamp > 0 ? ' ' + this._color(`+${elapsedTime(this._timestamp)}`) : '';
46
40
  let output = prefix + message + postfix;
47
41
  if (wrap) {
48
42
  const width = process.stdout.columns || (process.stdout.isTTY ? 80 : 200);
49
- if ((0, strip_ansi_1.default)(output).length > width) {
43
+ if (stripAnsi(output).length > width) {
50
44
  output =
51
- prefix + message.slice(0, width - (0, strip_ansi_1.default)(prefix + postfix).length) + postfix;
45
+ prefix + message.slice(0, width - stripAnsi(prefix + postfix).length) + postfix;
52
46
  }
53
47
  }
54
48
  process.stdout.write(output);
@@ -118,5 +112,4 @@ class Logger {
118
112
  this._color = selectColor(namespace);
119
113
  };
120
114
  }
121
- exports.Logger = Logger;
122
- exports.default = new Logger();
115
+ export default new Logger();
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logConfig = logConfig;
4
1
  /* eslint-disable no-console */
5
- const colors_1 = require("./colors");
6
- function logConfig(caption, config) {
7
- console.log(colors_1.colors.cyan(caption));
2
+ import { colors } from './colors';
3
+ export function logConfig(caption, config) {
4
+ console.log(colors.cyan(caption));
8
5
  console.dir(config, { depth: Infinity });
9
6
  }
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.elapsedTime = elapsedTime;
4
- exports.prettyTime = prettyTime;
5
1
  const scale = {
6
2
  w: BigInt(6048e11),
7
3
  d: BigInt(864e11),
@@ -12,11 +8,11 @@ const scale = {
12
8
  μs: BigInt(1e3),
13
9
  ns: BigInt(1),
14
10
  };
15
- function elapsedTime(time, smallest = 'ms') {
11
+ export function elapsedTime(time, smallest = 'ms') {
16
12
  const elapsed = process.hrtime.bigint() - time;
17
13
  return prettyTime(elapsed, smallest);
18
14
  }
19
- function prettyTime(time, smallest = 'ms') {
15
+ export function prettyTime(time, smallest = 'ms') {
20
16
  let elapsed = time;
21
17
  let res = '';
22
18
  let count = 0;
@@ -16,6 +16,7 @@ import type { WebpackMode } from '../webpack/config';
16
16
  import type { UploadOptions } from '../s3-upload/upload';
17
17
  import type { TerserOptions } from 'terser-webpack-plugin';
18
18
  import type { ReactRefreshPluginOptions } from '@pmmmwh/react-refresh-webpack-plugin/types/lib/types';
19
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
19
20
  type Bundler = 'webpack' | 'rspack';
20
21
  type JavaScriptLoader = 'babel' | 'swc';
21
22
  type ServerCompiler = 'typescript' | 'swc';
@@ -59,6 +60,64 @@ interface LazyCompilationConfig {
59
60
  */
60
61
  entries?: boolean;
61
62
  }
63
+ export type ModuleFederationConfig = Omit<moduleFederationPlugin.ModuleFederationPluginOptions, 'name' | 'remotes'> & {
64
+ /**
65
+ * Unique name of the application in the Module Federation ecosystem
66
+ * Used as an identifier for this micro-frontend
67
+ */
68
+ name: string;
69
+ /**
70
+ * Application version, appended to the entry file name
71
+ * When specified, the file will be named `entry-{version}.js`
72
+ * @default undefined (file will be named `entry.js`)
73
+ */
74
+ version?: string;
75
+ /**
76
+ * Base URL for loading resources of this micro-frontend
77
+ * Should point to a publicly accessible URL where the files will be hosted
78
+ * @example 'https://cdn.example.com/my-app/'
79
+ */
80
+ publicPath: string;
81
+ /**
82
+ * List of remote application names that this application can load
83
+ * Simplified alternative to originalRemotes - only names are specified
84
+ * @example ['header', 'footer', 'navigation']
85
+ */
86
+ remotes?: string[];
87
+ /**
88
+ * Full configuration of remote applications in Module Federation format
89
+ * Allows more detailed configuration of each remote application
90
+ * @example { header: 'header@https://header.example.com/remoteEntry.js' }
91
+ */
92
+ originalRemotes?: moduleFederationPlugin.ModuleFederationPluginOptions['remotes'];
93
+ /**
94
+ * Enables runtime versioning for remote applications
95
+ * When enabled, remote applications will be loaded with version in the filename
96
+ * @default false
97
+ */
98
+ remotesRuntimeVersioning?: boolean;
99
+ /**
100
+ * CSS style isolation settings to prevent conflicts
101
+ * between styles of different micro-frontends
102
+ */
103
+ isolateStyles?: {
104
+ /**
105
+ * Function to generate CSS class prefix
106
+ * @param entryName - Application entry name
107
+ * @returns Prefix string for CSS classes
108
+ */
109
+ getPrefix: (entryName: string) => string;
110
+ /**
111
+ * Function to add prefix to CSS selectors
112
+ * @param prefix - Prefix to add
113
+ * @param selector - Original CSS selector
114
+ * @param prefixedSelector - Selector with added prefix
115
+ * @param filePath - Path to the styles file
116
+ * @returns Modified CSS selector
117
+ */
118
+ prefixSelector: (prefix: string, selector: string, prefixedSelector: string, filePath: string) => string;
119
+ };
120
+ };
62
121
  export interface ClientConfig {
63
122
  modules?: string[];
64
123
  /**
@@ -248,6 +307,11 @@ export interface ClientConfig {
248
307
  };
249
308
  bundler?: Bundler;
250
309
  javaScriptLoader?: JavaScriptLoader;
310
+ /**
311
+ * Module Federation configuration for building micro-frontends
312
+ * @see https://module-federation.io/
313
+ */
314
+ moduleFederation?: ModuleFederationConfig;
251
315
  }
252
316
  export interface CdnUploadConfig {
253
317
  bucket: string;
@@ -281,7 +345,7 @@ export interface ServiceConfig {
281
345
  verbose?: boolean;
282
346
  configPath?: string;
283
347
  }
284
- export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'publicPath' | 'assetsManifestFile' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker' | 'disableReactRefresh'> & {
348
+ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'publicPath' | 'assetsManifestFile' | 'hiddenSourceMap' | 'svgr' | 'lazyCompilation' | 'devServer' | 'disableForkTsChecker' | 'disableReactRefresh' | 'transformCssWithLightningCss'> & {
285
349
  bundler: Bundler;
286
350
  javaScriptLoader: JavaScriptLoader;
287
351
  publicPath: string;
@@ -294,6 +358,7 @@ export type NormalizedClientConfig = Omit<ClientConfig, 'publicPathPrefix' | 'pu
294
358
  server?: ServerConfiguration;
295
359
  };
296
360
  verbose?: boolean;
361
+ transformCssWithLightningCss: boolean;
297
362
  webpack: (config: Configuration, options: {
298
363
  configType: `${WebpackMode}`;
299
364
  isSsr: boolean;
@@ -1,14 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isServiceConfig = isServiceConfig;
4
- exports.isLibraryConfig = isLibraryConfig;
5
- exports.defineConfig = defineConfig;
6
- function isServiceConfig(config) {
1
+ export function isServiceConfig(config) {
7
2
  return !('lib' in config);
8
3
  }
9
- function isLibraryConfig(config) {
4
+ export function isLibraryConfig(config) {
10
5
  return 'lib' in config;
11
6
  }
12
- function defineConfig(config) {
7
+ export function defineConfig(config) {
13
8
  return config;
14
9
  }
@@ -1,33 +1,8 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("node:fs"));
27
- const path = __importStar(require("node:path"));
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
28
3
  const appDirectory = fs.realpathSync(process.cwd());
29
4
  const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
30
- exports.default = {
5
+ export default {
31
6
  app: resolveApp('.'),
32
7
  appNodeModules: resolveApp('node_modules'),
33
8
  appClient: resolveApp('src/ui'),
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gzip = gzip;
4
- exports.brotli = brotli;
5
- const node_fs_1 = require("node:fs");
6
- const zlib_1 = require("zlib");
1
+ import { createReadStream, createWriteStream } from 'node:fs';
2
+ import { createBrotliCompress, createGzip } from 'zlib';
7
3
  function compressor(sourcePath, destinationPath, transformer) {
8
4
  return new Promise((resolve, reject) => {
9
- const sourceStream = (0, node_fs_1.createReadStream)(sourcePath);
5
+ const sourceStream = createReadStream(sourcePath);
10
6
  sourceStream.on('error', reject);
11
- const destinationStream = (0, node_fs_1.createWriteStream)(destinationPath);
7
+ const destinationStream = createWriteStream(destinationPath);
12
8
  destinationStream.on('finish', () => resolve(destinationPath));
13
9
  destinationStream.on('error', reject);
14
10
  sourceStream.pipe(transformer).pipe(destinationStream);
15
11
  });
16
12
  }
17
- function gzip(sourcePath) {
18
- return compressor(sourcePath, `${sourcePath}.gz`, (0, zlib_1.createGzip)({}));
13
+ export function gzip(sourcePath) {
14
+ return compressor(sourcePath, `${sourcePath}.gz`, createGzip({}));
19
15
  }
20
- function brotli(sourcePath) {
21
- return compressor(sourcePath, `${sourcePath}.br`, (0, zlib_1.createBrotliCompress)());
16
+ export function brotli(sourcePath) {
17
+ return compressor(sourcePath, `${sourcePath}.br`, createBrotliCompress());
22
18
  }