@salesforce/vite-plugin-lwc-ui-bundle 1.135.0 → 2.1.0

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.
@@ -75,8 +75,18 @@ Surface this early:
75
75
  > A) Upgrade Node (recommended — `nvm install 20.19` or `22`)
76
76
  > B) Pin `vite@^7` and a compatible `@lwc/rollup-plugin` major"
77
77
 
78
+ **Stop here.** Report the detected layout and the Node decision, then
79
+ wait for the user to answer. Do **not** bundle Step 2's chat-wrapper
80
+ question into the same turn — a misdetection in Step 1 cascades into
81
+ every later decision, so the user needs a clean moment to confirm or
82
+ correct before anything else lands.
83
+
78
84
  ### Step 2: Ask about chat wrappers
79
85
 
86
+ Only start this step **after** Step 1 has been answered and resolved.
87
+ Ask the chat-wrapper question in its own turn — don't stack it on top
88
+ of Step 1's findings report.
89
+
80
90
  If the project will run inside a ChatGPT/MCP host (tool output drives
81
91
  the UI), components need a thin chat-aware wrapper + mapper. The wrapper
82
92
  reads tool output from the host, the mapper normalizes it into the
@@ -162,11 +172,63 @@ Report what you found — plainly, so the user can correct misdetections:
162
172
  > - 3 label imports: `c.appTitle`, `c.greeting`, `c.save`
163
173
  > - Uses `lightning-card` → needs lightning-base-components + the
164
174
  > gate/accessCheck/primitiveUtils providers
165
- > - Uses `lightning/graphql` → needs `builtins.lds()` (graphql specifiers
166
- > are registered by default) + a `graphqlQuery` mock branch in
167
- > `bootstrap.js`
168
- > - Uses `lightning/uiRecordApi` → needs `builtins.lds()` + a
169
- > `getRecordMcpTool` mock branch"
175
+ > - Uses `lightning/graphql` → needs `builtins.lds()` provider (graphql
176
+ > specifiers are registered by default) + the `@conduit-client/*` LDS
177
+ > runtime peers (verified after install in Step 8.1) + a `graphqlQuery`
178
+ > mock branch in `bootstrap.js`
179
+ > - Uses `lightning/uiRecordApi` needs `builtins.lds()` provider + the
180
+ > `@conduit-client/*` LDS runtime peers + a `getRecordMcpTool` mock
181
+ > branch"
182
+
183
+ ### Step 4.5: Verify existing `vite.config.js` against findings
184
+
185
+ If `vite.config.js` already exists (Step 1 noted whether it does), open it
186
+ now and cross-check against what Step 4 found. This catches the silent-
187
+ failure case where a project builds successfully but wire adapters and
188
+ scoped imports return `undefined` at runtime because the `providers` array
189
+ is missing or incomplete.
190
+
191
+ Check in this order:
192
+
193
+ 1. **Does `lwcVitePlugin({...})` include a `providers` array at all?**
194
+ If not, flag it. Without the array, every `@salesforce/*` import returns
195
+ `undefined` — labels, gates, access checks, i18n, client — even though
196
+ the build succeeds. See `references/known-pitfalls.md#11`.
197
+
198
+ 2. **For each finding from Step 4, verify the matching provider is present:**
199
+ - Step 4 found `@salesforce/label/*` usage → `builtins.label({...})` must be in `providers`
200
+ - Step 4 found `@wire(graphql)`, `executeMutation`, or any `lightning/graphql` import →
201
+ `builtins.lds()` must be present (graphql specifiers are in the default registry)
202
+ - Step 4 found `@wire(getRecord)` from `lightning/uiRecordApi` →
203
+ `builtins.lds()` must be present (one `builtins.lds()` covers both)
204
+ - Step 4 found any `@salesforce/i18n/*` → `builtins.i18n()` must be
205
+ present
206
+ - Step 4 found any `@salesforce/client/*` → `builtins.client()` must
207
+ be present
208
+ - `modules.npm` includes `lightning-base-components` (or
209
+ `lwc-components-lightning`) → `builtins.gate()`,
210
+ `builtins.accessCheck()`, `builtins.primitiveUtils()` must all be
211
+ present. Base components use these modules internally even if user
212
+ code doesn't.
213
+
214
+ 3. **Report the gaps explicitly** before proceeding to later steps:
215
+
216
+ > "Your `vite.config.js` exists but its `providers` array is missing:
217
+ >
218
+ > - `builtins.label({...})` — Step 4 found 3 `@salesforce/label/*` imports
219
+ > - `builtins.lds()` — Step 4 found `@wire(graphql)` / `executeMutation` in `c/recordDetail`
220
+ > - `builtins.gate()`, `builtins.accessCheck()`, `builtins.primitiveUtils()` — `lightning-base-components` is in `modules.npm` and needs these
221
+ >
222
+ > I'll add these in Step 7. The build may currently succeed even with
223
+ > these missing, but wire adapters and labels will fail silently at
224
+ > runtime."
225
+
226
+ 4. **If the existing `providers` array is complete**, say so and move on.
227
+
228
+ Do not skip this verification. A build that compiles fine but has no
229
+ providers registered is the single most common failure mode for projects
230
+ that already have a partial config — the compiler doesn't care, but the
231
+ runtime silently returns `undefined` for everything.
170
232
 
