@salesforce/vite-plugin-lwc-ui-bundle 3.1.0 → 3.1.1
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/docs/consumer-guide.md
CHANGED
|
@@ -19,6 +19,68 @@ The plugin compiles your LWC components into a single self-contained `dist/index
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## Strategy & Responsibilities
|
|
23
|
+
|
|
24
|
+
This section is for team leads and app developers deciding **how** to uplift LWCs into static bundles for agentic surfaces. It's not a setup guide — for that, see [Off-Platform Build](#off-platform-build) below.
|
|
25
|
+
|
|
26
|
+
The plugin ships configuration for a default, foundational set of UI API adapters — including `lightning/graphql`. Most uplifted bundles can rely on these defaults without writing any adapter config. During development, consumers can supplement the defaults by passing additional config to `builtins.lds()` (see [Configuring `builtins.lds()`](#configuring-builtinslds) below). Once a configuration is stable and useful to others, open a PR against [`packages/vite-plugin-lwc-ui-bundle/src/providers/lds/index.ts`](../src/providers/lds/index.ts) to add it to `DEFAULT_ADAPTERS` so it ships in the next plugin release.
|
|
27
|
+
|
|
28
|
+
The Data Orchestration Service team is not responsible for the implementation of MCP tooling, nor for the adapter configuration of capabilities outside DOS ownership. As far as external teams are concerned, DOS provides the mechanism that applies the uplift per configuration; what each adapter resolves to at runtime — and which MCP tools back it — is owned by the team that owns the underlying capability.
|
|
29
|
+
|
|
30
|
+
### What ships in the default registry today
|
|
31
|
+
|
|
32
|
+
(see `DEFAULT_ADAPTERS` in [`src/providers/lds/index.ts`](../src/providers/lds/index.ts)):
|
|
33
|
+
|
|
34
|
+
- `lightning/uiRecordApi` — `getRecord` (wire), `createRecord` (imperative mutation), `updateRecord` (imperative mutation)
|
|
35
|
+
- `lightning/uiObjectInfoApi` — `getObjectInfo_imperative` (legacy-shape imperative read)
|
|
36
|
+
- `lightning/graphql` — `graphql` (wire) + `executeMutation`
|
|
37
|
+
|
|
38
|
+
### Configuring `builtins.lds()`
|
|
39
|
+
|
|
40
|
+
Pass an overrides object to extend or replace adapters:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import lwcVitePlugin, { builtins } from "@salesforce/vite-plugin-lwc-ui-bundle";
|
|
44
|
+
|
|
45
|
+
lwcVitePlugin({
|
|
46
|
+
providers: [
|
|
47
|
+
// ...
|
|
48
|
+
builtins.lds({
|
|
49
|
+
"lightning/uiListApi": {
|
|
50
|
+
getListUi: {
|
|
51
|
+
type: "wire",
|
|
52
|
+
mcp: { toolName: "getListUiMcpTool" },
|
|
53
|
+
configJsonSchema: {
|
|
54
|
+
/* ... */
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Merge semantics** (see `mergeWithDefaults` in [`src/providers/lds/index.ts:332-338`](../src/providers/lds/index.ts)):
|
|
64
|
+
|
|
65
|
+
- **Per specifier:** your overrides spread on top of defaults — `{ ...defaults[specifier], ...your[specifier] }`. Adding `getListUi` to `lightning/uiListApi` does not affect `lightning/uiRecordApi`.
|
|
66
|
+
- **Per adapter name within a specifier:** override-by-key. You can replace `getRecord` without losing siblings like `createRecord`.
|
|
67
|
+
- **Within an adapter entry:** **wholesale replacement, not deep merge.** If you redeclare `lightning/uiRecordApi` → `getRecord`, your `configJsonSchema` replaces the default's entirely. Repeat any default fields you want to keep.
|
|
68
|
+
|
|
69
|
+
### Data waterfall awareness
|
|
70
|
+
|
|
71
|
+
**Recommendation:** treat inefficient data access as the anti-pattern. Every LDS adapter call in an uplifted bundle becomes an independent, isolated MCP `callTool` — a fresh round-trip with tooling overhead the on-platform LDS path doesn't pay, and no shared cache. Multiple adapters requesting the same data (within a component, across components, or on re-render) all result in independent tool calls.
|
|
72
|
+
|
|
73
|
+
**What developers should do today:**
|
|
74
|
+
|
|
75
|
+
- **Consolidate / minimize calls within each component.** GraphQL or batch-enabled adapters are an alternative — one `@wire(graphql)` query can request fields from multiple records / object types in one round-trip, replacing N separate `@wire(getRecord)` / `@wire(getObjectInfo)` calls.
|
|
76
|
+
- **Share data across components via an LWC state manager.** A state manager serves as a single source of truth so descendants subscribe rather than re-fetching. This recovers the cross-component sharing that on-platform LDS provides for free.
|
|
77
|
+
|
|
78
|
+
**See also:** [Known pitfall #14 — Inefficient data access: latency and lack of caching](../skills/setup-lwc-vite-plugin/references/known-pitfalls.md#14-inefficient-data-access-latency-and-lack-of-caching).
|
|
79
|
+
|
|
80
|
+
**Detection:** compile-time detection is impractical (the plugin can't tell which components share data). This documentation is the primary guardrail. If you suspect inefficient data access, profile the bundle in DevTools Network: every `callTool` shows up as a separate request to the MCP host, and repeat visits don't get cached.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
22
84
|
## Off-Platform Build
|
|
23
85
|
|
|
24
86
|
### Project Structure
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Vite plugin for compiling LWC components into static bundles for off-platform and MCP use",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "Salesforce",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@lwc/rollup-plugin": "^9.0.0",
|
|
57
|
-
"@salesforce/platform-sdk-chat": "^3.1.
|
|
58
|
-
"@salesforce/ui-bundle": "^3.1.
|
|
57
|
+
"@salesforce/platform-sdk-chat": "^3.1.1",
|
|
58
|
+
"@salesforce/ui-bundle": "^3.1.1",
|
|
59
59
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
60
60
|
"zod": "^3.23.8"
|
|
61
61
|
},
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@conduit-client/bindings-utils": "3.19.3",
|
|
77
77
|
"@conduit-client/command-base": "3.19.3",
|
|
78
|
-
"@salesforce/platform-sdk-chat": "^3.1.
|
|
78
|
+
"@salesforce/platform-sdk-chat": "^3.1.1",
|
|
79
79
|
"typescript": "^5.9.3",
|
|
80
80
|
"vite": "^7.0.0",
|
|
81
81
|
"vite-plugin-dts": "^4.5.4",
|
|
@@ -321,3 +321,47 @@ No skill change needed.
|
|
|
321
321
|
`require.resolve()` check after `npm install` and installs the three
|
|
322
322
|
packages only when they are actually missing AND the component tree
|
|
323
323
|
uses LDS specifiers.
|
|
324
|
+
|
|
325
|
+
## 14. Inefficient data access: latency and lack of caching
|
|
326
|
+
|
|
327
|
+
**Symptom:** Data takes longer to load and the widget makes an
|
|
328
|
+
increased number of network calls. DevTools Network panel shows
|
|
329
|
+
multiple `callTool` requests; repeat visits don't get faster; two
|
|
330
|
+
components reading the same record each fire their own request.
|
|
331
|
+
|
|
332
|
+
**Cause:** Every LDS adapter call in an uplifted bundle becomes an
|
|
333
|
+
independent, isolated MCP `callTool`. Two effects compound:
|
|
334
|
+
|
|
335
|
+
- **Per-call latency.** Each `callTool` round-trips through the MCP
|
|
336
|
+
host before reaching a Salesforce server, adding tooling overhead
|
|
337
|
+
the on-platform LDS path doesn't pay. Adapters that fire
|
|
338
|
+
independently run in parallel, but adapters that are **chained**
|
|
339
|
+
(one's `config` depends on another's output) serialize — and the
|
|
340
|
+
per-call latencies sum link-by-link.
|
|
341
|
+
- **No caching.** Unlike on-platform LDS, the MCP runtime has no
|
|
342
|
+
durable, shared cache. If multiple adapters request the same data
|
|
343
|
+
— within one component, across components, or on re-render — they
|
|
344
|
+
all result in independent and isolated tool calls.
|
|
345
|
+
|
|
346
|
+
The plugin cannot detect this at compile time: whether two adapter
|
|
347
|
+
calls request the same data is a property of the runtime component
|
|
348
|
+
tree, not the source.
|
|
349
|
+
|
|
350
|
+
**Fix:**
|
|
351
|
+
|
|
352
|
+
- **Consolidate / minimize calls within each component.** GraphQL or
|
|
353
|
+
batch-enabled adapters are an alternative — one query / one batch
|
|
354
|
+
call replaces N separate adapter calls.
|
|
355
|
+
- **Share data across components via an LWC state manager.** A
|
|
356
|
+
state manager serves as a single source of truth for data that is
|
|
357
|
+
shared cross-component.
|
|
358
|
+
|
|
359
|
+
**Prevention:** Review the component tree before uplift. Look for
|
|
360
|
+
overlapping data needs across components (state-manager candidates)
|
|
361
|
+
and chained adapters within a component, where one's `config`
|
|
362
|
+
depends on another's output (graphql consolidation candidates).
|
|
363
|
+
Independent adapter declarations that fan out in parallel are not
|
|
364
|
+
inherently a problem — only chains and overlapping fetches are. The
|
|
365
|
+
strategy section in
|
|
366
|
+
[`docs/consumer-guide.md`](../../../docs/consumer-guide.md#data-waterfall-awareness)
|
|
367
|
+
walks through the recommendation.
|