@merkur/cli 0.37.4 → 0.37.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/cli",
3
- "version": "0.37.4",
3
+ "version": "0.37.5",
4
4
  "description": "Merkur is tiny and extensible library for creating front-end microservices.",
5
5
  "bin": {
6
6
  "merkur": "./bin/merkur.mjs"
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=20"
69
69
  },
70
- "gitHead": "d54912205822efbb7d3ca53f8dee0775d299853a"
70
+ "gitHead": "af943715deec4b2e509eab4c2a8f6389fd1d4822"
71
71
  }
@@ -1,12 +1,17 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import { gzip, constants } from 'node:zlib';
4
+ import { promisify } from 'node:util';
3
5
 
4
6
  import { createLogger } from '../logger.mjs';
5
7
  import { time } from '../utils.mjs';
8
+ import { COMMAND_NAME } from '../commands/constant.mjs';
6
9
 
7
10
  import chalk from 'chalk';
8
11
 
9
- export function metaPlugin({ definition, config, cliConfig }) {
12
+ const gzipAsync = promisify(gzip);
13
+
14
+ export function metaPlugin({ definition, cliConfig }) {
10
15
  const { projectFolder } = cliConfig;
11
16
  const logger = createLogger('metaPlugin', cliConfig);
12
17
  return {
@@ -25,7 +30,7 @@ export function metaPlugin({ definition, config, cliConfig }) {
25
30
  }
26
31
  let metaInformation = [];
27
32
 
28
- if (config.writeToDisk) {
33
+ if (cliConfig.command === COMMAND_NAME.BUILD) {
29
34
  const generatedFiles = Object.keys(
30
35
  result?.metafile?.outputs ?? {},
31
36
  ).filter((file) => !file.endsWith('.map'));
@@ -36,7 +41,11 @@ export function metaPlugin({ definition, config, cliConfig }) {
36
41
  path.resolve(`${projectFolder}/${file}`),
37
42
  );
38
43
 
39
- return { stat, file };
44
+ const gzipFile = await gzipAsync(await fs.readFile(file), {
45
+ level: constants.Z_BEST_COMPRESSION,
46
+ });
47
+
48
+ return { stat, file, gzipFile };
40
49
  }),
41
50
  );
42
51
  }
@@ -45,9 +54,11 @@ export function metaPlugin({ definition, config, cliConfig }) {
45
54
  `Task ${chalk.bold.green(definition.name)} complete for ${chalk.bold.green(timer())} [ms]`,
46
55
  );
47
56
 
48
- metaInformation.map(({ file, stat }) => {
57
+ metaInformation.map(({ file, gzipFile, stat }) => {
58
+ const { dir, base } = path.parse(file);
59
+
49
60
  logger.log(
50
- ` -> ${chalk.bold(file)}, ${Math.round(stat.size / 1024)} kB`,
61
+ ` -> ${chalk.gray(dir + '/')}${chalk.green(base)}, ${chalk.grey(`min: ${Math.round(stat.size / 1024)} kB, min+gzip: ${Math.round(gzipFile.length / 1024)} kB`)}`,
51
62
  );
52
63
  });
53
64
  });