@meituan-nocode/vite-plugin-nocode-compiler 0.3.1-beta.14 → 0.3.1-beta.15

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/dist/index.cjs CHANGED
@@ -102,9 +102,6 @@ function safeGetModulesByFile(server, filePath) {
102
102
  }
103
103
  function triggerHmrUpdate(server, fullPath, verbose = false) {
104
104
  const modules = server.moduleGraph.getModulesByFile(fullPath);
105
- if (verbose) {
106
- console.log(`[triggerHmrUpdate] fullPath=${fullPath}, modulesFound=${modules ? modules.size : 0}`);
107
- }
108
105
  if (modules && modules.size > 0) {
109
106
  for (const mod of modules) {
110
107
  safeInvalidateModule(server, mod);
@@ -119,6 +116,9 @@ function triggerHmrUpdate(server, fullPath, verbose = false) {
119
116
  }
120
117
  ]
121
118
  });
119
+ if (verbose) {
120
+ console.log(`[vite-compat] HMR triggered for: ${mod.url}`);
121
+ }
122
122
  }
123
123
  } else {
124
124
  const mod = server.moduleGraph.getModuleById(fullPath);
@@ -135,8 +135,6 @@ function triggerHmrUpdate(server, fullPath, verbose = false) {
135
135
  }
136
136
  ]
137
137
  });
138
- } else if (verbose) {
139
- console.warn(`[triggerHmrUpdate] No module found for: ${fullPath}`);
140
138
  }
141
139
  }
142
140
  }
@@ -180,7 +178,7 @@ function readJsonBody(req) {
180
178
  }
181
179
 
182
180
  // package.json
183
- var version = "0.3.1-beta.14";
181
+ var version = "0.3.1-beta.15";
184
182
 
185
183
  // src/design-mode/types.ts
186
184
  var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
@@ -212,12 +210,6 @@ function hasVirtualCode(id) {
212
210
  if (!relativePath) return false;
213
211
  return virtualCodeMap.has(relativePath) || virtualCodeMap.has("/" + relativePath);
214
212
  }