171
233
  ### Step 5: Decide the runtime mode
172
234
 
@@ -318,8 +380,8 @@ builtins.lds(), // default registry:
318
380
  // unmentioned entries (e.g. `getRecord`, `createRecord`) are preserved.
319
381
  builtins.lds({
320
382
  "lightning/graphql": {
321
- graphql: { type: "graphql-wire", toolName: "myGraphqlTool" },
322
- executeMutation: { type: "graphql-mutation", toolName: "myGraphqlTool" },
383
+ graphql: { type: "graphql-wire", mcp: { toolName: "myGraphqlTool" } },
384
+ executeMutation: { type: "graphql-mutation", mcp: { toolName: "myGraphqlTool" } },
323
385
  },
324
386
  }),
325
387
  ```
@@ -340,7 +402,7 @@ Adapt based on earlier findings:
340
402
 
341
403
  - `builtins.lds()` default for `lightning/uiRecordApi.getRecord`:
342
404
  `getRecordMcpTool`. Override via
343
- `builtins.lds({ "lightning/uiRecordApi": { getRecord: { type: "wire", toolName: "..." } } })`.
405
+ `builtins.lds({ "lightning/uiRecordApi": { getRecord: { type: "wire", mcp: { toolName: "..." } } } })`.
344
406
  - `builtins.lds()` default for `lightning/graphql` (both `graphql` wire
345
407
  and `executeMutation`): `graphqlQuery`. Override by registering the
346
408
  specifier explicitly — see example above.
@@ -387,12 +449,79 @@ Only add these if the component tree inspection reveals a need:
387
449
  system. Useful when an npm package has its own label definitions that
388
450
  shouldn't be intercepted.
389
451
  - **`ignorePatterns`**: Specifier prefixes that providers should never
390
- intercept. Defaults include `@salesforce/sdk-*` and `@salesforce/core`.
452
+ intercept. Defaults include `@salesforce/sdk-*`, `@salesforce/platform-sdk-*`, and `@salesforce/core`.
391
453
 
392
454
  ### Step 8: Install and build
393
455
 
394
456
  ```bash
395
457
  npm install
