@salesforce/vite-plugin-lwc-ui-bundle 12.17.0 → 12.18.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.
- package/README.md +15 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/consumer-guide.md +2 -2
- package/docs/limitations.md +1 -1
- package/docs/migration-guide.md +2 -3
- package/package.json +9 -4
- package/skills/setup-lwc-vite-plugin/SKILL.md +33 -275
- package/skills/setup-lwc-vite-plugin/references/component-tree-detection.md +63 -0
- package/skills/setup-lwc-vite-plugin/references/known-pitfalls.md +8 -9
- package/skills/setup-lwc-vite-plugin/references/lds-runtime-peers.md +50 -0
- package/skills/setup-lwc-vite-plugin/references/mock-questions.md +52 -0
- package/skills/setup-lwc-vite-plugin/references/provider-verification.md +27 -0
- package/skills/setup-lwc-vite-plugin/references/vite-config-providers.md +89 -0
package/README.md
CHANGED
|
@@ -76,23 +76,30 @@ providers: [
|
|
|
76
76
|
];
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
### `
|
|
79
|
+
### `outputMode`
|
|
80
80
|
|
|
81
|
-
Controls the build output
|
|
81
|
+
Controls the build output layout.
|
|
82
82
|
|
|
83
|
-
| Value
|
|
84
|
-
|
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
83
|
+
| Value | Behavior |
|
|
84
|
+
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `"bundled"` (default) | Vite's normal output. No output config injected. |
|
|
86
|
+
| `"unbundled"` | Multi-file web app output: `dist/index.html`, `dist/js/*.js`, `dist/css/*.css`. |
|
|
87
|
+
| `"single-file"` | Inlines JS, CSS and imported assets into one self-contained `index.html` (required for MCP apps). Requires `vite-plugin-singlefile` and vite >= 5.4.21. `vite build` only. |
|
|
87
88
|
|
|
88
89
|
```js
|
|
89
90
|
lwcVitePlugin({
|
|
90
|
-
|
|
91
|
+
outputMode: "single-file", // for MCP apps; omit for Vite's normal output
|
|
91
92
|
modules: { dirs: ["src/lwc"] },
|
|
92
93
|
});
|
|
93
94
|
```
|
|
94
95
|
|
|
95
|
-
> **Note:**
|
|
96
|
+
> **Note:** `bundle: false` still works but is deprecated in favour of `outputMode: "unbundled"`. Setting both `bundle` and `outputMode` throws.
|
|
97
|
+
|
|
98
|
+
For `"single-file"`, `public/` files are copied next to `index.html` rather than inlined, and the build logs a `[singleFile] public/ files are copied as separate files, not inlined` warning listing them. Static `src` attributes in LWC templates aren't imported, so their assets aren't inlined (or detected). Import the asset in JS to inline it.
|
|
99
|
+
|
|
100
|
+
Single-file output can be large: the `lwc-records` example is ~10.9 MB.
|
|
101
|
+
|
|
102
|
+
The plugin registers `viteSingleFile()` for you, so you can drop a manual call. If you leave one in your Vite `plugins` it is safe (the output is identical).
|
|
96
103
|
|
|
97
104
|
### `stubs`
|
|
98
105
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Plugin } from 'vite';
|
|
|
2
2
|
import { LabelsGraphqlOptions, PlatformGraphqlOptions } from './providers/index';
|
|
3
3
|
import { LwcVitePluginOptions, Provider } from './types';
|
|
4
4
|
import * as builtinProviders from "./providers/index";
|
|
5
|
-
export type { Provider, LwcVitePluginOptions, GenerateMetaXmlOptions, PassthroughRule, DiscoveredModule, DirConfig, } from './types';
|
|
5
|
+
export type { Provider, LwcVitePluginOptions, OutputMode, GenerateMetaXmlOptions, PassthroughRule, DiscoveredModule, DirConfig, } from './types';
|
|
6
6
|
export { builtinProviders as builtins };
|
|
7
7
|
export { discoverModules } from './discovery';
|
|
8
8
|
export { lwcProxy } from './plugins/proxy';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AASnC,OAAO,KAAK,gBAAgB,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAEX,oBAAoB,EAGpB,QAAQ,EACR,MAAM,SAAS,CAAC;AAEjB,YAAY,EACX,QAAQ,EACR,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IACzC,8EAA8E;IAC9E,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE,CA0B7F;AAsBD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAiPlF"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { singleFilePlugins } from "@salesforce/ui-bundle/vite";
|
|
3
4
|
import { existsSync, statSync, readdirSync } from "node:fs";
|
|
4
5
|
import { readdir, writeFile, access, readFile } from "node:fs/promises";
|
|
5
6
|
import { resolveMetaTarget, UI_BUNDLE_TARGETS, loadManifest, generateUIBundleMetaXml } from "@salesforce/ui-bundle/app";
|
|
@@ -531,9 +532,20 @@ function lwcVitePlugin(options = {}) {
|
|
|
531
532
|
"@salesforce/vite-plugin-lwc-ui-bundle"
|
|
532
533
|
],
|
|
533
534
|
passthroughRules = [],
|
|
534
|
-
bundle
|
|
535
|
+
bundle,
|
|
536
|
+
outputMode = bundle === false ? "unbundled" : "bundled",
|
|
535
537
|
generateMetaXml: generateMetaXmlOption = true
|
|
536
538
|
} = options;
|
|
539
|
+
if (bundle !== void 0 && options.outputMode !== void 0) {
|
|
540
|
+
throw new Error(
|
|
541
|
+
'@salesforce/vite-plugin-lwc-ui-bundle: `bundle` is deprecated and cannot be combined with `outputMode`. Use `outputMode: "unbundled"` instead of `bundle: false`.'
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (!["bundled", "unbundled", "single-file"].includes(outputMode)) {
|
|
545
|
+
throw new Error(
|
|
546
|
+
`@salesforce/vite-plugin-lwc-ui-bundle: unknown outputMode ${JSON.stringify(outputMode)}. Use "bundled", "unbundled" or "single-file".`
|
|
547
|
+
);
|
|
548
|
+
}
|
|
537
549
|
const resolvedItems = providers ?? defaultProviders();
|
|
538
550
|
const resolvedProviders = resolvedItems.filter(isProvider);
|
|
539
551
|
const rawPlugins = resolvedItems.filter((item) => !isProvider(item));
|
|
@@ -647,7 +659,7 @@ function lwcVitePlugin(options = {}) {
|
|
|
647
659
|
}
|
|
648
660
|
});
|
|
649
661
|
}
|
|
650
|
-
if (
|
|
662
|
+
if (outputMode === "unbundled") {
|
|
651
663
|
plugins.push({
|
|
652
664
|
name: "vite-plugin-lwc-output-multifile",
|
|
653
665
|
enforce: "pre",
|
|
@@ -679,6 +691,14 @@ function lwcVitePlugin(options = {}) {
|
|
|
679
691
|
plugins.push(generateMetaXml(metaOpts));
|
|
680
692
|
}
|
|
681
693
|
}
|
|
694
|
+
if (outputMode === "single-file") {
|
|
695
|
+
plugins.push(
|
|
696
|
+
...singleFilePlugins({
|
|
697
|
+
owner: "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
698
|
+
option: 'outputMode: "single-file"'
|
|
699
|
+
})
|
|
700
|
+
);
|
|
701
|
+
}
|
|
682
702
|
return plugins;
|
|
683
703
|
}
|
|
684
704
|
export {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/generate-meta-xml.ts","../src/plugins/lightning-npm.ts","../src/plugins/live-preview.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { access, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n\tgenerateUIBundleMetaXml,\n\tloadManifest,\n\tresolveMetaTarget,\n\tUI_BUNDLE_TARGETS,\n} from \"@salesforce/ui-bundle/app\";\nimport type { Plugin } from \"vite\";\nimport type { GenerateMetaXmlOptions } from \"../types\";\n\n/**\n * Vite plugin that writes the bundle's `*.uibundle-meta.xml` at build time.\n *\n * The `<target>` comes from `options.target` (configured on the Vite plugin,\n * NOT read from `ui-bundle.json` — the platform's manifest schema rejects a\n * `target` field). No-op unless a `target` is supplied. By default it won't\n * overwrite a meta XML that already declares a `<target>` (hand-authored\n * targets win); set `overwriteExisting: true` to change that.\n */\nexport function generateMetaXml(options: GenerateMetaXmlOptions = {}): Plugin {\n\t// Resolved from Vite's `configResolved` hook. `resolvedConfig.root` is the\n\t// project root even in a monorepo, which `process.cwd()` does not reliably\n\t// give (it depends on where the build was invoked from).\n\tlet root = process.cwd();\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-generate-meta-xml\",\n\t\tconfigResolved(config) {\n\t\t\troot = config.root;\n\t\t},\n\t\tasync closeBundle() {\n\t\t\t// Only generate when a build-time target is supplied — otherwise we\n\t\t\t// have nothing to contribute over a hand-authored meta XML.\n\t\t\tif (!options.target) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Guard JS consumers (e.g. vite.config.js) who bypass the TS union type.\n\t\t\tif (!resolveMetaTarget(options.target)) {\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Unknown generateMetaXml.target \"${String(options.target)}\"; expected one of ` +\n\t\t\t\t\t\t`${UI_BUNDLE_TARGETS.join(\", \")}. Skipping meta XML generation.`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst manifestPath = options.manifestPath ?? path.join(root, \"ui-bundle.json\");\n\t\t\tconst bundleName = options.bundleName ?? path.basename(root);\n\n\t\t\tif (!(await pathExists(manifestPath))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst manifest = await loadManifest(manifestPath);\n\t\t\tconst dir = path.dirname(manifestPath);\n\t\t\t// A UIBundle's meta file is named after the bundle; that is the file we\n\t\t\t// write. This is deterministic — we never retarget a differently-named\n\t\t\t// meta file that happens to sit in the directory.\n\t\t\tconst metaPath = path.join(dir, `${bundleName}.uibundle-meta.xml`);\n\n\t\t\tconst strays = (await readdir(dir))\n\t\t\t\t.filter((f) => f.endsWith(\".uibundle-meta.xml\") && f !== path.basename(metaPath))\n\t\t\t\t.sort();\n\t\t\tif (strays.length > 0) {\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Ignoring ${strays.join(\", \")} in ${dir}; writing the bundle's meta XML to ` +\n\t\t\t\t\t\t`${path.basename(metaPath)} (named after the bundle \"${bundleName}\").`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!options.overwriteExisting) {\n\t\t\t\tconst existing = await readIfExists(metaPath);\n\t\t\t\tif (existing?.includes(\"<target>\")) {\n\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t`${path.basename(metaPath)} already declares a <target>; skipping target ` +\n\t\t\t\t\t\t\t`generation. Set generateMetaXml.overwriteExisting to override.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst xml = generateUIBundleMetaXml(manifest, bundleName, {\n\t\t\t\ttarget: options.target,\n\t\t\t\tdescription: options.description,\n\t\t\t});\n\t\t\tawait writeFile(metaPath, xml, \"utf-8\");\n\t\t},\n\t};\n}\n\n/** Whether a path exists. */\nasync function pathExists(p: string): Promise<boolean> {\n\ttry {\n\t\tawait access(p);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Read a file's text, or `null` if it does not exist. */\nasync function readIfExists(p: string): Promise<string | null> {\n\ttry {\n\t\treturn await readFile(p, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\nexport interface LivePreviewOptions {\n\t/** Enable verbose logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that injects the Salesforce Live Preview bridge script into the\n * dev server's HTML so LWC UI Bundles work with the VSCode Live Preview\n * extension.\n *\n * The bridge (from `@salesforce/ui-bundle/proxy`) establishes a `postMessage`\n * channel from the previewed iframe to the VSCode webview: it forwards runtime\n * errors, unhandled rejections, network failures, and compile errors, plus\n * copy/paste, keyboard shortcuts, and a heartbeat. It is the same script the\n * React/generic `@salesforce/vite-plugin-ui-bundle` injects — sharing it keeps\n * the two dev-server paths behaviourally identical.\n *\n * Injection is **dev-only** (Vite `command === \"serve\"`). The compiled bundle\n * targets MCP hosts (ChatGPT, MCP Apps) and must never carry the dev bridge, so\n * the `transformIndexHtml` hook is a no-op during `vite build`.\n *\n * `@salesforce/ui-bundle` is an optional peer dependency; if it is not\n * installed the injection is skipped silently (a warning is logged only in\n * `debug` mode) and the dev server runs without Live Preview support.\n *\n * Included by default in `lwcVitePlugin()`. Available standalone for callers\n * who compose their own plugin array:\n * import { livePreview } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [livePreview(), lwcVitePlugin({ providers: [...] })]\n */\nexport function livePreview(options: LivePreviewOptions = {}): Plugin {\n\tlet isServe = false;\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-live-preview\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config) {\n\t\t\tisServe = config.command === \"serve\";\n\t\t},\n\n\t\ttransformIndexHtml: {\n\t\t\torder: \"pre\",\n\t\t\tasync handler(html) {\n\t\t\t\t// Only inject during local dev (`vite` / `vite dev`). Never during\n\t\t\t\t// `vite build` — the artifact ships to MCP hosts without the bridge.\n\t\t\t\tif (!isServe) return html;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Dynamic import: @salesforce/ui-bundle is an OPTIONAL peer dep,\n\t\t\t\t\t// so a missing install must degrade gracefully, not hard-fail.\n\t\t\t\t\tconst { injectLivePreviewScript } = await import(\"@salesforce/ui-bundle/proxy\");\n\t\t\t\t\tconst injected = injectLivePreviewScript(html);\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.log(\"[lwc-live-preview] Injected Live Preview bridge script\");\n\t\t\t\t\t}\n\t\t\t\t\treturn injected;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[lwc-live-preview] @salesforce/ui-bundle not available; skipping Live Preview injection.\\n ${msg}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn html;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/platform-sdk';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { generateMetaXml } from \"./plugins/generate-meta-xml\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { livePreview } from \"./plugins/live-preview\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { LabelsGraphqlOptions, PlatformGraphqlOptions } from \"./providers/index\";\nimport type {\n\tDirConfig,\n\tLwcVitePluginOptions,\n\tNpmModuleConfig,\n\tPassthroughRule,\n\tProvider,\n} from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tGenerateMetaXmlOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\nexport { livePreview } from \"./plugins/live-preview\";\nexport type { LivePreviewOptions } from \"./plugins/live-preview\";\n\n/**\n * Options for {@link defaultProviders}. Each key configures the corresponding\n * built-in provider without having to reconstruct the whole default array. Any\n * provider you don't mention keeps its default configuration.\n */\nexport interface DefaultProvidersOptions {\n\t/**\n\t * Options for the GraphQL-backed permission / i18n provider. Use this to\n\t * declare the required first-paint values for the `@salesforce/userPermission/*`\n\t * and `@salesforce/customPermission/*` your bundle imports.\n\t */\n\tplatformGraphql?: PlatformGraphqlOptions;\n\t/** Options for the GraphQL-backed label provider (e.g. `staticOverrides`). */\n\tlabelsGraphql?: LabelsGraphqlOptions;\n}\n\n/**\n * The default provider registry, used when `lwcVitePlugin` is called without an\n * explicit `providers` array. Exported so a consumer can tweak a single\n * provider's options — most commonly declaring `userPermissionDefaults` — while\n * keeping every other default in place, instead of hand-listing all ~10 builtins:\n *\n * ```js\n * lwcVitePlugin({\n * providers: defaultProviders({\n * platformGraphql: { userPermissionDefaults: { ApiEnabled: false } },\n * }),\n * });\n * ```\n */\nexport function defaultProviders(options: DefaultProvidersOptions = {}): (Provider | Plugin)[] {\n\treturn [\n\t\t// Resolve @salesforce/label/* via GraphQL through the Platform Data SDK by\n\t\t// default (W-22167030); the generated modules carry a static fallback so\n\t\t// labels still render when no data surface is available. Use the static\n\t\t// builtins.label() provider explicitly to opt out of runtime fetching.\n\t\tbuiltinProviders.labelsGraphql(options.labelsGraphql),\n\t\t// Resolve @salesforce/i18n/*, @salesforce/userPermission/*,\n\t\t// @salesforce/customPermission/* and @salesforce/accessCheck/* via the\n\t\t// uiapi.platform.* GraphQL fields off-core through the Platform Data SDK\n\t\t// (W-22167030). i18n format/calendar keys stay static (CLDR, no org source).\n\t\t// Replaces the static builtins.i18n() + builtins.accessCheck() providers;\n\t\t// those remain exported for explicit opt-out.\n\t\tbuiltinProviders.platformGraphql(options.platformGraphql),\n\t\tbuiltinProviders.apex(),\n\t\tbuiltinProviders.client(),\n\t\t// @salesforce/gate/* stays static: its GraphQL field (uiapi.platform.gates)\n\t\t// is UiTier-context-only and not reachable off-core (verified: FieldUndefined\n\t\t// / \"can only be executed in a UiTier context\").\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.messageChannel(),\n\t\tbuiltinProviders.messageService(),\n\t\tbuiltinProviders.navigation(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.lds(),\n\t];\n}\n\n/** Distinguishes a scoped-providers `Provider` from a raw Vite `Plugin`. */\nfunction isProvider(item: Provider | Plugin): item is Provider {\n\treturn typeof (item as Provider).resolve === \"function\";\n}\n\nasync function loadLwcRollup() {\n\ttry {\n\t\t// Use dynamic import to load ESM-only @lwc/rollup-plugin (peer dep, types not guaranteed)\n\t\tconst mod = await (import(\"@lwc/rollup-plugin\") as Promise<Record<string, unknown>>);\n\t\treturn (mod[\"default\"] ?? mod) as unknown as (options: Record<string, unknown>) => Plugin;\n\t} catch (error) {\n\t\tconst errMsg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. \" +\n\t\t\t\t\"Install it with: npm install -D @lwc/rollup-plugin\\n\" +\n\t\t\t\t`Debug: cwd=${process.cwd()}, error=${errMsg}`,\n\t\t);\n\t}\n}\n\nexport default function lwcVitePlugin(options: LwcVitePluginOptions = {}): Plugin[] {\n\tconst {\n\t\tmodules = {},\n\t\tproviders,\n\t\tstubs = {},\n\t\tlwcOptions = {},\n\t\tignorePatterns = [\n\t\t\t// Legacy @salesforce/sdk-* prefix — kept for external consumers still on the\n\t\t\t// pre-rename package names. The `@salesforce/platform-sdk-` prefix covers the\n\t\t\t// individual platform-sdk-* packages (still in place pending deprecation);\n\t\t\t// `@salesforce/platform-sdk` (no trailing dash) covers the consolidated package.\n\t\t\t\"@salesforce/sdk-\",\n\t\t\t\"@salesforce/platform-sdk-\",\n\t\t\t\"@salesforce/platform-sdk\",\n\t\t\t\"@salesforce/core\",\n\t\t\t// Transitive runtime deps of the Platform Data SDK (e.g. the embedding\n\t\t\t// bridge and its JSON-RPC client). These are real npm packages the SDK\n\t\t\t// needs at runtime — let them resolve normally instead of being claimed\n\t\t\t// by the broad `@salesforce/` scoped-provider interception (which would\n\t\t\t// stub them to `undefined` and break the SDK on the OpenAI/MCP surface).\n\t\t\t// The bridge exposes NAMED exports (e.g. `readHostMetaData`, imported by\n\t\t\t// platform-sdk's surface detection), so a default-only `undefined` stub\n\t\t\t// breaks the build outright — it must resolve to the real package.\n\t\t\t\"@salesforce/jsonrpc\",\n\t\t\t\"@salesforce/sf-embedding-bridge\",\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t],\n\t\tpassthroughRules = [],\n\t\tbundle = true,\n\t\tgenerateMetaXml: generateMetaXmlOption = true,\n\t} = options;\n\n\tconst resolvedItems = providers ?? defaultProviders();\n\tconst resolvedProviders = resolvedItems.filter(isProvider);\n\tconst rawPlugins = resolvedItems.filter((item): item is Plugin => !isProvider(item));\n\n\tconst { dirs = [], npm: npmPackages = [] } = modules;\n\n\tconst resolvedDirs: DirConfig[] = dirs.map((d) =>\n\t\ttypeof d === \"string\"\n\t\t\t? { path: path.resolve(d), namespace: \"\" }\n\t\t\t: { ...d, path: path.resolve(d.path) },\n\t);\n\n\tconst npmConfigs: NpmModuleConfig[] = npmPackages.map((pkg) =>\n\t\ttypeof pkg === \"string\" ? { npm: pkg } : pkg,\n\t);\n\n\tconst require = createRequire(import.meta.url);\n\tconst npmRoots = npmConfigs.map((cfg) => {\n\t\tconst pkgJson = require.resolve(`${cfg.npm}/package.json`);\n\t\treturn path.join(path.dirname(pkgJson), \"src\", \"lightning\");\n\t});\n\n\tconst discoveredModules = discoverModules(dirs);\n\n\tconst lwcModules = [...npmConfigs, ...discoveredModules];\n\n\tconst lightningOverrideDirs = resolvedDirs.map((d) => path.join(d.path, \"lightning\"));\n\n\tfunction isComponentAsset(id: string): boolean {\n\t\tconst clean = id.split(\"?\")[0] ?? id;\n\t\tfor (const dir of resolvedDirs) {\n\t\t\tif (clean.includes(dir.path)) return true;\n\t\t}\n\t\tfor (const cfg of npmConfigs) {\n\t\t\tif (clean.includes(cfg.npm)) return true;\n\t\t}\n\t\treturn clean.includes(\"@lwc/\") || clean.startsWith(\"\\0lwc-empty-css\");\n\t}\n\n\tconst stubAliases: Record<string, string> = {};\n\tfor (const [specifier, stubPath] of Object.entries(stubs)) {\n\t\tstubAliases[specifier] = path.resolve(stubPath);\n\t}\n\n\tconst interceptPrefixes = new Set<string>();\n\tfor (const p of resolvedProviders) {\n\t\tif (p.prefix && p.prefix.startsWith(\"@\")) {\n\t\t\tinterceptPrefixes.add(p.prefix.split(\"/\")[0] + \"/\");\n\t\t}\n\t}\n\n\t// Plugin-style providers (e.g. lds()) can contribute passthroughRules so\n\t// imports made from inside their virtual modules reach the real npm\n\t// package instead of being claimed by scopedProviders' broad\n\t// `@salesforce/` interceptPrefix.\n\tconst pluginPassthroughRules = rawPlugins.flatMap(\n\t\t(p) => (p as { passthroughRules?: PassthroughRule[] }).passthroughRules ?? [],\n\t);\n\n\tconst plugins: Plugin[] = [\n\t\t// Dev-only: injects the Live Preview bridge into index.html so LWC UI\n\t\t// Bundles work with the VSCode Live Preview extension. No-op during\n\t\t// `vite build`; degrades silently if @salesforce/ui-bundle is absent.\n\t\tlivePreview(),\n\t\t{\n\t\t\tname: \"vite-plugin-lwc-optimize-deps\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\texclude: [\"lwc\"],\n\t\t\t\t\t\tesbuildOptions: {\n\t\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"lwc-html-stub\",\n\t\t\t\t\t\t\t\t\tsetup(build: {\n\t\t\t\t\t\t\t\t\t\tonResolve: (\n\t\t\t\t\t\t\t\t\t\t\toptions: { filter: RegExp },\n\t\t\t\t\t\t\t\t\t\t\tcallback: (args: { path: string }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: string;\n\t\t\t\t\t\t\t\t\t\t\t\texternal: boolean;\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t) => void;\n\t\t\t\t\t\t\t\t\t}) {\n\t\t\t\t\t\t\t\t\t\t// esbuild cannot process LWC HTML templates (?lwc suffix).\n\t\t\t\t\t\t\t\t\t\t// Mark them as external so Vite's own plugin handles them.\n\t\t\t\t\t\t\t\t\t\tbuild.onResolve({ filter: /\\.html/ }, (args: { path: string }) => ({\n\t\t\t\t\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\t\t\t\t\texternal: true,\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t// plugins returned by plugin-style builtins (e.g. lds())\n\t\t...rawPlugins,\n\t\tscopedProviders(resolvedProviders, {\n\t\t\tignorePatterns,\n\t\t\tinterceptPrefixes: [...interceptPrefixes],\n\t\t\tpassthroughRules: [...passthroughRules, ...pluginPassthroughRules],\n\t\t}),\n\n\t\t...npmRoots.map((npmRoot) =>\n\t\t\tlightningNpm({\n\t\t\t\tnpmRoot,\n\t\t\t\toverrideDirs: lightningOverrideDirs,\n\t\t\t}),\n\t\t),\n\n\t\tmissingCss(),\n\t\tlwcBridge(isComponentAsset),\n\t\tlwcWrapper(\n\t\t\tloadLwcRollup,\n\t\t\t{\n\t\t\t\trootDir: process.cwd(),\n\t\t\t\t...lwcOptions,\n\t\t\t\tmodules: lwcModules,\n\t\t\t\texclude: [\n\t\t\t\t\t\"**/index.html\",\n\t\t\t\t\t\"**/node_modules/vite/**\",\n\t\t\t\t\t\"**/node_modules/.vite/**\",\n\t\t\t\t\t...((lwcOptions.exclude as string[]) || []),\n\t\t\t\t],\n\t\t\t},\n\t\t\tisComponentAsset,\n\t\t),\n\t];\n\n\tif (Object.keys(stubAliases).length > 0) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-stubs\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tresolve: {\n\t\t\t\t\t\talias: stubAliases,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\tif (!bundle) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-output-multifile\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tbuild: {\n\t\t\t\t\t\toutDir: \"dist\",\n\t\t\t\t\t\tassetsDir: \".\",\n\t\t\t\t\t\tcssCodeSplit: true,\n\t\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tentryFileNames: \"js/[name]-[hash].js\",\n\t\t\t\t\t\t\t\tchunkFileNames: \"js/[name]-[hash].js\",\n\t\t\t\t\t\t\t\tassetFileNames(info: { names?: string[]; name?: string }) {\n\t\t\t\t\t\t\t\t\tconst name = info.names?.[0] ?? info.name ?? \"\";\n\t\t\t\t\t\t\t\t\tif (name.endsWith(\".css\")) return \"css/[name]-[hash].css\";\n\t\t\t\t\t\t\t\t\treturn \"assets/[name]-[hash][extname]\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\tif (generateMetaXmlOption !== false) {\n\t\tconst metaOpts = generateMetaXmlOption === true ? {} : generateMetaXmlOption;\n\t\t// Only register when a target is configured — without one the plugin has\n\t\t// nothing to contribute over a hand-authored meta XML, so registering it\n\t\t// would just add a no-op closeBundle hook. It resolves the project root\n\t\t// itself via Vite's configResolved (accurate in a monorepo, unlike cwd).\n\t\tif (metaOpts.target) {\n\t\t\tplugins.push(generateMetaXml(metaOpts));\n\t\t}\n\t}\n\n\treturn plugins;\n}\n"],"names":["builtinProviders.labelsGraphql","builtinProviders.platformGraphql","builtinProviders.apex","builtinProviders.client","builtinProviders.gate","builtinProviders.messageChannel","builtinProviders.messageService","builtinProviders.navigation","builtinProviders.primitiveUtils","builtinProviders.lds","require"],"mappings":";;;;;;;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,W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AAAA,YACN,QAAQ;AAAA,YACR,WAAW;AAAA,YACX,cAAc;AAAA,YACd,eAAe;AAAA,cACd,QAAQ;AAAA,gBACP,gBAAgB;AAAA,gBAChB,gBAAgB;AAAA,gBAChB,eAAe,MAA2C;AACzD,wBAAM,OAAO,KAAK,QAAQ,CAAC,KAAK,KAAK,QAAQ;AAC7C,sBAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAClC,yBAAO;AAAA,gBACR;AAAA,cAAA;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,MAAI,0BAA0B,OAAO;AACpC,UAAM,WAAW,0BAA0B,OAAO,CAAA,IAAK;AAKvD,QAAI,SAAS,QAAQ;AACpB,cAAQ,KAAK,gBAAgB,QAAQ,CAAC;AAAA,IACvC;AAAA,EACD;AAEA,SAAO;AACR;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/discovery.ts","../src/plugins/generate-meta-xml.ts","../src/plugins/lightning-npm.ts","../src/plugins/live-preview.ts","../src/plugins/lwc-bridge.ts","../src/plugins/lwc-wrapper.ts","../src/plugins/missing-css.ts","../src/plugins/scoped-providers.ts","../src/plugins/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync, readdirSync, statSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { DirConfig, DiscoveredModule } from \"./types\";\n\nexport function discoverModules(dirs: (string | DirConfig)[] = []): DiscoveredModule[] {\n\tconst modules: DiscoveredModule[] = [];\n\n\tfor (const dir of dirs) {\n\t\tconst dirPath = typeof dir === \"string\" ? dir : dir.path;\n\t\tconst namespace = typeof dir === \"string\" ? undefined : dir.namespace;\n\t\tconst resolvedDir = path.resolve(dirPath);\n\n\t\tif (!existsSync(resolvedDir) || !statSync(resolvedDir).isDirectory()) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (namespace) {\n\t\t\t// Flat DX structure: <dir>/<componentName>/<componentName>.js\n\t\t\tfor (const name of readdirSync(resolvedDir)) {\n\t\t\t\tconst fullPath = path.join(resolvedDir, name);\n\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\tmodules.push({\n\t\t\t\t\t\tname: `${namespace}/${name}`,\n\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Standard structure: <dir>/<namespace>/<componentName>/<componentName>.js\n\t\t\tfor (const ns of readdirSync(resolvedDir)) {\n\t\t\t\tconst nsDir = path.join(resolvedDir, ns);\n\t\t\t\tif (!statSync(nsDir).isDirectory()) continue;\n\n\t\t\t\tfor (const name of readdirSync(nsDir)) {\n\t\t\t\t\tconst fullPath = path.join(nsDir, name);\n\t\t\t\t\tif (!statSync(fullPath).isDirectory()) continue;\n\n\t\t\t\t\tconst entryPath = path.join(fullPath, `${name}.js`);\n\t\t\t\t\tif (existsSync(entryPath)) {\n\t\t\t\t\t\tmodules.push({\n\t\t\t\t\t\t\tname: `${ns}/${name}`,\n\t\t\t\t\t\t\tpath: path.resolve(entryPath),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modules;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { access, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n\tgenerateUIBundleMetaXml,\n\tloadManifest,\n\tresolveMetaTarget,\n\tUI_BUNDLE_TARGETS,\n} from \"@salesforce/ui-bundle/app\";\nimport type { Plugin } from \"vite\";\nimport type { GenerateMetaXmlOptions } from \"../types\";\n\n/**\n * Vite plugin that writes the bundle's `*.uibundle-meta.xml` at build time.\n *\n * The `<target>` comes from `options.target` (configured on the Vite plugin,\n * NOT read from `ui-bundle.json` — the platform's manifest schema rejects a\n * `target` field). No-op unless a `target` is supplied. By default it won't\n * overwrite a meta XML that already declares a `<target>` (hand-authored\n * targets win); set `overwriteExisting: true` to change that.\n */\nexport function generateMetaXml(options: GenerateMetaXmlOptions = {}): Plugin {\n\t// Resolved from Vite's `configResolved` hook. `resolvedConfig.root` is the\n\t// project root even in a monorepo, which `process.cwd()` does not reliably\n\t// give (it depends on where the build was invoked from).\n\tlet root = process.cwd();\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-generate-meta-xml\",\n\t\tconfigResolved(config) {\n\t\t\troot = config.root;\n\t\t},\n\t\tasync closeBundle() {\n\t\t\t// Only generate when a build-time target is supplied — otherwise we\n\t\t\t// have nothing to contribute over a hand-authored meta XML.\n\t\t\tif (!options.target) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Guard JS consumers (e.g. vite.config.js) who bypass the TS union type.\n\t\t\tif (!resolveMetaTarget(options.target)) {\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Unknown generateMetaXml.target \"${String(options.target)}\"; expected one of ` +\n\t\t\t\t\t\t`${UI_BUNDLE_TARGETS.join(\", \")}. Skipping meta XML generation.`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst manifestPath = options.manifestPath ?? path.join(root, \"ui-bundle.json\");\n\t\t\tconst bundleName = options.bundleName ?? path.basename(root);\n\n\t\t\tif (!(await pathExists(manifestPath))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst manifest = await loadManifest(manifestPath);\n\t\t\tconst dir = path.dirname(manifestPath);\n\t\t\t// A UIBundle's meta file is named after the bundle; that is the file we\n\t\t\t// write. This is deterministic — we never retarget a differently-named\n\t\t\t// meta file that happens to sit in the directory.\n\t\t\tconst metaPath = path.join(dir, `${bundleName}.uibundle-meta.xml`);\n\n\t\t\tconst strays = (await readdir(dir))\n\t\t\t\t.filter((f) => f.endsWith(\".uibundle-meta.xml\") && f !== path.basename(metaPath))\n\t\t\t\t.sort();\n\t\t\tif (strays.length > 0) {\n\t\t\t\tthis.warn(\n\t\t\t\t\t`Ignoring ${strays.join(\", \")} in ${dir}; writing the bundle's meta XML to ` +\n\t\t\t\t\t\t`${path.basename(metaPath)} (named after the bundle \"${bundleName}\").`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!options.overwriteExisting) {\n\t\t\t\tconst existing = await readIfExists(metaPath);\n\t\t\t\tif (existing?.includes(\"<target>\")) {\n\t\t\t\t\tthis.warn(\n\t\t\t\t\t\t`${path.basename(metaPath)} already declares a <target>; skipping target ` +\n\t\t\t\t\t\t\t`generation. Set generateMetaXml.overwriteExisting to override.`,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst xml = generateUIBundleMetaXml(manifest, bundleName, {\n\t\t\t\ttarget: options.target,\n\t\t\t\tdescription: options.description,\n\t\t\t});\n\t\t\tawait writeFile(metaPath, xml, \"utf-8\");\n\t\t},\n\t};\n}\n\n/** Whether a path exists. */\nasync function pathExists(p: string): Promise<boolean> {\n\ttry {\n\t\tawait access(p);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Read a file's text, or `null` if it does not exist. */\nasync function readIfExists(p: string): Promise<string | null> {\n\ttry {\n\t\treturn await readFile(p, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { LightningNpmOptions } from \"../types\";\n\nfunction resolveJsFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.js`);\n\tif (existsSync(nested)) return nested;\n\tconst flat = path.join(root, `${sub}.js`);\n\tif (existsSync(flat)) return flat;\n\treturn null;\n}\n\nfunction resolveCssFromRoot(root: string, sub: string): string | null {\n\tconst segments = sub.split(\"/\");\n\tconst leaf = segments[segments.length - 1];\n\tconst nested = path.join(root, ...segments, `${leaf}.css`);\n\treturn existsSync(nested) ? nested : null;\n}\n\nexport function lightningNpm({ npmRoot, overrideDirs = [] }: LightningNpmOptions): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-resolve-lightning-npm\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(importee) {\n\t\t\tif (!importee.startsWith(\"lightning/\")) return null;\n\n\t\t\tconst sub = importee.slice(\"lightning/\".length);\n\t\t\tconst segments = sub.split(\"/\");\n\t\t\tconst leaf = segments[segments.length - 1];\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst overridePath = path.join(dir, ...segments, `${leaf}.js`);\n\t\t\t\tif (existsSync(overridePath)) return null;\n\t\t\t}\n\n\t\t\tconst npmJs = resolveJsFromRoot(npmRoot, sub);\n\t\t\tif (npmJs) return npmJs;\n\n\t\t\tfor (const dir of overrideDirs) {\n\t\t\t\tconst cssFallback = path.join(dir, ...segments, `${leaf}.css`);\n\t\t\t\tif (existsSync(cssFallback)) return cssFallback;\n\t\t\t}\n\n\t\t\treturn resolveCssFromRoot(npmRoot, sub);\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\nexport interface LivePreviewOptions {\n\t/** Enable verbose logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that injects the Salesforce Live Preview bridge script into the\n * dev server's HTML so LWC UI Bundles work with the VSCode Live Preview\n * extension.\n *\n * The bridge (from `@salesforce/ui-bundle/proxy`) establishes a `postMessage`\n * channel from the previewed iframe to the VSCode webview: it forwards runtime\n * errors, unhandled rejections, network failures, and compile errors, plus\n * copy/paste, keyboard shortcuts, and a heartbeat. It is the same script the\n * React/generic `@salesforce/vite-plugin-ui-bundle` injects — sharing it keeps\n * the two dev-server paths behaviourally identical.\n *\n * Injection is **dev-only** (Vite `command === \"serve\"`). The compiled bundle\n * targets MCP hosts (ChatGPT, MCP Apps) and must never carry the dev bridge, so\n * the `transformIndexHtml` hook is a no-op during `vite build`.\n *\n * `@salesforce/ui-bundle` is an optional peer dependency; if it is not\n * installed the injection is skipped silently (a warning is logged only in\n * `debug` mode) and the dev server runs without Live Preview support.\n *\n * Included by default in `lwcVitePlugin()`. Available standalone for callers\n * who compose their own plugin array:\n * import { livePreview } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [livePreview(), lwcVitePlugin({ providers: [...] })]\n */\nexport function livePreview(options: LivePreviewOptions = {}): Plugin {\n\tlet isServe = false;\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-live-preview\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config) {\n\t\t\tisServe = config.command === \"serve\";\n\t\t},\n\n\t\ttransformIndexHtml: {\n\t\t\torder: \"pre\",\n\t\t\tasync handler(html) {\n\t\t\t\t// Only inject during local dev (`vite` / `vite dev`). Never during\n\t\t\t\t// `vite build` — the artifact ships to MCP hosts without the bridge.\n\t\t\t\tif (!isServe) return html;\n\n\t\t\t\ttry {\n\t\t\t\t\t// Dynamic import: @salesforce/ui-bundle is an OPTIONAL peer dep,\n\t\t\t\t\t// so a missing install must degrade gracefully, not hard-fail.\n\t\t\t\t\tconst { injectLivePreviewScript } = await import(\"@salesforce/ui-bundle/proxy\");\n\t\t\t\t\tconst injected = injectLivePreviewScript(html);\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.log(\"[lwc-live-preview] Injected Live Preview bridge script\");\n\t\t\t\t\t}\n\t\t\t\t\treturn injected;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`[lwc-live-preview] @salesforce/ui-bundle not available; skipping Live Preview injection.\\n ${msg}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn html;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\n\nexport function lwcBridge(isComponentAsset: (id: string) => boolean): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-bridge\",\n\t\tenforce: \"pre\",\n\n\t\tconfigResolved(config: ResolvedConfig) {\n\t\t\tfor (const plugin of config.plugins) {\n\t\t\t\tif (plugin.name === \"vite:css\" || plugin.name === \"vite:css-post\") {\n\t\t\t\t\tconst p = plugin as unknown as Record<string, unknown>;\n\t\t\t\t\tconst origTransform = p[\"transform\"];\n\t\t\t\t\tif (!origTransform) continue;\n\n\t\t\t\t\tif (typeof origTransform === \"function\") {\n\t\t\t\t\t\t// Vite <7: transform is a plain function\n\t\t\t\t\t\tp[\"transform\"] = function (\n\t\t\t\t\t\t\tthis: unknown,\n\t\t\t\t\t\t\tcode: string,\n\t\t\t\t\t\t\tid: string,\n\t\t\t\t\t\t\t...rest: unknown[]\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\treturn (origTransform as (...a: unknown[]) => unknown).call(this, code, id, ...rest);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (\n\t\t\t\t\t\ttypeof origTransform === \"object\" &&\n\t\t\t\t\t\ttypeof (origTransform as Record<string, unknown>)[\"handler\"] === \"function\"\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Vite 7+: transform is { handler, order? }\n\t\t\t\t\t\tconst origHandler = (origTransform as Record<string, unknown>)[\"handler\"] as (\n\t\t\t\t\t\t\t...a: unknown[]\n\t\t\t\t\t\t) => unknown;\n\t\t\t\t\t\tp[\"transform\"] = {\n\t\t\t\t\t\t\t...(origTransform as object),\n\t\t\t\t\t\t\thandler: function (this: unknown, code: string, id: string, ...rest: unknown[]) {\n\t\t\t\t\t\t\t\tif (isComponentAsset(id)) return;\n\t\t\t\t\t\t\t\treturn origHandler.call(this, code, id, ...rest);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\tresolveId(id, importer) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tconst cleanId = id.split(\"?\", 2)[0] ?? id;\n\n\t\t\tif (cleanId.endsWith(\".html\") && isComponentAsset(cleanId) && !id.includes(\"?lwc\")) {\n\t\t\t\treturn `${cleanId}?lwc`;\n\t\t\t}\n\n\t\t\tif (!importer) return null;\n\t\t\tif (!cleanId.endsWith(\".html\")) return null;\n\t\t\tif (!cleanId.startsWith(\"./\") && !cleanId.startsWith(\"../\")) return null;\n\t\t\tif (!isComponentAsset(importer)) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importer.split(\"?\")[0] ?? importer), cleanId);\n\n\t\t\tif (existsSync(resolved)) {\n\t\t\t\treturn resolved + \"?lwc\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(\"@lwc/resources/\")) {\n\t\t\t\treturn \"export default undefined;\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\n\ntype AnyFn = (this: unknown, ...args: unknown[]) => unknown;\ntype LwcRollupFactory = (options: Record<string, unknown>) => Plugin;\ntype LazyLwcRollupLoader = () => Promise<LwcRollupFactory>;\n\nexport function lwcWrapper(\n\tlazyLoader: LazyLwcRollupLoader,\n\toptions: Record<string, unknown>,\n\tisComponentAsset?: (id: string) => boolean,\n): Plugin {\n\tlet pluginPromise: Promise<Plugin> | null = null;\n\n\tconst getPlugin = () => {\n\t\tif (!pluginPromise) {\n\t\t\tpluginPromise = lazyLoader().then((factory) => factory(options));\n\t\t}\n\t\treturn pluginPromise;\n\t};\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-wrapper\",\n\t\tenforce: \"pre\" as const,\n\t\tasync resolveId(importee: string, importer?: string) {\n\t\t\tif (importer?.split(\"?\")[0]?.endsWith(\"index.html\") && !importer.includes(\"html-proxy\"))\n\t\t\t\treturn null;\n\t\t\tif (importee.startsWith(\"/@\") || importee.startsWith(\"\\0\")) return null;\n\t\t\tif (importer?.includes(\"/node_modules/vite/\")) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.resolveId === \"function\"\n\t\t\t\t? (plugin.resolveId as AnyFn).call(this, importee, importer)\n\t\t\t\t: null;\n\t\t},\n\t\tasync load(id: string) {\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.load === \"function\" ? (plugin.load as AnyFn).call(this, id) : null;\n\t\t},\n\t\tasync transform(code: string, id: string) {\n\t\t\t// Only pass files to the LWC compiler if they are LWC component assets.\n\t\t\t// Non-component files (SDK sources, node_modules, etc.) must be skipped.\n\t\t\tif (isComponentAsset && !isComponentAsset(id)) return null;\n\t\t\tconst plugin = await getPlugin();\n\t\t\treturn typeof plugin.transform === \"function\"\n\t\t\t\t? (plugin.transform as AnyFn).call(this, code, id)\n\t\t\t\t: null;\n\t\t},\n\t} as Plugin;\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst LWC_EMPTY_CSS = \"\\0lwc-empty-css\";\n\nexport function missingCss(): Plugin {\n\treturn {\n\t\tname: \"vite-plugin-lwc-missing-css\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\tif (!importer || !id.startsWith(\"./\") || !id.includes(\".css\")) return null;\n\t\t\tconst importerPath = importer.split(\"?\")[0] ?? importer;\n\t\t\tif (!importerPath.endsWith(\".html\")) return null;\n\n\t\t\tconst resolved = path.resolve(path.dirname(importerPath), id.split(\"?\")[0] ?? id);\n\t\t\tif (existsSync(resolved)) return null;\n\n\t\t\treturn `${LWC_EMPTY_CSS}?${id}`;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (id.startsWith(LWC_EMPTY_CSS)) {\n\t\t\t\treturn \"export default undefined\";\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { Plugin } from \"vite\";\nimport type { Provider, ScopedProvidersOptions } from \"../types\";\n\nconst VIRTUAL_PREFIX = \"\\0sf-provider:\";\n\nexport function scopedProviders(\n\tproviders: Provider[] = [],\n\toptions: ScopedProvidersOptions = {},\n): Plugin {\n\tconst { ignorePatterns = [], interceptPrefixes = [], passthroughRules = [] } = options;\n\n\tconst prefixSet = new Set<string>();\n\tfor (const p of providers) {\n\t\tif (p.prefix) prefixSet.add(p.prefix);\n\t}\n\n\tfunction shouldIntercept(id: string): boolean {\n\t\tfor (const prefix of prefixSet) {\n\t\t\tif (id === prefix || id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const prefix of interceptPrefixes) {\n\t\t\tif (id.startsWith(prefix)) return true;\n\t\t}\n\t\tfor (const p of providers) {\n\t\t\tif (!p.prefix && typeof p.match === \"function\" && p.match(id)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-scoped-module-providers\",\n\t\tenforce: \"pre\",\n\n\t\tresolveId(id, importer) {\n\t\t\t// Explicit provider prefix always wins over ignorePatterns —\n\t\t\t// if a provider is registered for a specifier, it always handles it.\n\t\t\tconst handledByProvider = [...prefixSet].some((p) => id === p || id.startsWith(p + \"/\"));\n\n\t\t\tif (!handledByProvider) {\n\t\t\t\tif (!shouldIntercept(id)) return null;\n\n\t\t\t\tfor (const pattern of ignorePatterns) {\n\t\t\t\t\tif (id.startsWith(pattern)) return null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const rule of passthroughRules) {\n\t\t\t\tif (\n\t\t\t\t\timporter &&\n\t\t\t\t\tid.startsWith(rule.specifierPrefix) &&\n\t\t\t\t\timporter.includes(rule.importerPattern)\n\t\t\t\t) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn VIRTUAL_PREFIX + id;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(VIRTUAL_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(VIRTUAL_PREFIX.length);\n\n\t\t\tfor (const provider of providers) {\n\t\t\t\tconst result = provider.resolve(specifier);\n\t\t\t\tif (result != null) return result;\n\t\t\t}\n\n\t\t\tconsole.warn(\n\t\t\t\t`[scoped-module-providers] Unhandled import: ${specifier} — returning undefined`,\n\t\t\t);\n\t\t\treturn `export default undefined;`;\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport type { Plugin } from \"vite\";\n\nexport interface LwcProxyOptions {\n\t/** Salesforce org alias (defaults to the sf CLI default org) */\n\torgAlias?: string;\n\t/** Enable verbose request logging */\n\tdebug?: boolean;\n}\n\n/**\n * Vite plugin that proxies Salesforce API calls to a connected org.\n *\n * Uses the same authentication approach as @salesforce/vite-plugin-ui-bundle —\n * reads credentials from the sf CLI via @salesforce/ui-bundle/app.\n *\n * Intercepts requests to /services/ and /lwr/ and forwards them to Salesforce\n * with the org's access token. Handles token refresh on 401/403 responses.\n *\n * Usage in vite.config.js:\n * import { lwcProxy } from '@salesforce/vite-plugin-lwc-ui-bundle';\n * plugins: [lwcVitePlugin(...), lwcProxy()]\n *\n * Then initialise the SDK in your app's bootstrap:\n * import { createDataSDK } from '@salesforce/platform-sdk';\n * globalThis.__sfdc_sdk__ = await createDataSDK({ uiBundle: { basePath: '/' } });\n */\nexport function lwcProxy(options: LwcProxyOptions = {}): Plugin {\n\tlet instanceUrl: string | undefined;\n\tlet accessToken: string | undefined;\n\tconst orgAlias: string | undefined = options.orgAlias;\n\n\tasync function loadOrgInfo(): Promise<void> {\n\t\ttry {\n\t\t\t// Dynamically import to avoid bundling @salesforce/ui-bundle at build time\n\t\t\tconst { getOrgInfo } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await getOrgInfo(orgAlias);\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t\tif (options.debug) {\n\t\t\t\t\tconsole.log(`[lwc-proxy] Connected to ${instanceUrl}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.error(\n\t\t\t\t`[lwc-proxy] Failed to load org info — is a Salesforce org connected?\\n ${msg}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync function refreshToken(): Promise<void> {\n\t\ttry {\n\t\t\tconst { refreshOrgAuth } = await import(\"@salesforce/ui-bundle/app\");\n\t\t\tconst info = await refreshOrgAuth(orgAlias ?? \"\");\n\t\t\tif (info) {\n\t\t\t\tinstanceUrl = info.rawInstanceUrl ?? info.instanceUrl;\n\t\t\t\taccessToken = info.accessToken;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore refresh errors\n\t\t}\n\t}\n\n\treturn {\n\t\tname: \"vite-plugin-lwc-proxy\",\n\t\tenforce: \"pre\",\n\n\t\tasync configResolved() {\n\t\t\tawait loadOrgInfo();\n\t\t},\n\n\t\tconfigureServer(server) {\n\t\t\tserver.middlewares.use(async (req, res, next) => {\n\t\t\t\tconst url = req.url ?? \"\";\n\n\t\t\t\t// Only proxy Salesforce API paths\n\t\t\t\tif (!url.startsWith(\"/services/\") && !url.startsWith(\"/lwr/\")) {\n\t\t\t\t\treturn next();\n\t\t\t\t}\n\n\t\t\t\tif (!instanceUrl || !accessToken) {\n\t\t\t\t\tres.writeHead(503, { \"Content-Type\": \"application/json\" });\n\t\t\t\t\tres.end(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\terror: \"SERVICE_UNAVAILABLE\",\n\t\t\t\t\t\t\tmessage: \"Salesforce org not connected. Run: sf org display\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst forward = async (token: string): Promise<void> => {\n\t\t\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\t\t\tconst targetUrl = new URL(url, instanceUrl);\n\t\t\t\t\t\tconst isHttps = targetUrl.protocol === \"https:\";\n\t\t\t\t\t\tconst transport = isHttps ? https : http;\n\n\t\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\t\tconsole.log(`[lwc-proxy] ${req.method} ${url}`);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Strip hop-by-hop headers\n\t\t\t\t\t\tconst headers: Record<string, string | string[]> = {};\n\t\t\t\t\t\tfor (const [key, value] of Object.entries(req.headers)) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t![\n\t\t\t\t\t\t\t\t\t\"host\",\n\t\t\t\t\t\t\t\t\t\"connection\",\n\t\t\t\t\t\t\t\t\t\"keep-alive\",\n\t\t\t\t\t\t\t\t\t\"proxy-authenticate\",\n\t\t\t\t\t\t\t\t\t\"proxy-authorization\",\n\t\t\t\t\t\t\t\t\t\"te\",\n\t\t\t\t\t\t\t\t\t\"trailers\",\n\t\t\t\t\t\t\t\t\t\"transfer-encoding\",\n\t\t\t\t\t\t\t\t\t\"upgrade\",\n\t\t\t\t\t\t\t\t].includes(key.toLowerCase()) &&\n\t\t\t\t\t\t\t\tvalue !== undefined\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\theaders[key] = value as string | string[];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\theaders[\"host\"] = targetUrl.host;\n\t\t\t\t\t\theaders[\"authorization\"] = `Bearer ${token}`;\n\t\t\t\t\t\theaders[\"cookie\"] = `sid=${token}`;\n\n\t\t\t\t\t\tconst proxyReq = transport.request(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\t\thostname: targetUrl.hostname,\n\t\t\t\t\t\t\t\tport: targetUrl.port || (isHttps ? 443 : 80),\n\t\t\t\t\t\t\t\tpath: targetUrl.pathname + targetUrl.search,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(proxyRes) => {\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\tres.writeHead(proxyRes.statusCode ?? 200, proxyRes.headers);\n\t\t\t\t\t\t\t\tproxyRes.pipe(res);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treq.pipe(proxyReq);\n\t\t\t\t\t\tproxyReq.on(\"error\", reject);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\tawait forward(accessToken!);\n\n\t\t\t\t\t// On 401/403, refresh token and retry once\n\t\t\t\t\t// Note: we can't easily check status here since we piped to res,\n\t\t\t\t\t// so we rely on the transform hook below for retries in future iterations\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (options.debug) {\n\t\t\t\t\t\tconsole.error(\"[lwc-proxy] Request failed:\", error);\n\t\t\t\t\t}\n\t\t\t\t\t// Try refreshing token and retry\n\t\t\t\t\tawait refreshToken();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait forward(accessToken!);\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\tnext(err);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { singleFilePlugins } from \"@salesforce/ui-bundle/vite\";\nimport type { Plugin } from \"vite\";\nimport { discoverModules } from \"./discovery\";\nimport { generateMetaXml } from \"./plugins/generate-meta-xml\";\nimport { lightningNpm } from \"./plugins/lightning-npm\";\nimport { livePreview } from \"./plugins/live-preview\";\nimport { lwcBridge } from \"./plugins/lwc-bridge\";\nimport { lwcWrapper } from \"./plugins/lwc-wrapper\";\nimport { missingCss } from \"./plugins/missing-css\";\nimport { scopedProviders } from \"./plugins/scoped-providers\";\nimport * as builtinProviders from \"./providers/index\";\nimport type { LabelsGraphqlOptions, PlatformGraphqlOptions } from \"./providers/index\";\nimport type {\n\tDirConfig,\n\tLwcVitePluginOptions,\n\tNpmModuleConfig,\n\tPassthroughRule,\n\tProvider,\n} from \"./types\";\n\nexport type {\n\tProvider,\n\tLwcVitePluginOptions,\n\tOutputMode,\n\tGenerateMetaXmlOptions,\n\tPassthroughRule,\n\tDiscoveredModule,\n\tDirConfig,\n} from \"./types\";\nexport { builtinProviders as builtins };\nexport { discoverModules } from \"./discovery\";\nexport { lwcProxy } from \"./plugins/proxy\";\nexport type { LwcProxyOptions } from \"./plugins/proxy\";\nexport { livePreview } from \"./plugins/live-preview\";\nexport type { LivePreviewOptions } from \"./plugins/live-preview\";\n\n/**\n * Options for {@link defaultProviders}. Each key configures the corresponding\n * built-in provider without having to reconstruct the whole default array. Any\n * provider you don't mention keeps its default configuration.\n */\nexport interface DefaultProvidersOptions {\n\t/**\n\t * Options for the GraphQL-backed permission / i18n provider. Use this to\n\t * declare the required first-paint values for the `@salesforce/userPermission/*`\n\t * and `@salesforce/customPermission/*` your bundle imports.\n\t */\n\tplatformGraphql?: PlatformGraphqlOptions;\n\t/** Options for the GraphQL-backed label provider (e.g. `staticOverrides`). */\n\tlabelsGraphql?: LabelsGraphqlOptions;\n}\n\n/**\n * The default provider registry, used when `lwcVitePlugin` is called without an\n * explicit `providers` array. Exported so a consumer can tweak a single\n * provider's options — most commonly declaring `userPermissionDefaults` — while\n * keeping every other default in place, instead of hand-listing all ~10 builtins:\n *\n * ```js\n * lwcVitePlugin({\n * providers: defaultProviders({\n * platformGraphql: { userPermissionDefaults: { ApiEnabled: false } },\n * }),\n * });\n * ```\n */\nexport function defaultProviders(options: DefaultProvidersOptions = {}): (Provider | Plugin)[] {\n\treturn [\n\t\t// Resolve @salesforce/label/* via GraphQL through the Platform Data SDK by\n\t\t// default (W-22167030); the generated modules carry a static fallback so\n\t\t// labels still render when no data surface is available. Use the static\n\t\t// builtins.label() provider explicitly to opt out of runtime fetching.\n\t\tbuiltinProviders.labelsGraphql(options.labelsGraphql),\n\t\t// Resolve @salesforce/i18n/*, @salesforce/userPermission/*,\n\t\t// @salesforce/customPermission/* and @salesforce/accessCheck/* via the\n\t\t// uiapi.platform.* GraphQL fields off-core through the Platform Data SDK\n\t\t// (W-22167030). i18n format/calendar keys stay static (CLDR, no org source).\n\t\t// Replaces the static builtins.i18n() + builtins.accessCheck() providers;\n\t\t// those remain exported for explicit opt-out.\n\t\tbuiltinProviders.platformGraphql(options.platformGraphql),\n\t\tbuiltinProviders.apex(),\n\t\tbuiltinProviders.client(),\n\t\t// @salesforce/gate/* stays static: its GraphQL field (uiapi.platform.gates)\n\t\t// is UiTier-context-only and not reachable off-core (verified: FieldUndefined\n\t\t// / \"can only be executed in a UiTier context\").\n\t\tbuiltinProviders.gate(),\n\t\tbuiltinProviders.messageChannel(),\n\t\tbuiltinProviders.messageService(),\n\t\tbuiltinProviders.navigation(),\n\t\tbuiltinProviders.primitiveUtils(),\n\t\tbuiltinProviders.lds(),\n\t];\n}\n\n/** Distinguishes a scoped-providers `Provider` from a raw Vite `Plugin`. */\nfunction isProvider(item: Provider | Plugin): item is Provider {\n\treturn typeof (item as Provider).resolve === \"function\";\n}\n\nasync function loadLwcRollup() {\n\ttry {\n\t\t// Use dynamic import to load ESM-only @lwc/rollup-plugin (peer dep, types not guaranteed)\n\t\tconst mod = await (import(\"@lwc/rollup-plugin\") as Promise<Record<string, unknown>>);\n\t\treturn (mod[\"default\"] ?? mod) as unknown as (options: Record<string, unknown>) => Plugin;\n\t} catch (error) {\n\t\tconst errMsg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle requires @lwc/rollup-plugin as a peer dependency. \" +\n\t\t\t\t\"Install it with: npm install -D @lwc/rollup-plugin\\n\" +\n\t\t\t\t`Debug: cwd=${process.cwd()}, error=${errMsg}`,\n\t\t);\n\t}\n}\n\nexport default function lwcVitePlugin(options: LwcVitePluginOptions = {}): Plugin[] {\n\tconst {\n\t\tmodules = {},\n\t\tproviders,\n\t\tstubs = {},\n\t\tlwcOptions = {},\n\t\tignorePatterns = [\n\t\t\t// Legacy @salesforce/sdk-* prefix — kept for external consumers still on the\n\t\t\t// pre-rename package names. The `@salesforce/platform-sdk-` prefix covers the\n\t\t\t// individual platform-sdk-* packages (still in place pending deprecation);\n\t\t\t// `@salesforce/platform-sdk` (no trailing dash) covers the consolidated package.\n\t\t\t\"@salesforce/sdk-\",\n\t\t\t\"@salesforce/platform-sdk-\",\n\t\t\t\"@salesforce/platform-sdk\",\n\t\t\t\"@salesforce/core\",\n\t\t\t// Transitive runtime deps of the Platform Data SDK (e.g. the embedding\n\t\t\t// bridge and its JSON-RPC client). These are real npm packages the SDK\n\t\t\t// needs at runtime — let them resolve normally instead of being claimed\n\t\t\t// by the broad `@salesforce/` scoped-provider interception (which would\n\t\t\t// stub them to `undefined` and break the SDK on the OpenAI/MCP surface).\n\t\t\t// The bridge exposes NAMED exports (e.g. `readHostMetaData`, imported by\n\t\t\t// platform-sdk's surface detection), so a default-only `undefined` stub\n\t\t\t// breaks the build outright — it must resolve to the real package.\n\t\t\t\"@salesforce/jsonrpc\",\n\t\t\t\"@salesforce/sf-embedding-bridge\",\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t],\n\t\tpassthroughRules = [],\n\t\tbundle,\n\t\toutputMode = bundle === false ? \"unbundled\" : \"bundled\",\n\t\tgenerateMetaXml: generateMetaXmlOption = true,\n\t} = options;\n\n\tif (bundle !== undefined && options.outputMode !== undefined) {\n\t\tthrow new Error(\n\t\t\t\"@salesforce/vite-plugin-lwc-ui-bundle: `bundle` is deprecated and cannot be combined \" +\n\t\t\t\t'with `outputMode`. Use `outputMode: \"unbundled\"` instead of `bundle: false`.',\n\t\t);\n\t}\n\n\tif (![\"bundled\", \"unbundled\", \"single-file\"].includes(outputMode)) {\n\t\tthrow new Error(\n\t\t\t`@salesforce/vite-plugin-lwc-ui-bundle: unknown outputMode ${JSON.stringify(outputMode)}. ` +\n\t\t\t\t'Use \"bundled\", \"unbundled\" or \"single-file\".',\n\t\t);\n\t}\n\n\tconst resolvedItems = providers ?? defaultProviders();\n\tconst resolvedProviders = resolvedItems.filter(isProvider);\n\tconst rawPlugins = resolvedItems.filter((item): item is Plugin => !isProvider(item));\n\n\tconst { dirs = [], npm: npmPackages = [] } = modules;\n\n\tconst resolvedDirs: DirConfig[] = dirs.map((d) =>\n\t\ttypeof d === \"string\"\n\t\t\t? { path: path.resolve(d), namespace: \"\" }\n\t\t\t: { ...d, path: path.resolve(d.path) },\n\t);\n\n\tconst npmConfigs: NpmModuleConfig[] = npmPackages.map((pkg) =>\n\t\ttypeof pkg === \"string\" ? { npm: pkg } : pkg,\n\t);\n\n\tconst require = createRequire(import.meta.url);\n\tconst npmRoots = npmConfigs.map((cfg) => {\n\t\tconst pkgJson = require.resolve(`${cfg.npm}/package.json`);\n\t\treturn path.join(path.dirname(pkgJson), \"src\", \"lightning\");\n\t});\n\n\tconst discoveredModules = discoverModules(dirs);\n\n\tconst lwcModules = [...npmConfigs, ...discoveredModules];\n\n\tconst lightningOverrideDirs = resolvedDirs.map((d) => path.join(d.path, \"lightning\"));\n\n\tfunction isComponentAsset(id: string): boolean {\n\t\tconst clean = id.split(\"?\")[0] ?? id;\n\t\tfor (const dir of resolvedDirs) {\n\t\t\tif (clean.includes(dir.path)) return true;\n\t\t}\n\t\tfor (const cfg of npmConfigs) {\n\t\t\tif (clean.includes(cfg.npm)) return true;\n\t\t}\n\t\treturn clean.includes(\"@lwc/\") || clean.startsWith(\"\\0lwc-empty-css\");\n\t}\n\n\tconst stubAliases: Record<string, string> = {};\n\tfor (const [specifier, stubPath] of Object.entries(stubs)) {\n\t\tstubAliases[specifier] = path.resolve(stubPath);\n\t}\n\n\tconst interceptPrefixes = new Set<string>();\n\tfor (const p of resolvedProviders) {\n\t\tif (p.prefix && p.prefix.startsWith(\"@\")) {\n\t\t\tinterceptPrefixes.add(p.prefix.split(\"/\")[0] + \"/\");\n\t\t}\n\t}\n\n\t// Plugin-style providers (e.g. lds()) can contribute passthroughRules so\n\t// imports made from inside their virtual modules reach the real npm\n\t// package instead of being claimed by scopedProviders' broad\n\t// `@salesforce/` interceptPrefix.\n\tconst pluginPassthroughRules = rawPlugins.flatMap(\n\t\t(p) => (p as { passthroughRules?: PassthroughRule[] }).passthroughRules ?? [],\n\t);\n\n\tconst plugins: Plugin[] = [\n\t\t// Dev-only: injects the Live Preview bridge into index.html so LWC UI\n\t\t// Bundles work with the VSCode Live Preview extension. No-op during\n\t\t// `vite build`; degrades silently if @salesforce/ui-bundle is absent.\n\t\tlivePreview(),\n\t\t{\n\t\t\tname: \"vite-plugin-lwc-optimize-deps\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\toptimizeDeps: {\n\t\t\t\t\t\texclude: [\"lwc\"],\n\t\t\t\t\t\tesbuildOptions: {\n\t\t\t\t\t\t\tplugins: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tname: \"lwc-html-stub\",\n\t\t\t\t\t\t\t\t\tsetup(build: {\n\t\t\t\t\t\t\t\t\t\tonResolve: (\n\t\t\t\t\t\t\t\t\t\t\toptions: { filter: RegExp },\n\t\t\t\t\t\t\t\t\t\t\tcallback: (args: { path: string }) => {\n\t\t\t\t\t\t\t\t\t\t\t\tpath: string;\n\t\t\t\t\t\t\t\t\t\t\t\texternal: boolean;\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t) => void;\n\t\t\t\t\t\t\t\t\t}) {\n\t\t\t\t\t\t\t\t\t\t// esbuild cannot process LWC HTML templates (?lwc suffix).\n\t\t\t\t\t\t\t\t\t\t// Mark them as external so Vite's own plugin handles them.\n\t\t\t\t\t\t\t\t\t\tbuild.onResolve({ filter: /\\.html/ }, (args: { path: string }) => ({\n\t\t\t\t\t\t\t\t\t\t\tpath: args.path,\n\t\t\t\t\t\t\t\t\t\t\texternal: true,\n\t\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t// plugins returned by plugin-style builtins (e.g. lds())\n\t\t...rawPlugins,\n\t\tscopedProviders(resolvedProviders, {\n\t\t\tignorePatterns,\n\t\t\tinterceptPrefixes: [...interceptPrefixes],\n\t\t\tpassthroughRules: [...passthroughRules, ...pluginPassthroughRules],\n\t\t}),\n\n\t\t...npmRoots.map((npmRoot) =>\n\t\t\tlightningNpm({\n\t\t\t\tnpmRoot,\n\t\t\t\toverrideDirs: lightningOverrideDirs,\n\t\t\t}),\n\t\t),\n\n\t\tmissingCss(),\n\t\tlwcBridge(isComponentAsset),\n\t\tlwcWrapper(\n\t\t\tloadLwcRollup,\n\t\t\t{\n\t\t\t\trootDir: process.cwd(),\n\t\t\t\t...lwcOptions,\n\t\t\t\tmodules: lwcModules,\n\t\t\t\texclude: [\n\t\t\t\t\t\"**/index.html\",\n\t\t\t\t\t\"**/node_modules/vite/**\",\n\t\t\t\t\t\"**/node_modules/.vite/**\",\n\t\t\t\t\t...((lwcOptions.exclude as string[]) || []),\n\t\t\t\t],\n\t\t\t},\n\t\t\tisComponentAsset,\n\t\t),\n\t];\n\n\tif (Object.keys(stubAliases).length > 0) {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-stubs\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tresolve: {\n\t\t\t\t\t\talias: stubAliases,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\tif (outputMode === \"unbundled\") {\n\t\tplugins.push({\n\t\t\tname: \"vite-plugin-lwc-output-multifile\",\n\t\t\tenforce: \"pre\",\n\t\t\tconfig() {\n\t\t\t\treturn {\n\t\t\t\t\tbuild: {\n\t\t\t\t\t\toutDir: \"dist\",\n\t\t\t\t\t\tassetsDir: \".\",\n\t\t\t\t\t\tcssCodeSplit: true,\n\t\t\t\t\t\trollupOptions: {\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\tentryFileNames: \"js/[name]-[hash].js\",\n\t\t\t\t\t\t\t\tchunkFileNames: \"js/[name]-[hash].js\",\n\t\t\t\t\t\t\t\tassetFileNames(info: { names?: string[]; name?: string }) {\n\t\t\t\t\t\t\t\t\tconst name = info.names?.[0] ?? info.name ?? \"\";\n\t\t\t\t\t\t\t\t\tif (name.endsWith(\".css\")) return \"css/[name]-[hash].css\";\n\t\t\t\t\t\t\t\t\treturn \"assets/[name]-[hash][extname]\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t}\n\n\tif (generateMetaXmlOption !== false) {\n\t\tconst metaOpts = generateMetaXmlOption === true ? {} : generateMetaXmlOption;\n\t\t// Only register when a target is configured — without one the plugin has\n\t\t// nothing to contribute over a hand-authored meta XML, so registering it\n\t\t// would just add a no-op closeBundle hook. It resolves the project root\n\t\t// itself via Vite's configResolved (accurate in a monorepo, unlike cwd).\n\t\tif (metaOpts.target) {\n\t\t\tplugins.push(generateMetaXml(metaOpts));\n\t\t}\n\t}\n\n\tif (outputMode === \"single-file\") {\n\t\t// Loads vite-plugin-singlefile lazily (optional peer), scoped to `vite build`.\n\t\tplugins.push(\n\t\t\t...singleFilePlugins<Plugin>({\n\t\t\t\towner: \"@salesforce/vite-plugin-lwc-ui-bundle\",\n\t\t\t\toption: 'outputMode: \"single-file\"',\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn plugins;\n}\n"],"names":["builtinProviders.labelsGraphql","builtinProviders.platformGraphql","builtinProviders.apex","builtinProviders.client","builtinProviders.gate","builtinProviders.messageChannel","builtinProviders.messageService","builtinProviders.navigation","builtinProviders.primitiveUtils","builtinProviders.lds","require"],"mappings":";;;;;;;;;;;;;AASO,SAAS,gBAAgB,OAA+B,IAAwB;AACtF,QAAM,UAA8B,CAAA;AAEpC,aAAW,OAAO,MAAM;AACvB,UAAM,UAAU,OAAO,QAAQ,WAAW,MAAM,IAAI;AACpD,UAAM,YAAY,OAAO,QAAQ,WAAW,SAAY,IAAI;AAC5D,UAAM,cAAc,KAAK,QAAQ,OAAO;AAExC,QAAI,CAAC,WAAW,WAAW,KAAK,CAAC,SAAS,WAAW,EAAE,eAAe;AACrE;AAAA,IACD;AAEA,QAAI,WAAW;AAEd,iBAAW,QAAQ,YAAY,WAAW,GAAG;AAC5C,cAAM,WAAW,KAAK,KAAK,aAAa,IAAI;AAC5C,YAAI,CAAC,SAAS,QAAQ,EAAE,cAAe;AAEvC,cAAM,YAAY,KAAK,KAAK,UAAU,GAAG,IAAI,KAAK;AAClD,YAAI,WAAW,SAAS,GAAG;AAC1B,kBAAQ,KAAK;AAAA,YACZ,MAAM,GAAG,SAAS,IAAI,IAAI;AA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AA,cACd,QAAQ;AAAA,gBACP,gBAAgB;AAAA,gBAChB,gBAAgB;AAAA,gBAChB,eAAe,MAA2C;AACzD,wBAAM,OAAO,KAAK,QAAQ,CAAC,KAAK,KAAK,QAAQ;AAC7C,sBAAI,KAAK,SAAS,MAAM,EAAG,QAAO;AAClC,yBAAO;AAAA,gBACR;AAAA,cAAA;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MAEF;AAAA,IAAA,CACA;AAAA,EACF;AAEA,MAAI,0BAA0B,OAAO;AACpC,UAAM,WAAW,0BAA0B,OAAO,CAAA,IAAK;AAKvD,QAAI,SAAS,QAAQ;AACpB,cAAQ,KAAK,gBAAgB,QAAQ,CAAC;AAAA,IACvC;AAAA,EACD;AAEA,MAAI,eAAe,eAAe;AAEjC,YAAQ;AAAA,MACP,GAAG,kBAA0B;AAAA,QAC5B,OAAO;AAAA,QACP,QAAQ;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EAEH;AAEA,SAAO;AACR;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface PassthroughRule {
|
|
|
20
20
|
specifierPrefix: string;
|
|
21
21
|
importerPattern: string;
|
|
22
22
|
}
|
|
23
|
+
export type OutputMode = "bundled" | "unbundled" | "single-file";
|
|
23
24
|
export interface LwcVitePluginOptions {
|
|
24
25
|
modules?: ModuleConfig;
|
|
25
26
|
providers?: (Provider | Plugin)[];
|
|
@@ -27,6 +28,23 @@ export interface LwcVitePluginOptions {
|
|
|
27
28
|
lwcOptions?: Record<string, unknown>;
|
|
28
29
|
ignorePatterns?: string[];
|
|
29
30
|
passthroughRules?: PassthroughRule[];
|
|
31
|
+
/**
|
|
32
|
+
* Build output layout:
|
|
33
|
+
* - `"bundled"`: Vite's default output.
|
|
34
|
+
* - `"unbundled"`: multi-file web app output (`dist/index.html`, `dist/js/*.js`, `dist/css/*.css`).
|
|
35
|
+
* - `"single-file"`: inline JS, CSS and imported assets into a single self-contained
|
|
36
|
+
* `index.html` at build time (required for MCP apps). Requires vite >= 5.4.21 and
|
|
37
|
+
* `vite-plugin-singlefile` installed as a peer dependency. Files in `public/` are
|
|
38
|
+
* copied next to `index.html` rather than inlined, and the build warns listing them.
|
|
39
|
+
* Static `src` attributes in LWC templates aren't imported, so their assets are
|
|
40
|
+
* neither inlined nor detected; import the asset in JS to inline it. Output can be large.
|
|
41
|
+
* @default "bundled"
|
|
42
|
+
*/
|
|
43
|
+
outputMode?: OutputMode;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use `outputMode: "unbundled"` instead of `bundle: false`.
|
|
46
|
+
* Setting both `bundle` and `outputMode` throws.
|
|
47
|
+
*/
|
|
30
48
|
bundle?: boolean;
|
|
31
49
|
/**
|
|
32
50
|
* Write the bundle's `*.uibundle-meta.xml` at build time, deriving its
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;IAChC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,eAAe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ACrC;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,OAAO,GAAG,sBAAsB,CAAC;CACnD;AAED,MAAM,WAAW,sBAAsB;IACtC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,sBAAsB;IACtC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC"}
|
package/docs/consumer-guide.md
CHANGED
|
@@ -228,7 +228,6 @@ npm install lwc @salesforce-ux/design-system lightning-base-components
|
|
|
228
228
|
```js
|
|
229
229
|
import { defineConfig } from "vite";
|
|
230
230
|
import lwcVitePlugin, { builtins } from "@salesforce/vite-plugin-lwc-ui-bundle";
|
|
231
|
-
import { viteSingleFile } from "vite-plugin-singlefile";
|
|
232
231
|
|
|
233
232
|
export default defineConfig({
|
|
234
233
|
build: {
|
|
@@ -237,6 +236,8 @@ export default defineConfig({
|
|
|
237
236
|
},
|
|
238
237
|
plugins: [
|
|
239
238
|
lwcVitePlugin({
|
|
239
|
+
// Inline everything into a single index.html (required for MCP apps)
|
|
240
|
+
outputMode: "single-file",
|
|
240
241
|
modules: {
|
|
241
242
|
// Flat SFDX structure: specify { path, namespace }
|
|
242
243
|
dirs: [{ path: "force-app/main/default/lwc", namespace: "c" }],
|
|
@@ -252,7 +253,6 @@ export default defineConfig({
|
|
|
252
253
|
builtins.accessCheck(),
|
|
253
254
|
],
|
|
254
255
|
}),
|
|
255
|
-
viteSingleFile(),
|
|
256
256
|
],
|
|
257
257
|
});
|
|
258
258
|
```
|
package/docs/limitations.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
An LWC UI Bundle compiles your Lightning Web Components off-platform into a static
|
|
4
4
|
`dist/` — an `index.html` plus hashed `assets/*.js`/`*.css` by default, or a single
|
|
5
|
-
inlined `dist/index.html` if you
|
|
5
|
+
inlined `dist/index.html` if you set `outputMode: "single-file"`
|
|
6
6
|
(see [Consumer Guide → Off-Platform Build](consumer-guide.md#off-platform-build)). The
|
|
7
7
|
output runs anywhere with a DOM — an agentic MCP host (ChatGPT, MCP Apps), a plain
|
|
8
8
|
website, or a `*.salesforce.app`-served page. Because there is **no Lightning runtime**
|
package/docs/migration-guide.md
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
This guide walks you through porting a Lightning Web Component that runs **inside a
|
|
4
4
|
Salesforce org** to an **LWC UI Bundle** compiled off-platform with
|
|
5
5
|
`@salesforce/vite-plugin-lwc-ui-bundle`. The build emits a static `dist/` (an
|
|
6
|
-
`index.html
|
|
7
|
-
`vite-plugin-singlefile`) that runs in any browser, an MCP host, or a Salesforce UI
|
|
6
|
+
`index.html`, possibly with `assets/*`) that runs in any browser, an MCP host, or a Salesforce UI
|
|
8
7
|
Bundle served from the `*.salesforce.app` domain.
|
|
9
8
|
|
|
10
9
|
> **New to the plugin?** Read the [Consumer Guide](consumer-guide.md) first for the
|
|
@@ -290,7 +289,7 @@ If the build fails with `Rollup failed to resolve import "force/someModule"` (or
|
|
|
290
289
|
|
|
291
290
|
```bash
|
|
292
291
|
npm run build # → dist/ (index.html + assets/*, or a single dist/index.html
|
|
293
|
-
# if you
|
|
292
|
+
# if you set outputMode: "single-file")
|
|
294
293
|
open dist/index.html
|
|
295
294
|
|
|
296
295
|
npm run dev # dev server with live reload (+ lwcProxy for live data)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/vite-plugin-lwc-ui-bundle",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.18.0",
|
|
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",
|
|
@@ -74,11 +74,12 @@
|
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@lwc/rollup-plugin": "^9.0.0",
|
|
77
|
-
"@salesforce/platform-sdk": "^12.
|
|
77
|
+
"@salesforce/platform-sdk": "^12.18.0",
|
|
78
78
|
"@salesforce/state-managers-uiapi": "^0.31.0",
|
|
79
|
-
"@salesforce/ui-bundle": "^12.
|
|
79
|
+
"@salesforce/ui-bundle": "^12.18.0",
|
|
80
80
|
"lwc": "^9.0.0",
|
|
81
81
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
82
|
+
"vite-plugin-singlefile": "^2.3.4",
|
|
82
83
|
"zod": "^3.23.8"
|
|
83
84
|
},
|
|
84
85
|
"peerDependenciesMeta": {
|
|
@@ -87,6 +88,9 @@
|
|
|
87
88
|
},
|
|
88
89
|
"@salesforce/ui-bundle": {
|
|
89
90
|
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"vite-plugin-singlefile": {
|
|
93
|
+
"optional": true
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
96
|
"dependencies": {
|
|
@@ -100,11 +104,12 @@
|
|
|
100
104
|
"devDependencies": {
|
|
101
105
|
"@conduit-client/bindings-utils": "3.19.6",
|
|
102
106
|
"@conduit-client/command-base": "3.19.6",
|
|
103
|
-
"@salesforce/platform-sdk": "^12.
|
|
107
|
+
"@salesforce/platform-sdk": "^12.18.0",
|
|
104
108
|
"@types/ws": "^8.5.12",
|
|
105
109
|
"typescript": "^5.9.3",
|
|
106
110
|
"vite": "^7.3.5",
|
|
107
111
|
"vite-plugin-dts": "^4.5.4",
|
|
112
|
+
"vite-plugin-singlefile": "^2.3.4",
|
|
108
113
|
"vitest": "^4.1.11",
|
|
109
114
|
"ws": "^8.21.0",
|
|
110
115
|
"zod": "^3.23.8"
|
|
@@ -131,67 +131,9 @@ Starting from the root component, trace the dependency tree:
|
|
|
131
131
|
1. Read the root component's `.html` file — find all `c-*` tags (or other
|
|
132
132
|
namespace tags) to identify child components.
|
|
133
133
|
2. Recursively read each child component's `.js` and `.html`.
|
|
134
|
-
3. Collect all imports across the tree
|
|
135
|
-
-
|
|
136
|
-
-
|
|
137
|
-
support (provider + mock branch)
|
|
138
|
-
- `lightning/uiRecordApi` imported AND `@wire(getRecord` / `@wire(get*`
|
|
139
|
-
actually used → needs LDS support (provider + mock branch)
|
|
140
|
-
- `lightning/stateManagerRecord` imported (default `smRecord` import)
|
|
141
|
-
→ needs `builtins.lds()` provider (default registry covers it) +
|
|
142
|
-
the `getRecordMcpTool` `callTool` mock branch (same tool the
|
|
143
|
-
`@wire(getRecord)` path uses — one branch covers both). See
|
|
144
|
-
`known-pitfalls.md` for the no-auto-refire (no shared Luvio store)
|
|
145
|
-
reactivity contract.
|
|
146
|
-
- `lightning/stateManagerObjectInfo` imported (default `smObjectInfo`
|
|
147
|
-
import) → needs `builtins.lds()` provider + the
|
|
148
|
-
`getObjectInfoMcpTool` `callTool` mock branch.
|
|
149
|
-
- `lightning/stateManagerGraphQL` imported (default `smGraphQL`
|
|
150
|
-
import) → needs `builtins.lds()` provider + the `graphqlQuery`
|
|
151
|
-
`callTool` mock branch (same tool the `@wire(graphql)` path uses).
|
|
152
|
-
Note `smGraphQL` exposes `errors` (plural) on its outer shape,
|
|
153
|
-
matching its analogous wire adapter — distinct from UIAPI managers
|
|
154
|
-
which expose `error` (singular).
|
|
155
|
-
- `lightning/*` base components → needs `lightning-base-components`
|
|
156
|
-
npm package, plus `gate()`, `accessCheck()`, and `primitiveUtils()`
|
|
157
|
-
providers because base components use these modules internally even
|
|
158
|
-
if user code doesn't
|
|
159
|
-
- `@salesforce/gate/*`, `@salesforce/accessCheck/*` → handled by
|
|
160
|
-
those providers (accessCheck deny-defaults to `false`, no per-name
|
|
161
|
-
config required)
|
|
162
|
-
- `@salesforce/userPermission/<Name>`, `@salesforce/customPermission/<Name>`
|
|
163
|
-
→ **collect every `<Name>`.** These are named per-user permissions:
|
|
164
|
-
the default `platformGraphql()` provider **fails the build** unless
|
|
165
|
-
each imported name has a first-paint value declared in
|
|
166
|
-
`userPermissionDefaults` / `customPermissionDefaults`. Record the
|
|
167
|
-
exact names so Step 7 can generate them (default them to `false`
|
|
168
|
-
unless the user says otherwise). See `known-pitfalls.md#17`.
|
|
169
|
-
- `@salesforce/i18n/*` → `i18n` provider
|
|
170
|
-
- `@salesforce/client/*` → `client` provider (provides `formFactor`
|
|
171
|
-
based on viewport width)
|
|
172
|
-
- `lightning/primitiveUtils` → `primitiveUtils` provider
|
|
173
|
-
|
|
174
|
-
**Be precise with LDS detection.** The LDS provider/mock is only needed
|
|
175
|
-
when a component's `@wire` actually consumes `getRecord`/`getRecordUi`/
|
|
176
|
-
similar adapters from `lightning/uiRecordApi`, **or** when a component
|
|
177
|
-
imports a `lightning/stateManager*` default export and calls its
|
|
178
|
-
`setConfig` / setters. **Do not trigger the LDS provider just because:**
|
|
179
|
-
|
|
180
|
-
- The app has a chat wrapper whose tool output happens to contain a
|
|
181
|
-
record shape (`records[...]`) — that goes through
|
|
182
|
-
`window.openai.toolOutput` + the mapper, not the LDS wire adapter.
|
|
183
|
-
- A component imports `lightning/uiRecordApi` but doesn't `@wire` it.
|
|
184
|
-
- A component imports `lightning/stateManager*` but never instantiates
|
|
185
|
-
the state manager.
|
|
186
|
-
|
|
187
|
-
`builtins.lds()` wires up `@wire(getRecord)`, `@wire(graphql)`, **and**
|
|
188
|
-
the three `lightning/stateManager{Record,ObjectInfo,GraphQL}` virtual
|
|
189
|
-
modules — they all live in the same default registry. If no component
|
|
190
|
-
calls those wire adapters or instantiates a state manager, omit both
|
|
191
|
-
the provider and the corresponding mock branch (`getRecordMcpTool` /
|
|
192
|
-
`getObjectInfoMcpTool` / `graphqlQuery`). A chat wrapper that maps
|
|
193
|
-
`window.openai.toolOutput.records[...]` into a component's `@api`
|
|
194
|
-
props is independent of LDS.
|
|
134
|
+
3. Collect all imports across the tree. See
|
|
135
|
+
[references/component-tree-detection.md](references/component-tree-detection.md) for the full
|
|
136
|
+
import-to-provider detection rules and the LDS detection guidance — read it before reporting.
|
|
195
137
|
|
|
196
138
|
Report what you found — plainly, so the user can correct misdetections:
|
|
197
139
|
|
|
@@ -224,33 +166,18 @@ Check in this order:
|
|
|
224
166
|
`undefined` — labels, gates, access checks, i18n, client — even though
|
|
225
167
|
the build succeeds. See `references/known-pitfalls.md#11`.
|
|
226
168
|
|
|
227
|
-
2. **For each finding from Step 4, verify the matching provider is present
|
|
228
|
-
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
`@salesforce/customPermission/<Name>` → the default
|
|
240
|
-
`platformGraphql()` provider must declare a first-paint value for
|
|
241
|
-
**each** name in `userPermissionDefaults` / `customPermissionDefaults`,
|
|
242
|
-
or the build throws. Use the `defaultProviders({ platformGraphql: {…} })`
|
|
243
|
-
helper so the rest of the registry stays default. See
|
|
244
|
-
`references/known-pitfalls.md#17`.
|
|
245
|
-
- Step 4 found any `@salesforce/client/*` → `builtins.client()` must
|
|
246
|
-
be present
|
|
247
|
-
- `modules.npm` includes `lightning-base-components` (or
|
|
248
|
-
`lwc-components-lightning`) → `builtins.gate()`,
|
|
249
|
-
`builtins.accessCheck()`, `builtins.primitiveUtils()` must all be
|
|
250
|
-
present. Base components use these modules internally even if user
|
|
251
|
-
code doesn't.
|
|
252
|
-
|
|
253
|
-
3. **Report the gaps explicitly** before proceeding to later steps:
|
|
169
|
+
2. **For each finding from Step 4, verify the matching provider is present.** See
|
|
170
|
+
[references/provider-verification.md](references/provider-verification.md) for the finding-to-provider
|
|
171
|
+
checklist.
|
|
172
|
+
|
|
173
|
+
3. **Is single-file output set up by hand?** Look for `viteSingleFile()`
|
|
174
|
+
(imported from `vite-plugin-singlefile`) in the `plugins` array and for a
|
|
175
|
+
`vite-plugin-singlefile` entry in `package.json` `devDependencies`. Note
|
|
176
|
+
either for Step 7/8: the plugin's `outputMode: "single-file"` option replaces the
|
|
177
|
+
manual call, but the `vite-plugin-singlefile` devDependency must stay (it
|
|
178
|
+
is now a peer of the plugin).
|
|
179
|
+
|
|
180
|
+
4. **Report the gaps explicitly** before proceeding to later steps:
|
|
254
181
|
|
|
255
182
|
> "Your `vite.config.js` exists but its `providers` array is missing:
|
|
256
183
|
>
|
|
@@ -262,7 +189,7 @@ Check in this order:
|
|
|
262
189
|
> these missing, but wire adapters and labels will fail silently at
|
|
263
190
|
> runtime."
|
|
264
191
|
|
|
265
|
-
|
|
192
|
+
5. **If the existing `providers` array is complete**, say so and move on.
|
|
266
193
|
|
|
267
194
|
Do not skip this verification. A build that compiles fine but has no
|
|
268
195
|
providers registered is the single most common failure mode for projects
|
|
@@ -287,56 +214,9 @@ the bundle, so the guard short-circuits.
|
|
|
287
214
|
> for components that use LDS. Keep the workflow simple: mock locally,
|
|
288
215
|
> real host in ChatGPT.
|
|
289
216
|
|
|
290
|
-
Ask the user whether to generate mocks.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
- **`callTool` branches for wire adapters and state managers** — one
|
|
295
|
-
branch per tool actually detected in Step 4. State managers share
|
|
296
|
-
tool names with their sibling wire adapters, so one branch covers
|
|
297
|
-
both call paths:
|
|
298
|
-
- `graphqlQuery` — only if Step 4 found `@wire(graphql)` **or**
|
|
299
|
-
`lightning/stateManagerGraphQL` (default `smGraphQL`) usage. Not
|
|
300
|
-
needed otherwise.
|
|
301
|
-
- `getRecordMcpTool` — only if Step 4 found `@wire(getRecord)` **or**
|
|
302
|
-
`lightning/stateManagerRecord` (default `smRecord`) usage. Not
|
|
303
|
-
needed just because a chat wrapper passes record-shaped data;
|
|
304
|
-
the wrapper reads `toolOutput`, not `callTool`.
|
|
305
|
-
- `getObjectInfoMcpTool` — only if Step 4 found
|
|
306
|
-
`lightning/stateManagerObjectInfo` (default `smObjectInfo`) usage,
|
|
307
|
-
or a future `getObjectInfo` imperative-read consumer.
|
|
308
|
-
- **Seed `window.openai.toolOutput`** — only if Step 2 generated a
|
|
309
|
-
chat wrapper. This is what drives the wrapper's initial render; the
|
|
310
|
-
mapper consumes it. It has nothing to do with `callTool`.
|
|
311
|
-
|
|
312
|
-
Build the question by combining whichever applies. For example, a
|
|
313
|
-
project with graphql only:
|
|
314
|
-
|
|
315
|
-
> "For local dev (`npm run dev`) I can add mocks in `bootstrap.js`. The
|
|
316
|
-
> shim only activates when no host bridge is present, so the same
|
|
317
|
-
> compiled bundle runs inside ChatGPT unchanged.
|
|
318
|
-
>
|
|
319
|
-
> Based on Step 4, the mock will need:
|
|
320
|
-
>
|
|
321
|
-
> - `callTool` branch for `graphqlQuery`
|
|
322
|
-
>
|
|
323
|
-
> A) Yes — generate mocks with sample data I'll describe
|
|
324
|
-
> B) No — skip mocks
|
|
325
|
-
>
|
|
326
|
-
> If B, `@wire(graphql)` will return no data under `npm run dev`, but
|
|
327
|
-
> the bundle will still render correctly when deployed to a real MCP
|
|
328
|
-
> server as a UI resource — the host provides a real `window.openai`
|
|
329
|
-
> there."
|
|
330
|
-
|
|
331
|
-
For a project with a chat wrapper **and** `@wire(graphql)`, include
|
|
332
|
-
both the `callTool` branch and the `toolOutput` seed, but keep them
|
|
333
|
-
as distinct items in the list:
|
|
334
|
-
|
|
335
|
-
> Based on Step 2 / Step 4, the mocks will include:
|
|
336
|
-
>
|
|
337
|
-
> - `callTool` branch for `graphqlQuery` (for the `@wire(graphql)` call)
|
|
338
|
-
> - Seed for `window.openai.toolOutput` (drives the
|
|
339
|
-
> `<bcx-record-detail-chat-wrapper>` initial render)
|
|
217
|
+
Ask the user whether to generate mocks. See
|
|
218
|
+
[references/mock-questions.md](references/mock-questions.md) for the mock list (build it from what
|
|
219
|
+
Step 4 / Step 2 found) and the question templates.
|
|
340
220
|
|
|
341
221
|
### Step 6: Resolve label values
|
|
342
222
|
|
|
@@ -394,11 +274,15 @@ Merge in dependencies and scripts. Don't overwrite existing.
|
|
|
394
274
|
- `lightning-base-components` (if used)
|
|
395
275
|
- `@salesforce-ux/design-system` (if used)
|
|
396
276
|
- `vite`
|
|
397
|
-
- `vite-plugin-singlefile`
|
|
277
|
+
- `vite-plugin-singlefile` (when using `outputMode: "single-file"`)
|
|
398
278
|
|
|
399
279
|
If a registry lookup fails (offline / auth issue), ask the user for
|
|
400
280
|
the version rather than falling back to the stale snippet.
|
|
401
281
|
|
|
282
|
+
- When switching to `outputMode: "single-file"`, keep `vite-plugin-singlefile` as a
|
|
283
|
+
devDependency (it is an optional peer of the plugin) and drop the manual
|
|
284
|
+
`viteSingleFile()` call (and its import) from `vite.config.js`.
|
|
285
|
+
|
|
402
286
|
#### `vite.config.js`
|
|
403
287
|
|
|
404
288
|
See "Step 2" in the consumer guide for the template.
|
|
@@ -412,69 +296,8 @@ adapter, `normalizeMcpResponse` envelope parsing, LDS wire/read/mutation
|
|
|
412
296
|
adapters, and more. Hand-rolling any of them bypasses all that and
|
|
413
297
|
breaks host integration (see `references/known-pitfalls.md#3`).
|
|
414
298
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
// inside plugins -> lwcVitePlugin({ providers: [...] })
|
|
419
|
-
builtins.lds(), // default registry:
|
|
420
|
-
// lightning/uiRecordApi, uiObjectInfoApi,
|
|
421
|
-
// lightning/graphql (tool: "graphqlQuery"),
|
|
422
|
-
// lightning/stateManagerRecord -> getRecordMcpTool
|
|
423
|
-
// lightning/stateManagerObjectInfo -> getObjectInfoMcpTool
|
|
424
|
-
// lightning/stateManagerGraphQL -> graphqlQuery
|
|
425
|
-
|
|
426
|
-
// Add to / override the default registry. The argument is deep-merged onto
|
|
427
|
-
// the defaults per specifier, so you only declare what you are changing —
|
|
428
|
-
// unmentioned entries (e.g. `getRecord`, `createRecord`, the three
|
|
429
|
-
// `lightning/stateManager*` defaults) are preserved.
|
|
430
|
-
builtins.lds({
|
|
431
|
-
"lightning/graphql": {
|
|
432
|
-
graphql: { type: "graphql-wire", mcp: { toolName: "myGraphqlTool" } },
|
|
433
|
-
executeMutation: { type: "graphql-mutation", mcp: { toolName: "myGraphqlTool" } },
|
|
434
|
-
},
|
|
435
|
-
}),
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
**Registering or overriding a state manager** — the
|
|
439
|
-
`LdsStateManagerConfig` discriminator (`type: 'state-manager'`)
|
|
440
|
-
points the load hook at an upstream per-state-manager **factory**.
|
|
441
|
-
Composition (the externalized state manager and all its per-manager
|
|
442
|
-
metadata — `definedBy`, `requiredKeys`, `optionalKeys`, predicate)
|
|
443
|
-
lives in the upstream factory; the registry entry only carries the
|
|
444
|
-
factory specifier (`factoryModule` + `factoryName`), the MCP tool name,
|
|
445
|
-
and the JSON schema for `setConfig` validation:
|
|
446
|
-
|
|
447
|
-
```js
|
|
448
|
-
builtins.lds({
|
|
449
|
-
"lightning/stateManagerRecord": {
|
|
450
|
-
default: {
|
|
451
|
-
type: "state-manager",
|
|
452
|
-
factoryModule: "@salesforce/state-managers-uiapi/factory",
|
|
453
|
-
factoryName: "createSmRecord",
|
|
454
|
-
mcp: { toolName: "getRecordMcpTool" },
|
|
455
|
-
configJsonSchema: {
|
|
456
|
-
/* same RECORD_SCHEMA used by getRecord wire entry */
|
|
457
|
-
},
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
}),
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
The three default entries are:
|
|
464
|
-
|
|
465
|
-
| Specifier | `factoryModule` | `factoryName` | Default `mcp.toolName` |
|
|
466
|
-
| ---------------------------------- | ------------------------------------------ | -------------------- | ---------------------- |
|
|
467
|
-
| `lightning/stateManagerRecord` | `@salesforce/state-managers-uiapi/factory` | `createSmRecord` | `getRecordMcpTool` |
|
|
468
|
-
| `lightning/stateManagerObjectInfo` | `@salesforce/state-managers-uiapi/factory` | `createSmObjectInfo` | `getObjectInfoMcpTool` |
|
|
469
|
-
| `lightning/stateManagerGraphQL` | `@salesforce/state-managers-uiapi/factory` | `createSmGraphQL` | `graphqlQuery` |
|
|
470
|
-
|
|
471
|
-
State-manager entries do **not** carry `definedBy`, `requiredKeys`,
|
|
472
|
-
`optionalKeys`, or any predicate — those live in the upstream factory
|
|
473
|
-
and reach off-core verbatim through the externalized state manager.
|
|
474
|
-
Within an adapter entry, the override is a **wholesale replacement,
|
|
475
|
-
not a deep merge**, so when you redeclare the `default` adapter you
|
|
476
|
-
must repeat every field you want to keep (including `factoryModule` /
|
|
477
|
-
`factoryName`).
|
|
299
|
+
See [references/vite-config-providers.md](references/vite-config-providers.md) for the `builtins.lds()`
|
|
300
|
+
default registry, how to add or override entries, and how to register a state manager.
|
|
478
301
|
|
|
479
302
|
Adapt based on earlier findings:
|
|
480
303
|
|
|
@@ -510,32 +333,13 @@ Adapt based on earlier findings:
|
|
|
510
333
|
- Include `builtins.lds()` if any component uses `lightning/uiRecordApi`,
|
|
511
334
|
`lightning/uiObjectInfoApi`, `lightning/graphql`, or any of the
|
|
512
335
|
`lightning/stateManager{Record,ObjectInfo,GraphQL}` specifiers.
|
|
513
|
-
-
|
|
514
|
-
|
|
515
|
-
`known-pitfalls.md#6` for the full config block.
|
|
336
|
+
- Set `outputMode: "single-file"` on `lwcVitePlugin`. Without it, `vite build` emits multi-file output and the MCP host can't inline the bundle.
|
|
337
|
+
Note `public/` files are not inlined (build warns). See `known-pitfalls.md#6` for details.
|
|
516
338
|
- Remove `npm: ["lightning-base-components"]` if no base components used.
|
|
517
339
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
`getRecordMcpTool`. Override via
|
|
522
|
-
`builtins.lds({ "lightning/uiRecordApi": { getRecord: { type: "wire", mcp: { toolName: "..." } } } })`.
|
|
523
|
-
- `builtins.lds()` default for `lightning/graphql` (both `graphql` wire
|
|
524
|
-
and `executeMutation`): `graphqlQuery`. Override by registering the
|
|
525
|
-
specifier explicitly — see example above.
|
|
526
|
-
- `builtins.lds()` default for `lightning/stateManagerRecord`:
|
|
527
|
-
`getRecordMcpTool` (shared with the `getRecord` wire entry — one
|
|
528
|
-
mock branch covers both).
|
|
529
|
-
- `builtins.lds()` default for `lightning/stateManagerObjectInfo`:
|
|
530
|
-
`getObjectInfoMcpTool`.
|
|
531
|
-
- `builtins.lds()` default for `lightning/stateManagerGraphQL`:
|
|
532
|
-
`graphqlQuery` (shared with the `graphql` wire entry).
|
|
533
|
-
|
|
534
|
-
Whatever tool names you settle on here **must match** the branches in
|
|
535
|
-
`bootstrap.js` mocks (Step 8). For state-manager consumers, also note
|
|
536
|
-
that `smGraphQL`'s outer shape exposes `errors` (plural), matching its
|
|
537
|
-
sibling wire adapter — UIAPI managers (`smRecord`, `smObjectInfo`)
|
|
538
|
-
expose `error` (singular).
|
|
340
|
+
See [references/vite-config-providers.md](references/vite-config-providers.md#tool-names) for the canonical
|
|
341
|
+
list of `builtins.lds()` default tool names. Whatever tool names you settle on **must match** the
|
|
342
|
+
branches in `bootstrap.js` mocks (Step 8).
|
|
539
343
|
|
|
540
344
|
#### `index.html`
|
|
541
345
|
|
|
@@ -601,54 +405,8 @@ Run this check **only** if Step 4 found actual usage of any of:
|
|
|
601
405
|
If none of the above are in the component tree, skip this sub-step
|
|
602
406
|
entirely — the LDS runtime is never loaded and the peers don't matter.
|
|
603
407
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
Depending on the plugin version, these may ship as the plugin's own
|
|
607
|
-
`dependencies`/`optionalDependencies`, or may be left undeclared (as of
|
|
608
|
-
`@salesforce/vite-plugin-lwc-ui-bundle@1.135.0`). The skill does not
|
|
609
|
-
need to know which — it just verifies they are resolvable in the
|
|
610
|
-
consumer's `node_modules` after install, regardless of how they got
|
|
611
|
-
there.
|
|
612
|
-
|
|
613
|
-
**Check:**
|
|
614
|
-
|
|
615
|
-
```bash
|
|
616
|
-
node -e "
|
|
617
|
-
const peers = [
|
|
618
|
-
'@conduit-client/service-bindings-imperative',
|
|
619
|
-
'@conduit-client/service-bindings-lwc',
|
|
620
|
-
'@conduit-client/utils'
|
|
621
|
-
];
|
|
622
|
-
const missing = peers.filter(p => {
|
|
623
|
-
try { require.resolve(p); return false; }
|
|
624
|
-
catch { return true; }
|
|
625
|
-
});
|
|
626
|
-
if (missing.length) {
|
|
627
|
-
console.error('Missing LDS runtime peers:', missing.join(', '));
|
|
628
|
-
process.exit(1);
|
|
629
|
-
} else {
|
|
630
|
-
console.log('LDS runtime peers OK');
|
|
631
|
-
}
|
|
632
|
-
"
|
|
633
|
-
```
|
|
634
|
-
|
|
635
|
-
**If any are missing**, install the set as consumer `dependencies` (not
|
|
636
|
-
`@salesforce/ui-bundle` — that package does not pull these three
|
|
637
|
-
transitively and installing it does not resolve the error):
|
|
638
|
-
|
|
639
|
-
```bash
|
|
640
|
-
npm install --save \
|
|
641
|
-
@conduit-client/service-bindings-imperative@^3 \
|
|
642
|
-
@conduit-client/service-bindings-lwc@^3 \
|
|
643
|
-
@conduit-client/utils@^3
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
Re-run the check. See `references/known-pitfalls.md#13` for the full
|
|
647
|
-
background.
|
|
648
|
-
|
|
649
|
-
**If all three are already present** (e.g., a future plugin version
|
|
650
|
-
ships them as its own deps, or a sibling package already pulled them
|
|
651
|
-
in), do nothing — no lockfile churn, no duplicate entries.
|
|
408
|
+
See [references/lds-runtime-peers.md](references/lds-runtime-peers.md) for why this check exists, the
|
|
409
|
+
check script, and the install command when peers are missing.
|
|
652
410
|
|
|
653
411
|
#### Step 8.2: Build
|
|
654
412
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Component tree detection rules
|
|
2
|
+
|
|
3
|
+
3. Collect all imports across the tree:
|
|
4
|
+
- `@salesforce/label/*` → label keys (need `builtins.label()`)
|
|
5
|
+
- `lightning/graphql` AND `@wire(graphql` present → needs GraphQL
|
|
6
|
+
support (provider + mock branch)
|
|
7
|
+
- `lightning/uiRecordApi` imported AND `@wire(getRecord` / `@wire(get*`
|
|
8
|
+
actually used → needs LDS support (provider + mock branch)
|
|
9
|
+
- `lightning/stateManagerRecord` imported (default `smRecord` import)
|
|
10
|
+
→ needs `builtins.lds()` provider (default registry covers it) +
|
|
11
|
+
the `getRecordMcpTool` `callTool` mock branch (same tool the
|
|
12
|
+
`@wire(getRecord)` path uses — one branch covers both). See
|
|
13
|
+
`known-pitfalls.md` for the no-auto-refire (no shared Luvio store)
|
|
14
|
+
reactivity contract.
|
|
15
|
+
- `lightning/stateManagerObjectInfo` imported (default `smObjectInfo`
|
|
16
|
+
import) → needs `builtins.lds()` provider + the
|
|
17
|
+
`getObjectInfoMcpTool` `callTool` mock branch.
|
|
18
|
+
- `lightning/stateManagerGraphQL` imported (default `smGraphQL`
|
|
19
|
+
import) → needs `builtins.lds()` provider + the `graphqlQuery`
|
|
20
|
+
`callTool` mock branch (same tool the `@wire(graphql)` path uses).
|
|
21
|
+
Note `smGraphQL` exposes `errors` (plural) on its outer shape,
|
|
22
|
+
matching its analogous wire adapter — distinct from UIAPI managers
|
|
23
|
+
which expose `error` (singular).
|
|
24
|
+
- `lightning/*` base components → needs `lightning-base-components`
|
|
25
|
+
npm package, plus `gate()`, `accessCheck()`, and `primitiveUtils()`
|
|
26
|
+
providers because base components use these modules internally even
|
|
27
|
+
if user code doesn't
|
|
28
|
+
- `@salesforce/gate/*`, `@salesforce/accessCheck/*` → handled by
|
|
29
|
+
those providers (accessCheck deny-defaults to `false`, no per-name
|
|
30
|
+
config required)
|
|
31
|
+
- `@salesforce/userPermission/<Name>`, `@salesforce/customPermission/<Name>`
|
|
32
|
+
→ **collect every `<Name>`.** These are named per-user permissions:
|
|
33
|
+
the default `platformGraphql()` provider **fails the build** unless
|
|
34
|
+
each imported name has a first-paint value declared in
|
|
35
|
+
`userPermissionDefaults` / `customPermissionDefaults`. Record the
|
|
36
|
+
exact names so Step 7 can generate them (default them to `false`
|
|
37
|
+
unless the user says otherwise). See `known-pitfalls.md#17`.
|
|
38
|
+
- `@salesforce/i18n/*` → `i18n` provider
|
|
39
|
+
- `@salesforce/client/*` → `client` provider (provides `formFactor`
|
|
40
|
+
based on viewport width)
|
|
41
|
+
- `lightning/primitiveUtils` → `primitiveUtils` provider
|
|
42
|
+
|
|
43
|
+
**Be precise with LDS detection.** The LDS provider/mock is only needed
|
|
44
|
+
when a component's `@wire` actually consumes `getRecord`/`getRecordUi`/
|
|
45
|
+
similar adapters from `lightning/uiRecordApi`, **or** when a component
|
|
46
|
+
imports a `lightning/stateManager*` default export and calls its
|
|
47
|
+
`setConfig` / setters. **Do not trigger the LDS provider just because:**
|
|
48
|
+
|
|
49
|
+
- The app has a chat wrapper whose tool output happens to contain a
|
|
50
|
+
record shape (`records[...]`) — that goes through
|
|
51
|
+
`window.openai.toolOutput` + the mapper, not the LDS wire adapter.
|
|
52
|
+
- A component imports `lightning/uiRecordApi` but doesn't `@wire` it.
|
|
53
|
+
- A component imports `lightning/stateManager*` but never instantiates
|
|
54
|
+
the state manager.
|
|
55
|
+
|
|
56
|
+
`builtins.lds()` wires up `@wire(getRecord)`, `@wire(graphql)`, **and**
|
|
57
|
+
the three `lightning/stateManager{Record,ObjectInfo,GraphQL}` virtual
|
|
58
|
+
modules — they all live in the same default registry. If no component
|
|
59
|
+
calls those wire adapters or instantiates a state manager, omit both
|
|
60
|
+
the provider and the corresponding mock branch (`getRecordMcpTool` /
|
|
61
|
+
`getObjectInfoMcpTool` / `graphqlQuery`). A chat wrapper that maps
|
|
62
|
+
`window.openai.toolOutput.records[...]` into a component's `@api`
|
|
63
|
+
props is independent of LDS.
|
|
@@ -111,31 +111,30 @@ function unwrapPropertiesMap(value) {
|
|
|
111
111
|
|
|
112
112
|
Apply this in every mapper that reads map-shaped fields.
|
|
113
113
|
|
|
114
|
-
## 6. Missing `
|
|
114
|
+
## 6. Missing `outputMode: "single-file"`
|
|
115
115
|
|
|
116
116
|
**Symptom:** `dist/index.html` is 1-2 KB (just a stub); component
|
|
117
117
|
doesn't render when opened locally.
|
|
118
118
|
|
|
119
|
-
**Cause:** `
|
|
119
|
+
**Cause:** `outputMode` is not `"single-file"` (it defaults to `"bundled"`), so
|
|
120
120
|
Vite emits its default multi-file output (HTML stub + separate
|
|
121
121
|
`assets/*.js` + `assets/*.css`).
|
|
122
122
|
|
|
123
|
-
**Fix:**
|
|
123
|
+
**Fix:** Enable it for the plugin in `vite.config.js` and install the required peer dependency with
|
|
124
|
+
`npm install -D vite-plugin-singlefile` (vite >= 5.4.21).
|
|
124
125
|
|
|
125
126
|
```js
|
|
126
|
-
import { viteSingleFile } from "vite-plugin-singlefile";
|
|
127
|
-
// ...
|
|
128
127
|
plugins: [
|
|
129
|
-
lwcVitePlugin({ /* ... */ }),
|
|
130
|
-
viteSingleFile(),
|
|
128
|
+
lwcVitePlugin({ outputMode: "single-file", /* ... */ }),
|
|
131
129
|
],
|
|
132
130
|
build: {
|
|
133
131
|
target: "esnext",
|
|
134
|
-
cssCodeSplit: false,
|
|
135
|
-
rollupOptions: { output: { inlineDynamicImports: true } },
|
|
136
132
|
},
|
|
137
133
|
```
|
|
138
134
|
|
|
135
|
+
Files in `public/` are not inlined; they are emitted separately and the build
|
|
136
|
+
warns.
|
|
137
|
+
|
|
139
138
|
A correctly built `dist/index.html` is typically 100 KB+.
|
|
140
139
|
|
|
141
140
|
## 7. `@salesforce/label/...` warnings
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Verify LDS runtime peers
|
|
2
|
+
|
|
3
|
+
**Why this check exists:** the plugin's `dist/providers/lds/runtime.js`
|
|
4
|
+
statically imports three `@conduit-client/*` packages at build time.
|
|
5
|
+
Depending on the plugin version, these may ship as the plugin's own
|
|
6
|
+
`dependencies`/`optionalDependencies`, or may be left undeclared (as of
|
|
7
|
+
`@salesforce/vite-plugin-lwc-ui-bundle@1.135.0`). The skill does not
|
|
8
|
+
need to know which — it just verifies they are resolvable in the
|
|
9
|
+
consumer's `node_modules` after install, regardless of how they got
|
|
10
|
+
there.
|
|
11
|
+
|
|
12
|
+
**Check:**
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node -e "
|
|
16
|
+
const peers = [
|
|
17
|
+
'@conduit-client/service-bindings-imperative',
|
|
18
|
+
'@conduit-client/service-bindings-lwc',
|
|
19
|
+
'@conduit-client/utils'
|
|
20
|
+
];
|
|
21
|
+
const missing = peers.filter(p => {
|
|
22
|
+
try { require.resolve(p); return false; }
|
|
23
|
+
catch { return true; }
|
|
24
|
+
});
|
|
25
|
+
if (missing.length) {
|
|
26
|
+
console.error('Missing LDS runtime peers:', missing.join(', '));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
} else {
|
|
29
|
+
console.log('LDS runtime peers OK');
|
|
30
|
+
}
|
|
31
|
+
"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**If any are missing**, install the set as consumer `dependencies` (not
|
|
35
|
+
`@salesforce/ui-bundle` — that package does not pull these three
|
|
36
|
+
transitively and installing it does not resolve the error):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install --save \
|
|
40
|
+
@conduit-client/service-bindings-imperative@^3 \
|
|
41
|
+
@conduit-client/service-bindings-lwc@^3 \
|
|
42
|
+
@conduit-client/utils@^3
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Re-run the check. See `references/known-pitfalls.md#13` for the full
|
|
46
|
+
background.
|
|
47
|
+
|
|
48
|
+
**If all three are already present** (e.g., a future plugin version
|
|
49
|
+
ships them as its own deps, or a sibling package already pulled them
|
|
50
|
+
in), do nothing — no lockfile churn, no duplicate entries.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Mock questions for local dev
|
|
2
|
+
|
|
3
|
+
Ask the user whether to generate mocks. Mocks serve two independent
|
|
4
|
+
purposes — list each one **only if Step 4 / Step 2 produced something
|
|
5
|
+
to mock**, and skip lines that don't apply:
|
|
6
|
+
|
|
7
|
+
- **`callTool` branches for wire adapters and state managers** — one
|
|
8
|
+
branch per tool actually detected in Step 4. State managers share
|
|
9
|
+
tool names with their sibling wire adapters, so one branch covers
|
|
10
|
+
both call paths:
|
|
11
|
+
- `graphqlQuery` — only if Step 4 found `@wire(graphql)` **or**
|
|
12
|
+
`lightning/stateManagerGraphQL` (default `smGraphQL`) usage. Not
|
|
13
|
+
needed otherwise.
|
|
14
|
+
- `getRecordMcpTool` — only if Step 4 found `@wire(getRecord)` **or**
|
|
15
|
+
`lightning/stateManagerRecord` (default `smRecord`) usage. Not
|
|
16
|
+
needed just because a chat wrapper passes record-shaped data;
|
|
17
|
+
the wrapper reads `toolOutput`, not `callTool`.
|
|
18
|
+
- `getObjectInfoMcpTool` — only if Step 4 found
|
|
19
|
+
`lightning/stateManagerObjectInfo` (default `smObjectInfo`) usage,
|
|
20
|
+
or a future `getObjectInfo` imperative-read consumer.
|
|
21
|
+
- **Seed `window.openai.toolOutput`** — only if Step 2 generated a
|
|
22
|
+
chat wrapper. This is what drives the wrapper's initial render; the
|
|
23
|
+
mapper consumes it. It has nothing to do with `callTool`.
|
|
24
|
+
|
|
25
|
+
Build the question by combining whichever applies. For example, a
|
|
26
|
+
project with graphql only:
|
|
27
|
+
|
|
28
|
+
> "For local dev (`npm run dev`) I can add mocks in `bootstrap.js`. The
|
|
29
|
+
> shim only activates when no host bridge is present, so the same
|
|
30
|
+
> compiled bundle runs inside ChatGPT unchanged.
|
|
31
|
+
>
|
|
32
|
+
> Based on Step 4, the mock will need:
|
|
33
|
+
>
|
|
34
|
+
> - `callTool` branch for `graphqlQuery`
|
|
35
|
+
>
|
|
36
|
+
> A) Yes — generate mocks with sample data I'll describe
|
|
37
|
+
> B) No — skip mocks
|
|
38
|
+
>
|
|
39
|
+
> If B, `@wire(graphql)` will return no data under `npm run dev`, but
|
|
40
|
+
> the bundle will still render correctly when deployed to a real MCP
|
|
41
|
+
> server as a UI resource — the host provides a real `window.openai`
|
|
42
|
+
> there."
|
|
43
|
+
|
|
44
|
+
For a project with a chat wrapper **and** `@wire(graphql)`, include
|
|
45
|
+
both the `callTool` branch and the `toolOutput` seed, but keep them
|
|
46
|
+
as distinct items in the list:
|
|
47
|
+
|
|
48
|
+
> Based on Step 2 / Step 4, the mocks will include:
|
|
49
|
+
>
|
|
50
|
+
> - `callTool` branch for `graphqlQuery` (for the `@wire(graphql)` call)
|
|
51
|
+
> - Seed for `window.openai.toolOutput` (drives the
|
|
52
|
+
> `<bcx-record-detail-chat-wrapper>` initial render)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Provider verification checklist
|
|
2
|
+
|
|
3
|
+
2. **For each finding from Step 4, verify the matching provider is present:**
|
|
4
|
+
- Step 4 found `@salesforce/label/*` usage → `builtins.label({...})` must be in `providers`
|
|
5
|
+
- Step 4 found `@wire(graphql)`, `executeMutation`, or any `lightning/graphql` import →
|
|
6
|
+
`builtins.lds()` must be present (graphql specifiers are in the default registry)
|
|
7
|
+
- Step 4 found `@wire(getRecord)` from `lightning/uiRecordApi` →
|
|
8
|
+
`builtins.lds()` must be present (one `builtins.lds()` covers both)
|
|
9
|
+
- Step 4 found any `lightning/stateManager{Record,ObjectInfo,GraphQL}`
|
|
10
|
+
import that's actually instantiated → `builtins.lds()` must be
|
|
11
|
+
present (the default registry covers all three specifiers)
|
|
12
|
+
- Step 4 found any `@salesforce/i18n/*` → `builtins.i18n()` must be
|
|
13
|
+
present
|
|
14
|
+
- Step 4 found any `@salesforce/userPermission/<Name>` or
|
|
15
|
+
`@salesforce/customPermission/<Name>` → the default
|
|
16
|
+
`platformGraphql()` provider must declare a first-paint value for
|
|
17
|
+
**each** name in `userPermissionDefaults` / `customPermissionDefaults`,
|
|
18
|
+
or the build throws. Use the `defaultProviders({ platformGraphql: {…} })`
|
|
19
|
+
helper so the rest of the registry stays default. See
|
|
20
|
+
`references/known-pitfalls.md#17`.
|
|
21
|
+
- Step 4 found any `@salesforce/client/*` → `builtins.client()` must
|
|
22
|
+
be present
|
|
23
|
+
- `modules.npm` includes `lightning-base-components` (or
|
|
24
|
+
`lwc-components-lightning`) → `builtins.gate()`,
|
|
25
|
+
`builtins.accessCheck()`, `builtins.primitiveUtils()` must all be
|
|
26
|
+
present. Base components use these modules internally even if user
|
|
27
|
+
code doesn't.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# vite.config.js provider details
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
import lwcVitePlugin, { builtins } from "@salesforce/vite-plugin-lwc-ui-bundle";
|
|
5
|
+
|
|
6
|
+
// inside plugins -> lwcVitePlugin({ providers: [...] })
|
|
7
|
+
builtins.lds(), // default registry:
|
|
8
|
+
// lightning/uiRecordApi, uiObjectInfoApi,
|
|
9
|
+
// lightning/graphql (tool: "graphqlQuery"),
|
|
10
|
+
// lightning/stateManagerRecord -> getRecordMcpTool
|
|
11
|
+
// lightning/stateManagerObjectInfo -> getObjectInfoMcpTool
|
|
12
|
+
// lightning/stateManagerGraphQL -> graphqlQuery
|
|
13
|
+
|
|
14
|
+
// Add to / override the default registry. The argument is deep-merged onto
|
|
15
|
+
// the defaults per specifier, so you only declare what you are changing —
|
|
16
|
+
// unmentioned entries (e.g. `getRecord`, `createRecord`, the three
|
|
17
|
+
// `lightning/stateManager*` defaults) are preserved.
|
|
18
|
+
builtins.lds({
|
|
19
|
+
"lightning/graphql": {
|
|
20
|
+
graphql: { type: "graphql-wire", mcp: { toolName: "myGraphqlTool" } },
|
|
21
|
+
executeMutation: { type: "graphql-mutation", mcp: { toolName: "myGraphqlTool" } },
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Registering or overriding a state manager** — the
|
|
27
|
+
`LdsStateManagerConfig` discriminator (`type: 'state-manager'`)
|
|
28
|
+
points the load hook at an upstream per-state-manager **factory**.
|
|
29
|
+
Composition (the externalized state manager and all its per-manager
|
|
30
|
+
metadata — `definedBy`, `requiredKeys`, `optionalKeys`, predicate)
|
|
31
|
+
lives in the upstream factory; the registry entry only carries the
|
|
32
|
+
factory specifier (`factoryModule` + `factoryName`), the MCP tool name,
|
|
33
|
+
and the JSON schema for `setConfig` validation:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
builtins.lds({
|
|
37
|
+
"lightning/stateManagerRecord": {
|
|
38
|
+
default: {
|
|
39
|
+
type: "state-manager",
|
|
40
|
+
factoryModule: "@salesforce/state-managers-uiapi/factory",
|
|
41
|
+
factoryName: "createSmRecord",
|
|
42
|
+
mcp: { toolName: "getRecordMcpTool" },
|
|
43
|
+
configJsonSchema: {
|
|
44
|
+
/* same RECORD_SCHEMA used by getRecord wire entry */
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The three default entries are:
|
|
52
|
+
|
|
53
|
+
| Specifier | `factoryModule` | `factoryName` | Default `mcp.toolName` |
|
|
54
|
+
| ---------------------------------- | ------------------------------------------ | -------------------- | ---------------------- |
|
|
55
|
+
| `lightning/stateManagerRecord` | `@salesforce/state-managers-uiapi/factory` | `createSmRecord` | `getRecordMcpTool` |
|
|
56
|
+
| `lightning/stateManagerObjectInfo` | `@salesforce/state-managers-uiapi/factory` | `createSmObjectInfo` | `getObjectInfoMcpTool` |
|
|
57
|
+
| `lightning/stateManagerGraphQL` | `@salesforce/state-managers-uiapi/factory` | `createSmGraphQL` | `graphqlQuery` |
|
|
58
|
+
|
|
59
|
+
State-manager entries do **not** carry `definedBy`, `requiredKeys`,
|
|
60
|
+
`optionalKeys`, or any predicate — those live in the upstream factory
|
|
61
|
+
and reach off-core verbatim through the externalized state manager.
|
|
62
|
+
Within an adapter entry, the override is a **wholesale replacement,
|
|
63
|
+
not a deep merge**, so when you redeclare the `default` adapter you
|
|
64
|
+
must repeat every field you want to keep (including `factoryModule` /
|
|
65
|
+
`factoryName`).
|
|
66
|
+
|
|
67
|
+
## Tool names
|
|
68
|
+
|
|
69
|
+
**Tool names** (canonical list — referenced elsewhere):
|
|
70
|
+
|
|
71
|
+
- `builtins.lds()` default for `lightning/uiRecordApi.getRecord`:
|
|
72
|
+
`getRecordMcpTool`. Override via
|
|
73
|
+
`builtins.lds({ "lightning/uiRecordApi": { getRecord: { type: "wire", mcp: { toolName: "..." } } } })`.
|
|
74
|
+
- `builtins.lds()` default for `lightning/graphql` (both `graphql` wire
|
|
75
|
+
and `executeMutation`): `graphqlQuery`. Override by registering the
|
|
76
|
+
specifier explicitly — see example above.
|
|
77
|
+
- `builtins.lds()` default for `lightning/stateManagerRecord`:
|
|
78
|
+
`getRecordMcpTool` (shared with the `getRecord` wire entry — one
|
|
79
|
+
mock branch covers both).
|
|
80
|
+
- `builtins.lds()` default for `lightning/stateManagerObjectInfo`:
|
|
81
|
+
`getObjectInfoMcpTool`.
|
|
82
|
+
- `builtins.lds()` default for `lightning/stateManagerGraphQL`:
|
|
83
|
+
`graphqlQuery` (shared with the `graphql` wire entry).
|
|
84
|
+
|
|
85
|
+
Whatever tool names you settle on here **must match** the branches in
|
|
86
|
+
`bootstrap.js` mocks (Step 8). For state-manager consumers, also note
|
|
87
|
+
that `smGraphQL`'s outer shape exposes `errors` (plural), matching its
|
|
88
|
+
sibling wire adapter — UIAPI managers (`smRecord`, `smObjectInfo`)
|
|
89
|
+
expose `error` (singular).
|