215
- function hasVirtualCodeByAbsolutePath(absolutePath, projectRoot) {
216
- if (virtualCodeMap.size === 0) return false;
217
- const relativePath = absolutePath.startsWith(projectRoot) ? absolutePath.slice(projectRoot.length).replace(/^\//, "") : null;
218
- if (!relativePath) return false;
219
- return virtualCodeMap.has(relativePath) || virtualCodeMap.has("/" + relativePath);
220
- }
221
213
  function shouldSkipDesignModeTransform(id, options) {
222
214
  if (!matchesDesignModePattern(id, options)) return true;
223
215
  if (hasVirtualCode(id)) return true;
@@ -229,7 +221,7 @@ function loadVirtualCode(id, options) {
229
221
  if (!relativePath) return void 0;
230
222
  const code = virtualCodeMap.get(relativePath) || virtualCodeMap.get("/" + relativePath);
231
223
  if (code && options.verbose) {
232
- console.log(`[loadVirtualCode] Returning virtual code for: ${relativePath} (length=${code.length})`);
224
+ console.log(`[DesignMode] Using virtual code for: ${relativePath}`);
233
225
  }
234
226
  return code;
235
227
  }
@@ -260,7 +252,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
260
252
  const { filePath, content } = JSON.parse(body);
261
253
  virtualCodeMap.set(filePath, content);
262
254
  if (verbose) {
263
- console.log(`[VirtualCode POST] filePath=${filePath}, contentLength=${content == null ? void 0 : content.length}, mapSize=${virtualCodeMap.size}`);
255
+ console.log(`[DnD] Virtual code set for: ${filePath}`);
264
256
  }
265
257
  res.end(JSON.stringify({ success: true, filePath }));
266
258
  } catch (error) {
@@ -508,22 +500,6 @@ function componentCompiler(options = {}) {
508
500
  console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
509
501
  }
510
502
  },
511
- /**
512
- * 处理 HMR 更新:
513
- * 当磁盘文件变更触发 Vite file watcher 时,如果该文件存在虚拟代码,
514
- * 让 Vite 原生 HMR 正常执行(不拦截),这样 Vite 内部的 updateModules
515
- * 会走完整流程(propagateUpdate → 客户端 fetch → load 钩子返回虚拟代码)。
516
- *
517
- * 此钩子仅用于诊断日志,不做任何拦截操作。
518
- */
519
- handleHotUpdate(ctx) {
520
- if (!designModeOptions.enableVirtualCode) return;
521
- if (hasVirtualCodeByAbsolutePath(ctx.file, projectRoot)) {
522
- if (designModeOptions.verbose) {
523
- console.log(`[DesignMode] File watcher HMR for virtual-code file: ${ctx.file} (allowing native HMR)`);
524
- }
525
- }
526
- },
527
503
  /**
528
504
  * 转换 index.html:
529
505
  * 1. 在 <body> 标签上注入组件库版本信息和编译插件版本
package/dist/index.js CHANGED
@@ -67,9 +67,6 @@ function safeGetModulesByFile(server, filePath) {
67
67
  }
68
68
  function triggerHmrUpdate(server, fullPath, verbose = false) {
69
69
  const modules = server.moduleGraph.getModulesByFile(fullPath);
70
- if (verbose) {
71
- console.log(`[triggerHmrUpdate] fullPath=${fullPath}, modulesFound=${modules ? modules.size : 0}`);
72
- }
73
70
  if (modules && modules.size > 0) {
74
71
  for (const mod of modules) {
75
72
  safeInvalidateModule(server, mod);
@@ -84,6 +81,9 @@ function triggerHmrUpdate(server, fullPath, verbose = false) {
84
81
  }
85
82
  ]
86
83
  });
84
+ if (verbose) {
85
+ console.log(`[vite-compat] HMR triggered for: ${mod.url}`);
86
+ }
87
87
  }
88
88
  } else {
89
89
  const mod = server.moduleGraph.getModuleById(fullPath);
@@ -100,8 +100,6 @@ function triggerHmrUpdate(server, fullPath, verbose = false) {
100
100
  }
101
101
  ]
102
102
  });
103
- } else if (verbose) {
104
- console.warn(`[triggerHmrUpdate] No module found for: ${fullPath}`);
105
103
  }
106
104
  }
107
105
  }
@@ -145,7 +143,7 @@ function readJsonBody(req) {
145
143
  }
146
144
 
147
145
  // package.json
148
- var version = "0.3.1-beta.14";
146
+ var version = "0.3.1-beta.15";
149
147
 
150
148
  // src/design-mode/types.ts
151
149
  var SANDBOX_SCRIPT_PATH = "/sandbox-script.js";
@@ -177,12 +175,6 @@ function hasVirtualCode(id) {
177
175
  if (!relativePath) return false;
178
176
  return virtualCodeMap.has(relativePath) || virtualCodeMap.has("/" + relativePath);
179
177
  }
180
- function hasVirtualCodeByAbsolutePath(absolutePath, projectRoot) {
181
- if (virtualCodeMap.size === 0) return false;
182
- const relativePath = absolutePath.startsWith(projectRoot) ? absolutePath.slice(projectRoot.length).replace(/^\//, "") : null;
183
- if (!relativePath) return false;
184
- return virtualCodeMap.has(relativePath) || virtualCodeMap.has("/" + relativePath);
185
- }
186
178
  function shouldSkipDesignModeTransform(id, options) {
187
179
  if (!matchesDesignModePattern(id, options)) return true;
188
180
  if (hasVirtualCode(id)) return true;
@@ -194,7 +186,7 @@ function loadVirtualCode(id, options) {
194
186
  if (!relativePath) return void 0;
195
187
  const code = virtualCodeMap.get(relativePath) || virtualCodeMap.get("/" + relativePath);
196
188
  if (code && options.verbose) {
197
- console.log(`[loadVirtualCode] Returning virtual code for: ${relativePath} (length=${code.length})`);
189
+ console.log(`[DesignMode] Using virtual code for: ${relativePath}`);
198
190
  }
199
191
  return code;
200
192
  }
@@ -225,7 +217,7 @@ function createVirtualCodeMiddleware(server, options, projectRoot) {
225
217
  const { filePath, content } = JSON.parse(body);
226
218
  virtualCodeMap.set(filePath, content);
227
219
  if (verbose) {
228
- console.log(`[VirtualCode POST] filePath=${filePath}, contentLength=${content == null ? void 0 : content.length}, mapSize=${virtualCodeMap.size}`);
220
+ console.log(`[DnD] Virtual code set for: ${filePath}`);
229
221
  }
230
222
  res.end(JSON.stringify({ success: true, filePath }));
231
223
  } catch (error) {
@@ -473,22 +465,6 @@ function componentCompiler(options = {}) {
473
465
  console.log(`[DesignMode] Virtual code API enabled at ${designModeOptions.virtualCodeApiPath}`);
474
466
  }
475
467
  },
476
- /**
477
- * 处理 HMR 更新:
478
- * 当磁盘文件变更触发 Vite file watcher 时,如果该文件存在虚拟代码,
479
- * 让 Vite 原生 HMR 正常执行(不拦截),这样 Vite 内部的 updateModules
480
- * 会走完整流程(propagateUpdate → 客户端 fetch → load 钩子返回虚拟代码)。
481
- *
482
- * 此钩子仅用于诊断日志,不做任何拦截操作。
483
- */
484
- handleHotUpdate(ctx) {
485
- if (!designModeOptions.enableVirtualCode) return;
486
- if (hasVirtualCodeByAbsolutePath(ctx.file, projectRoot)) {
487
- if (designModeOptions.verbose) {
488
- console.log(`[DesignMode] File watcher HMR for virtual-code file: ${ctx.file} (allowing native HMR)`);
489
- }
490
- }
491
- },
492
468
  /**
493
469
  * 转换 index.html:
494
470
  * 1. 在 <body> 标签上注入组件库版本信息和编译插件版本
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meituan-nocode/vite-plugin-nocode-compiler",
3
- "version": "0.3.1-beta.14",
3
+ "version": "0.3.1-beta.15",
4
4
  "description": "Vite plugin for nocode compiler",
5
5
  "type": "module",
6
6
  "exports": {