458
+ ```
459
+
460
+ #### Step 8.1: Verify LDS runtime peers (only if LDS is in use)
461
+
462
+ Run this check **only** if Step 4 found actual usage of any of:
463
+
464
+ - `lightning/graphql` with real `@wire(graphql)`, `executeMutation`, or
465
+ graphql-imperative calls
466
+ - `lightning/uiRecordApi` with real `@wire` usage of `getRecord` /
467
+ `createRecord` / `updateRecord`
468
+ - `lightning/uiObjectInfoApi` with real usage
469
+
470
+ If none of the above are in the component tree, skip this sub-step
471
+ entirely — the LDS runtime is never loaded and the peers don't matter.
472
+
473
+ **Why this check exists:** the plugin's `dist/providers/lds/runtime.js`
474
+ statically imports three `@conduit-client/*` packages at build time.
475
+ Depending on the plugin version, these may ship as the plugin's own
476
+ `dependencies`/`optionalDependencies`, or may be left undeclared (as of
477
+ `@salesforce/vite-plugin-lwc-ui-bundle@1.135.0`). The skill does not
478
+ need to know which — it just verifies they are resolvable in the
479
+ consumer's `node_modules` after install, regardless of how they got
480
+ there.
481
+
482
+ **Check:**
483
+
484
+ ```bash
485
+ node -e "
486
+ const peers = [
487
+ '@conduit-client/service-bindings-imperative',
488
+ '@conduit-client/service-bindings-lwc',
489
+ '@conduit-client/utils'
490
+ ];
491
+ const missing = peers.filter(p => {
492
+ try { require.resolve(p); return false; }
493
+ catch { return true; }
494
+ });
495
+ if (missing.length) {
496
+ console.error('Missing LDS runtime peers:', missing.join(', '));
497
+ process.exit(1);
498
+ } else {
499
+ console.log('LDS runtime peers OK');
500
+ }
501
+ "
502
+ ```
503
+
504
+ **If any are missing**, install the set as consumer `dependencies` (not
505
+ `@salesforce/ui-bundle` — that package does not pull these three
506
+ transitively and installing it does not resolve the error):
507
+
508
+ ```bash
509
+ npm install --save \
510
+ @conduit-client/service-bindings-imperative@^3 \
511
+ @conduit-client/service-bindings-lwc@^3 \
512
+ @conduit-client/utils@^3
513
+ ```
514
+
515
+ Re-run the check. See `references/known-pitfalls.md#13` for the full
516
+ background.
517
+
518
+ **If all three are already present** (e.g., a future plugin version
519
+ ships them as its own deps, or a sibling package already pulled them
520
+ in), do nothing — no lockfile churn, no duplicate entries.
521
+
522
+ #### Step 8.2: Build
523
+
524
+ ```bash
396
525
  npm run build
397
526
  ```
398
527
 
@@ -412,6 +541,8 @@ frequent issues have symptoms that map directly to specific entries:
412
541
  - "No matching version found for \<pkg\>" → pitfall #2 (stale dep pins)
413
542
  - Missing `isOpen` / missing `lightning/button` → pitfalls #8 / #6
414
543
  - `force/someModule` not resolved → pitfall #9
544
+ - `Rollup failed to resolve import "@conduit-client/..."` → pitfall #13
545
+ (LDS runtime peers missing; Step 8.1 was skipped or failed silently)
415
546
  - Component renders but unstyled → missing SLDS CSS import in
416
547
  `bootstrap.js`
417
548
 
@@ -21,7 +21,7 @@ bundle, so the guard short-circuits and real host calls run.
21
21
 
22
22
  Do **not** expect `npm run build && open dist/index.html` to render mock
23
23
  data. Rollup hoists module-init code to the top of the bundle, which
24
- means `@salesforce/sdk-chat`'s `detectSurface()` runs _before_ the
24
+ means `@salesforce/platform-sdk-chat`'s `detectSurface()` runs _before_ the
25
25
  `main.js` / `bootstrap.js` body executes the `if (!window.openai?.
26
26
  callTool)` block. The SDK caches surface = `"WebApp"` and never observes
27
27
  the mock — LDS / graphql wire adapters silently return empty data.
@@ -74,8 +74,8 @@ the same custom name to both the provider and the mock:
74
74
  // vite.config.js — override the default "graphqlQuery" tool name
75
75
  builtins.lds({
76
76
  "lightning/graphql": {
77
- graphql: { type: "graphql-wire", toolName: "myCustomGraphql" },
78
- executeMutation: { type: "graphql-mutation", toolName: "myCustomGraphql" },
77
+ graphql: { type: "graphql-wire", mcp: { toolName: "myCustomGraphql" } },
78
+ executeMutation: { type: "graphql-mutation", mcp: { toolName: "myCustomGraphql" } },
79
79
  },
80
80
  }),
81
81
 
@@ -188,7 +188,7 @@ expects.
188
188
  the console. Dev server (`npm run dev`) works fine.
189
189
 
190
190
  **Cause:** Rollup hoists module-init code to the top of the bundle.
191
- `@salesforce/sdk-chat`'s top-level `const surface = detectSurface()`
191
+ `@salesforce/platform-sdk-chat`'s top-level `const surface = detectSurface()`
192
192
  runs before `main.js` / `bootstrap.js` installs the mock, so the SDK
193
193
  caches `surface = "WebApp"` forever.
194
194
 
@@ -196,3 +196,128 @@ caches `surface = "WebApp"` forever.
196
196
  builds only target real MCP hosts (where the host sets `window.openai`
197
197
  before the bundle loads, so surface detection correctly resolves to
198
198
  `OpenAI`). See `bootstrap-js-patterns.md` for the full explanation.
199
+
200
+ ## 11. `providers` array missing entirely from `vite.config.js`
201
+
202
+ **Symptom:** Build succeeds, but:
203
+
204
+ - Labels render as `undefined` instead of their configured values
205
+ - `@wire(graphql)` returns `undefined` or silently no-ops
206
+ - `executeMutation()` fails with "No SDK found" or similar
207
+ - Console shows `[scoped-module-providers] Unhandled import: @salesforce/...`
208
+ lines for every scoped import
209
+
210
+ **Cause:** `lwcVitePlugin({ modules: {...} })` is called **without** a
211
+ `providers: [...]` array. The plugin loads and compiles LWC just fine,
212
+ but no scoped-module providers are registered — so every
213
+ `@salesforce/label/*`, `@salesforce/i18n/*`, `@salesforce/gate/*`,
214
+ `@salesforce/accessCheck/*`, `lightning/graphql`, `lightning/uiRecordApi`
215
+ import resolves to `undefined` at runtime.
216
+
217
+ **Fix:** Add the `providers: [...]` array with the appropriate builtins
218
+ for what the component tree actually uses:
219
+
220
+ ```js
221
+ import lwcVitePlugin, { builtins } from "@salesforce/vite-plugin-lwc-ui-bundle";
222
+
223
+ lwcVitePlugin({
224
+ modules: {
225
+ /* ... */
226
+ },
227
+ providers: [
228
+ builtins.label({
229
+ /* label overrides */
230
+ }),
231
+ builtins.i18n(),
232
+ builtins.client(),
233
+ // Required when using base components:
234
+ builtins.gate(),
235
+ builtins.accessCheck(),
236
+ builtins.primitiveUtils(),
237
+ // Add only if detected in the component tree:
238
+ builtins.lds(), // covers lightning/uiRecordApi and lightning/graphql
239
+ ],
240
+ });
241
+ ```
242
+
243
+ **Prevention:** SKILL.md Step 4.5 ("Verify existing `vite.config.js`
244
+ against findings") catches this by cross-checking Step 4's tree-walk
245
+ findings against the providers actually listed in the config.
246
+
247
+ ## 12. `lwc-components-lightning` vs `lightning-base-components`
248
+
249
+ **Symptom:** Config references one package name but the project has the
250
+ other installed, or provider behavior differs between environments.
251
+
252
+ **Cause:** Both names appear in the wild:
253
+
254
+ - `lightning-base-components` — the public npm package
255
+ - `lwc-components-lightning` — an internal-workspace name that some
256
+ Salesforce projects resolve through private registries, aliases, or
257
+ monorepo linking. The public-registry entry for this name is a
258
+ security-reserved placeholder, not a real package.
259
+
260
+ Both resolve to the same LWC base components and **require the same
261
+ scoped providers**: `builtins.gate()`, `builtins.accessCheck()`,
262
+ `builtins.primitiveUtils()`.
263
+
264
+ **Fix:** Use whichever package your project already depends on. For
265
+ public-facing consumers, use `lightning-base-components`. In either
266
+ case, make sure the three providers above are in the `providers` array
267
+ whenever the package name is in `modules.npm`.
268
+
269
+ ## 13. Missing `@conduit-client/*` peers for `builtins.lds()`
270
+
271
+ **Symptom:** `vite build` fails with:
272
+
273
+ ```
274
+ Rollup failed to resolve import "@conduit-client/service-bindings-imperative/v1"
275
+ from "\0sf-lds-adapter:lightning/graphql"
276
+ ```
277
+
278
+ (or `service-bindings-lwc`, or `utils` — errors cascade one at a time as
279
+ each is resolved.)
280
+
281
+ **Cause:** The plugin's LDS runtime
282
+ (`node_modules/@salesforce/vite-plugin-lwc-ui-bundle/dist/providers/lds/runtime.js`)
283
+ statically imports three `@conduit-client/*` packages. Depending on the
284
+ plugin version, these may be declared as the plugin's own
285
+ `dependencies` / `optionalDependencies`, or may be left undeclared (as
286
+ of `@salesforce/vite-plugin-lwc-ui-bundle@1.135.0`). The plugin reads
287
+ `runtime.js` as a string at init, so nothing resolves until a consumer
288
+ module imports `lightning/graphql`, `lightning/uiRecordApi`, or
289
+ `lightning/uiObjectInfoApi` — then Rollup has to resolve the
290
+ conduit-client imports in the consumer's `node_modules`, where they may
291
+ be missing.
292
+
293
+ The packages **are** publicly published on `registry.npmjs.org`; this
294
+ is a missing-peer-declaration issue in the plugin for the plugin
295
+ versions that don't ship them, not a registry / auth issue.
296
+
297
+ **Fix (consumer side, works against any plugin version):** when a
298
+ component actually imports `lightning/graphql`,
299
+ `lightning/uiRecordApi`, or `lightning/uiObjectInfoApi`, install the
300
+ three packages directly:
301
+
302
+ ```bash
303
+ npm install --save \
304
+ @conduit-client/service-bindings-imperative@^3 \
305
+ @conduit-client/service-bindings-lwc@^3 \
306
+ @conduit-client/utils@^3
307
+ ```
308
+
309
+ If no component imports those specifiers, the packages are not
310
+ needed — omit them AND omit `builtins.lds()` from the `providers`
311
+ array.
312
+
313
+ **Forward compatibility:** if a future plugin version adds these to its
314
+ own `dependencies` / `optionalDependencies`, they will already be
315
+ present after `npm install @salesforce/vite-plugin-lwc-ui-bundle` and
316
+ Step 8.1's post-install check becomes a no-op — it simply observes that
317
+ the packages are already resolvable and skips the additional install.
318
+ No skill change needed.
319
+
320
+ **Prevention:** SKILL.md Step 8.1 ("Verify LDS runtime peers") runs the
321
+ `require.resolve()` check after `npm install` and installs the three
322
+ packages only when they are actually missing AND the component tree
323
+ uses LDS specifiers.