@merkur/cli 0.35.3 → 0.35.4

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/bin/merkur.mjs CHANGED
@@ -23,12 +23,24 @@ program
23
23
  .option('--buildFolder <string>', 'Build folder.')
24
24
  .option('--staticFolder <string>', 'Static folder.')
25
25
  .option('--staticPath <string>', 'The static path for dev server and widget server.')
26
+ .option('--hasRunDevServer', 'Flag for starting dev server')
27
+ .option('--hasRunWidgetServer', 'Flag for starting widget server')
26
28
  .option('--inspect', 'Debugging widget server')
27
29
  .option('--verbose', 'Verbose mode which show debug information.')
28
30
  .version(packageFile.version);
29
31
 
30
32
  program.command(COMMAND_NAME.DEV).description('Dev command').action(async (options, cmd) => {
31
- const args = { ...{ writeToDisk: false, watch: true, runTask: ['node', 'es13'] }, ...cmd.optsWithGlobals(), ...options };
33
+ const args = {
34
+ ...{
35
+ writeToDisk: false,
36
+ watch: true,
37
+ runTask: ['node', 'es13'],
38
+ hasRunDevServer: true,
39
+ hasRunWidgetServer: true,
40
+ },
41
+ ...cmd.optsWithGlobals(),
42
+ ...options,
43
+ };
32
44
  process.env.NODE_ENV = process.env.NODE_ENV ?? 'development';
33
45
 
34
46
  dev({ args, command: COMMAND_NAME.DEV });
@@ -45,7 +57,7 @@ program.command(COMMAND_NAME.BUILD).action(async (options, cmd) => {
45
57
 
46
58
  program.command(COMMAND_NAME.START).action(async (options, cmd) => {
47
59
  const args = {
48
- ...{ watch: false }, ...cmd.optsWithGlobals(), ...options
60
+ ...{ watch: false, hasRunWidgetServer: true }, ...cmd.optsWithGlobals(), ...options
49
61
  };
50
62
  process.env.NODE_ENV = process.env.NODE_ENV ?? 'production';
51
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/cli",
3
- "version": "0.35.3",
3
+ "version": "0.35.4",
4
4
  "description": "Merkur is tiny and extensible library for creating front-end microservices.",
5
5
  "bin": {
6
6
  "merkur": "./bin/merkur.mjs"
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=20"
67
67
  },
68
- "gitHead": "6b65a5581c1c32a14479c3bb4702c394592d0a20"
68
+ "gitHead": "a78cf3d373ad20dbb2700e4070a52965cebd5a17"
69
69
  }
package/src/CLIConfig.mjs CHANGED
@@ -20,6 +20,8 @@ export async function createCLIConfig({ args, context, command } = {}) {
20
20
  buildFolder: args?.buildFolder ?? './build',
21
21
  staticFolder: args?.staticFolder ?? './build/static',
22
22
  staticPath: args?.staticPath ?? '/static',
23
+ hasRunDevServer: args?.hasRunDevServer ?? false,
24
+ hasRunWidgetServer: args?.hasRunWidgetServer ?? false,
23
25
  inspect: args.inspect ?? false,
24
26
  verbose: args.verbose ?? false,
25
27
  },
@@ -53,7 +53,9 @@ export async function dev({ args, command }) {
53
53
 
54
54
  await Promise.all(Object.values(task));
55
55
 
56
- await runDevServer({ merkurConfig, cliConfig, context });
56
+ cliConfig.hasRunDevServer &&
57
+ (await runDevServer({ merkurConfig, cliConfig, context }));
57
58
  await runSocketServer({ merkurConfig, cliConfig, context });
58
- await runWidgetServer({ merkurConfig, cliConfig, context });
59
+ cliConfig.hasRunWidgetServer &&
60
+ (await runWidgetServer({ merkurConfig, cliConfig, context }));
59
61
  }
package/src/devServer.mjs CHANGED
@@ -84,17 +84,17 @@ export async function runDevServer({ context, merkurConfig, cliConfig }) {
84
84
  }
85
85
 
86
86
  if (asset.type.includes('inline')) {
87
- const path = asset.source.replace(origin, '');
87
+ const assetPath = asset.source.replace(origin, '');
88
88
  if (writeToDisk) {
89
89
  asset.source = fs.readFileSync(
90
90
  path.join(
91
91
  path.resolve(projectFolder, buildFolder),
92
- path,
92
+ assetPath,
93
93
  ),
94
94
  'utf8',
95
95
  );
96
96
  } else {
97
- asset.source = context.memory[path]?.text;
97
+ asset.source = context.memory[assetPath]?.text;
98
98
  }
99
99
  }
100
100
  });
@@ -186,8 +186,10 @@ emitter.on(
186
186
  widgetHandler: async (req) => {
187
187
  const { protocol, host } = merkurConfig.widgetServer;
188
188
  let widgetProperties = null;
189
+ const params = merkurConfig.playground.widgetParams(req);
190
+
189
191
  const response = await fetch(
190
- `${protocol}//${host}/widget?${new URLSearchParams(req.params)}`,
192
+ `${protocol}//${host}/widget${params?.size > 0 ? `?${params}` : ``}`,
191
193
  );
192
194
 
193
195
  widgetProperties = await response.json();
@@ -199,6 +201,9 @@ emitter.on(
199
201
 
200
202
  return widgetProperties;
201
203
  },
204
+ widgetParams: (req) => {
205
+ return new URLSearchParams(req.query);
206
+ },
202
207
  ...merkurConfig.playground,
203
208
  };
204
209
 
@@ -11,7 +11,7 @@
11
11
  <% } %>
12
12
  <%if (asset.type==='inlineStyle' ) { %>
13
13
  <style data-name="<%= asset.name %>">
14
- <%= asset.source %>
14
+ <%- asset.source %>
15
15
  </style>
16
16
  <% } %>
17
17