@merkur/cli 0.37.3 → 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.3",
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": "7237693f163d80defa4a19071419c697cc8785fa"
70
+ "gitHead": "af943715deec4b2e509eab4c2a8f6389fd1d4822"
71
71
  }
@@ -79,6 +79,7 @@ export async function createBuildConfig({
79
79
  },
80
80
  definition,
81
81
  config,
82
+ merkurConfig,
82
83
  cliConfig,
83
84
  context,
84
85
  [RESULT_KEY]: 'build',
@@ -37,7 +37,7 @@ export async function createMerkurConfig({ cliConfig, context, args } = {}) {
37
37
 
38
38
  await loadExtender({ merkurConfig, cliConfig, logger, context });
39
39
 
40
- await registerHooks({ merkurConfig });
40
+ registerHooks({ merkurConfig });
41
41
 
42
42
  cliConfig = await updateCLIConfig({ args, cliConfig, context });
43
43
 
@@ -60,13 +60,16 @@ async function loadExtender({ merkurConfig, cliConfig, logger, context }) {
60
60
  merkurConfig?.extends?.map(async (modulePath) => {
61
61
  try {
62
62
  const file = await import(`${modulePath}`);
63
- await file.default({
63
+ const hooks = await file.default({
64
64
  cliConfig,
65
65
  merkurConfig,
66
66
  context,
67
67
  emitter,
68
68
  EMITTER_EVENTS,
69
+ logger,
69
70
  });
71
+
72
+ registerHooks({ merkurConfig: hooks ?? {} });
70
73
  } catch (error) {
71
74
  logger.error(error);
72
75
  }
@@ -74,7 +77,7 @@ async function loadExtender({ merkurConfig, cliConfig, logger, context }) {
74
77
  );
75
78
  }
76
79
 
77
- async function registerHooks({ merkurConfig }) {
80
+ function registerHooks({ merkurConfig }) {
78
81
  Object.values(EMITTER_EVENTS)
79
82
  .filter((eventName) => eventName in merkurConfig)
80
83
  .forEach((eventName) => {
@@ -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
  });