@lensmcp/vite-plugin 1.18.1 → 1.18.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/lib/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAElD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKzE,UAAU,SAAS;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,EAChC,IAAI,GAAE,SAAc,GACnB,MAAM,GAAG,kBAAkB,CAmL7B;AAqCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAEvE"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/lib/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAElD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKzE,UAAU,SAAS;IACjB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,EAChC,IAAI,GAAE,SAAc,GACnB,MAAM,GAAG,kBAAkB,CAwL7B;AAqCD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAEvE"}
package/lib/plugin.js CHANGED
@@ -135,7 +135,12 @@ export function lensmcpVitePlugin(options = {}, deps = {}) {
135
135
  identity: ctx.file,
136
136
  }),
137
137
  title: `HMR ${ctx.file}`,
138
+ // The changed file, structured. The build reducer retracts bundler
139
+ // failures for exactly the files an update touched, so it needs them
140
+ // as data — it previously had to scrape the `HMR ` title prefix.
141
+ location: { file: ctx.file },
138
142
  relatedFiles: affected,
143
+ raw: { kind: 'hmr', file: ctx.file },
139
144
  });
140
145
  },
141
146
  generateBundle(_opts, bundle) {
@@ -227,9 +232,26 @@ async function runLensmcpBabel(code, filename) {
227
232
  export function handleClientEnvelope(raw, deps) {
228
233
  forwardClientEnvelope(raw, makePublisher(deps), deps.sessionId);
229
234
  }
235
+ /**
236
+ * Vite's `ErrorPayload.err` carries the offending module as `loc.file` (when
237
+ * the plugin reported a position) or `id` (the resolved module id, which may
238
+ * carry a `?t=` cache-buster). Both are stripped to a bare path.
239
+ */
240
+ function errorLocation(err) {
241
+ const raw = err?.loc?.file ?? err?.id;
242
+ if (typeof raw !== 'string' || raw.length === 0)
243
+ return undefined;
244
+ const file = raw.split('?')[0] || raw;
245
+ return {
246
+ file,
247
+ ...(typeof err?.loc?.line === 'number' ? { line: err.loc.line } : {}),
248
+ ...(typeof err?.loc?.column === 'number' ? { column: err.loc.column } : {}),
249
+ };
250
+ }
230
251
  function viteErrorToEvent(data, sessionId) {
231
252
  const message = data.err?.message ?? 'Vite error';
232
253
  const stack = data.err?.stack;
254
+ const loc = errorLocation(data.err);
233
255
  return {
234
256
  id: ulid(),
235
257
  sessionId: sessionId ?? 'pending',
@@ -238,9 +260,26 @@ function viteErrorToEvent(data, sessionId) {
238
260
  category: 'build',
239
261
  severity: 'error',
240
262
  context: { sessionId: sessionId ?? 'pending' },
241
- fingerprint: fingerprint({ kind: 'vite', identity: data.type ?? message }),
263
+ // The FILE is part of the identity. Without it two different modules
264
+ // failing with the same message ("Failed to resolve import") collapsed
265
+ // into ONE entry, so retracting either would have silenced both — and a
266
+ // file-scoped clear could not be safe. It is also what lets a later HMR
267
+ // update for that file retract this error at all: until now nothing in
268
+ // this repo ever removed a build failure, so a fixed Vite error was
269
+ // reported for the life of the session.
270
+ fingerprint: fingerprint({
271
+ kind: 'vite',
272
+ identity: data.type ?? message,
273
+ ...(loc ? { file: loc.file } : {}),
274
+ }),
242
275
  title: message,
243
276
  message: stack,
277
+ ...(loc ? { location: loc } : {}),
278
+ raw: {
279
+ kind: 'build-diagnostic',
280
+ ...(loc ? { file: loc.file } : {}),
281
+ ...(data.err?.plugin ? { plugin: data.err.plugin } : {}),
282
+ },
244
283
  };
245
284
  }
246
285
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensmcp/vite-plugin",
3
- "version": "1.18.1",
3
+ "version": "1.18.3",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -15,11 +15,11 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@babel/core": "^7.0.0",
18
- "@lensmcp/bridge": "1.18.1",
19
- "@lensmcp/core": "1.18.1",
20
- "@lensmcp/protocol-types": "1.18.1",
21
- "@lensmcp/react-instrumentation": "1.18.1",
22
- "@lensmcp/valtio-instrumentation": "1.18.1",
18
+ "@lensmcp/bridge": "1.18.3",
19
+ "@lensmcp/core": "1.18.3",
20
+ "@lensmcp/protocol-types": "1.18.3",
21
+ "@lensmcp/react-instrumentation": "1.18.3",
22
+ "@lensmcp/valtio-instrumentation": "1.18.3",
23
23
  "tslib": "^2.3.0"
24
24
  },
25
25
  "peerDependencies": {