@salesforce/vite-plugin-ui-bundle 12.16.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 +185 -0
- package/dist/core/assetRefTracer.d.ts +10 -1
- package/dist/core/assetRefTracer.d.ts.map +1 -1
- package/dist/core/buildManifest.d.ts +221 -0
- package/dist/core/buildManifest.d.ts.map +1 -0
- package/dist/core/createCorePlugins.d.ts +21 -0
- package/dist/core/createCorePlugins.d.ts.map +1 -1
- package/dist/createCorePlugins-C2hhY3Xv.js +1192 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/site/index.js +1 -1
- package/package.json +17 -5
- package/dist/createCorePlugins-CC0qwAbX.js +0 -592
package/README.md
CHANGED
|
@@ -50,3 +50,188 @@ neither. The site entry mirrors this for local dev, per request:
|
|
|
50
50
|
|
|
51
51
|
All of this is gated to non-production, non-CodeBuilder, and a non-empty
|
|
52
52
|
`languages` list, so a deployed build and every generic bundle are untouched.
|
|
53
|
+
|
|
54
|
+
### Build manifest (`buildManifest`)
|
|
55
|
+
|
|
56
|
+
Bundles inside Core that Core composes through its import map (a shell and the
|
|
57
|
+
screen bundles it mounts), or serves as a published version, turn on
|
|
58
|
+
`buildManifest`. It's off by default and runs only during `vite build` (not an
|
|
59
|
+
SSR build). It keeps every specifier in Core's shared allowlist a bare import,
|
|
60
|
+
builds the bundle's main module as an entry, and writes `ui-bundle.build.json`
|
|
61
|
+
into the build output, listing the files on disk when it runs:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import uiBundlePlugin from "@salesforce/vite-plugin-ui-bundle";
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
plugins: [uiBundlePlugin({ disableOrgProxy: true, buildManifest: true }), react()],
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The main module is what `@screens/<namespace>/<name>` resolves to, so a screen
|
|
71
|
+
bundle names it as its package's root export, which is what an `import` of the
|
|
72
|
+
package would load:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "name": "screens", "exports": "./src/routes.tsx" }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`exports["."]` works too, taking the `import`, then `default` condition. `main`
|
|
79
|
+
and `module` are ignored: `npm init` writes `"main": "index.js"` whether or not
|
|
80
|
+
the file exists. A bundle with no root export, such as a shell, has no `entry`.
|
|
81
|
+
|
|
82
|
+
Pass an object instead of `true` to override the defaults below. The site entry
|
|
83
|
+
accepts the same option.
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"manifestVersion": 1,
|
|
88
|
+
"entry": "assets/routes-Da6y3Zy7.js",
|
|
89
|
+
"entryCss": ["assets/routes-BmT0x_3c.css"],
|
|
90
|
+
"externals": ["react", "react/jsx-runtime"],
|
|
91
|
+
"peerDependencies": { "react": "^19.0.0" },
|
|
92
|
+
"uiBundle": {
|
|
93
|
+
"outputDir": "dist",
|
|
94
|
+
"appNamespace": "sales",
|
|
95
|
+
"appName": "accounts",
|
|
96
|
+
"composition": { "screens": [{ "mount": "/accounts", "label": "Accounts" }] }
|
|
97
|
+
},
|
|
98
|
+
"version": "1.2.0",
|
|
99
|
+
"files": [
|
|
100
|
+
{ "path": "assets/routes-Da6y3Zy7.js", "md5": "…", "size": 1234 },
|
|
101
|
+
{ "path": "favicon.ico", "md5": "…", "size": 4286, "cache": "revalidate" },
|
|
102
|
+
{ "path": "index.html", "md5": "…", "size": 512 }
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Field | Source |
|
|
108
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
109
|
+
| `manifestVersion` | The manifest's format, now `1`. Keys are only ever added to a version; a change Core can't ignore bumps it. |
|
|
110
|
+
| `entry` | Output file of the main module. Absent for a bundle without one, such as a shell. |
|
|
111
|
+
| `entryCss` | CSS files the main module needs, in link order. A page that imports the module links them; Vite only links them from `index.html`. |
|
|
112
|
+
| `externals` | Shared specifiers the output imports, including from dependencies. |
|
|
113
|
+
| `peerDependencies` | The bundle's package.json `peerDependencies`, limited to packages of shared specifiers. |
|
|
114
|
+
| `uiBundle` | A copy of the bundle's `ui-bundle.json`, every key as written, so Core fetches one file per version. Absent without one. |
|
|
115
|
+
| `version` | The `version` option, else the bundle's package.json `version`. |
|
|
116
|
+
| `files` | Every regular file in the output directory when the manifest is written, except the manifest, with `md5` and `size`. Core derives each file's content type from its extension. |
|
|
117
|
+
| `files[].cache` | `"revalidate"` on each non-HTML file the build can't prove is content-hashed (see below). Absent on hashed files and HTML. |
|
|
118
|
+
|
|
119
|
+
Core serves a UI bundle's non-HTML files as immutable for a year, so a file
|
|
120
|
+
whose bytes change under the same name would stay stale in browsers. `cache:
|
|
121
|
+
"revalidate"` tells Core to serve that file `public,no-cache` with an ETag
|
|
122
|
+
instead. A file counts as hashed only if it's part of this build and:
|
|
123
|
+
|
|
124
|
+
- for a chunk, the bundler put a content hash in its name, whether the name
|
|
125
|
+
came from a string or a function `entryFileNames` or `chunkFileNames`;
|
|
126
|
+
- for an asset, `assetFileNames` named it, from a string or a function, with a
|
|
127
|
+
pattern that has `[hash]` or `[hash:N]`. An asset emitted with an explicit
|
|
128
|
+
`fileName`, such as a sourcemap, isn't hashed whatever its name.
|
|
129
|
+
|
|
130
|
+
Vite's defaults qualify, so with a default config only the files copied from
|
|
131
|
+
`public/`, sourcemaps, and files written under a fixed name (by Vite, such as
|
|
132
|
+
`.vite/manifest.json`, or by other plugins) are marked. Put files that must
|
|
133
|
+
keep their URL while their content changes, such as `sw.js`,
|
|
134
|
+
`manifest.webmanifest`, `favicon.ico` or `robots.txt`, in `public/`. A plugin
|
|
135
|
+
that changes a file's bytes in `generateBundle`, after its name is hashed,
|
|
136
|
+
isn't caught. Marking a hashed file costs a 304
|
|
137
|
+
per revalidation, never stale content, so the build errs toward marking.
|
|
138
|
+
|
|
139
|
+
| Option | Default | Meaning |
|
|
140
|
+
| --------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
141
|
+
| `shared` | `uiBundleShared` of the nearest package.json at/above root | Specifiers kept external. The build fails if none is found. |
|
|
142
|
+
| `entry` | package.json `exports["."]` | Main module, added as a build entry with its exports kept. |
|
|
143
|
+
| `version` | package.json `version` | Published version; must be one Core accepts: `[A-Za-z0-9][A-Za-z0-9._-]*`, up to 64 characters, so no `+build` metadata. |
|
|
144
|
+
|
|
145
|
+
Composition is declared in the `composition` of `ui-bundle.json`. That file
|
|
146
|
+
stays the one you edit; the manifest's `uiBundle` is generated from it, so it
|
|
147
|
+
is published with every version:
|
|
148
|
+
|
|
149
|
+
- `screens`: the tabs this bundle provides. Each has a `mount`, a literal URL
|
|
150
|
+
prefix such as `/accounts`: the tab's link, and the claim on that path and
|
|
151
|
+
every path under it. The pages under a mount are the routes of the bundle's
|
|
152
|
+
entry, not listed here. They're mounted through the entry, so a bundle with
|
|
153
|
+
screens needs one.
|
|
154
|
+
- `screenDependencies`: the bundles, as `namespace/name`, whose screens this
|
|
155
|
+
bundle shows. Names ignore case. That makes it a shell. Its own screens come first, then each
|
|
156
|
+
dependency's in order; on overlapping mounts, the first one wins.
|
|
157
|
+
|
|
158
|
+
A shell can set both. Composition is for bundles inside Core only: the
|
|
159
|
+
platform's deploy schema doesn't accept `composition`, and Core ignores keys it
|
|
160
|
+
doesn't know, so this build is the only check. `appNamespace` and `appName`
|
|
161
|
+
name the bundle, which lets the build reject a bundle that lists itself. See
|
|
162
|
+
[the ADR](../../docs/adr/2026-10-24-ui-bundle-composition.md).
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"outputDir": "dist",
|
|
167
|
+
"composition": {
|
|
168
|
+
"screens": [{ "mount": "/accounts", "label": "Accounts" }],
|
|
169
|
+
"screenDependencies": ["sales/contacts"]
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The build fails, rather than shipping a bundle Core would drop or misread:
|
|
175
|
+
|
|
176
|
+
- `composition` or a screen has an unknown key (it names the closest known
|
|
177
|
+
one), or `composition` isn't an object;
|
|
178
|
+
- a screen has no `mount`, a `mount` that isn't `/` then literal segments (no
|
|
179
|
+
pattern syntax, no trailing `/`, only characters a browser leaves unencoded
|
|
180
|
+
in a path), a field of the wrong type, an `order` that isn't a
|
|
181
|
+
32-bit integer, an `access` entry that isn't an access check name
|
|
182
|
+
(`Namespace.checkName`, such as `LwrInternalApp.hasTestingAppAccess`), or a
|
|
183
|
+
`mount` equal to, or under or over, an earlier screen's;
|
|
184
|
+
- a screen dependency isn't `namespace/name`, is listed twice, or is this bundle;
|
|
185
|
+
- there are screens but no entry, or the entry is missing or inside the build output;
|
|
186
|
+
- there's an entry and `build.cssCodeSplit` is false (as in library mode), since
|
|
187
|
+
its CSS then can't be listed;
|
|
188
|
+
- an external has no `peerDependencies` range, or a range isn't one Core reads
|
|
189
|
+
(Core's npm range grammar: no `workspace:`, tags or pre-releases). Core drops
|
|
190
|
+
a screen bundle for that, and logs it for a shell's own externals;
|
|
191
|
+
- `peerDependencies` isn't an object of strings, `ui-bundle.json` isn't an
|
|
192
|
+
object, or `version` isn't one Core accepts;
|
|
193
|
+
- the output `index.html` has an import map of its own, which stops Core composing the page;
|
|
194
|
+
- React's dev JSX runtime is bundled, which crashes on Core's production React.
|
|
195
|
+
Build with `NODE_ENV=production`; `vite build` sets it unless you've set
|
|
196
|
+
another value;
|
|
197
|
+
- a package.json or ui-bundle.json isn't valid JSON (the error names its path).
|
|
198
|
+
|
|
199
|
+
The build warns when:
|
|
200
|
+
|
|
201
|
+
- it bundles a module of a shared package through a specifier that isn't
|
|
202
|
+
shared, such as `react-dom/server`: that code is a second copy, next to the
|
|
203
|
+
one Core shares;
|
|
204
|
+
- Vite won't empty the output directory, since files of an earlier build would
|
|
205
|
+
be listed. Set `build.emptyOutDir: true`;
|
|
206
|
+
- the output has symlinks, which aren't listed.
|
|
207
|
+
|
|
208
|
+
The build removes an earlier `ui-bundle.build.json` before it writes any file,
|
|
209
|
+
so a build that fails leaves none behind. To build a bundle for Core without
|
|
210
|
+
changing dev or test builds, turn the option on for production only:
|
|
211
|
+
`buildManifest: mode === "production"`.
|
|
212
|
+
|
|
213
|
+
## Single-file output
|
|
214
|
+
|
|
215
|
+
Set `singleFile: true` to emit one self-contained `index.html` at build time
|
|
216
|
+
(required for MCP apps). Requires
|
|
217
|
+
[`vite-plugin-singlefile`](https://github.com/richardtallent/vite-plugin-singlefile).
|
|
218
|
+
It is applied to `vite build` only. Defaults to `false`. Works with both the
|
|
219
|
+
generic and `./site` entries.
|
|
220
|
+
|
|
221
|
+
Inlined: JS, CSS, imported assets, and plain JSX `src/assets/...` string
|
|
222
|
+
literals (e.g. `<img src="src/assets/images/logo.png">`, which the build imports
|
|
223
|
+
so Vite inlines it once, however often it is referenced). Not inlined: `public/`
|
|
224
|
+
files (copied as separate files; the build warns listing every copied file:
|
|
225
|
+
import them from `src/` to inline) and SVG `#fragment` refs such as
|
|
226
|
+
`<use href="src/assets/images/icons.svg#a">` (a `data:` URL can't serve `<use>`),
|
|
227
|
+
which are emitted as separate files with a build warning. Paths in template
|
|
228
|
+
literals or variables aren't traced, so import those assets explicitly.
|
|
229
|
+
|
|
230
|
+
Note: an `<a href>` to an inlined asset becomes a `data:` link, which browsers
|
|
231
|
+
block for top-level navigation unless the anchor has a `download` attribute.
|
|
232
|
+
Single-file output can also be large.
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import uiBundlePlugin from "@salesforce/vite-plugin-ui-bundle";
|
|
236
|
+
export default defineConfig({ plugins: [uiBundlePlugin({ singleFile: true })] });
|
|
237
|
+
```
|
|
@@ -11,6 +11,15 @@ import { Plugin } from 'vite';
|
|
|
11
11
|
*
|
|
12
12
|
* `apply: "build"` + `enforce: "pre"`: no-op under `vite serve`, and runs before
|
|
13
13
|
* esbuild's JSX transform so it still sees JSX attribute syntax.
|
|
14
|
+
*
|
|
15
|
+
* With `inline: true` (set by the `singleFile` option) nothing is emitted: the
|
|
16
|
+
* module instead gets `import _sfAsset from "./<relative path>"` and the attr
|
|
17
|
+
* references that binding, so Vite's asset pipeline handles it (vite-plugin-singlefile
|
|
18
|
+
* forces it to inline as a data URI, once per asset). The exception is an SVG
|
|
19
|
+
* `#fragment` ref (`<use href="icons.svg#a">`): a data URL can't serve `<use>`, so
|
|
20
|
+
* it is still emitted as a file and a warning is logged.
|
|
14
21
|
*/
|
|
15
|
-
export declare function createAssetRefTracerPlugin(
|
|
22
|
+
export declare function createAssetRefTracerPlugin({ inline }?: {
|
|
23
|
+
inline?: boolean;
|
|
24
|
+
}): Plugin;
|
|
16
25
|
//# sourceMappingURL=assetRefTracer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetRefTracer.d.ts","sourceRoot":"","sources":["../../src/core/assetRefTracer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"assetRefTracer.d.ts","sourceRoot":"","sources":["../../src/core/assetRefTracer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAgOnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CA8FhG"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { UIBundleManifest } from '@salesforce/ui-bundle/app';
|
|
2
|
+
import { Plugin, Rollup } from 'vite';
|
|
3
|
+
/** File name Core reads the build manifest from, at the root of the build output. */
|
|
4
|
+
export declare const BUILD_MANIFEST_FILE = "ui-bundle.build.json";
|
|
5
|
+
/**
|
|
6
|
+
* Format of `ui-bundle.build.json`. Published manifests are stored and read
|
|
7
|
+
* back by later Core versions, so changes are additive only: a new field
|
|
8
|
+
* keeps this version, and a changed type or meaning needs a new one.
|
|
9
|
+
*/
|
|
10
|
+
export declare const BUILD_MANIFEST_VERSION = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Options for `uiBundlePlugin({ buildManifest: { ... } })`. Every option has a
|
|
13
|
+
* default that suits a bundle in Core's layout, so `buildManifest: true` is
|
|
14
|
+
* usually enough.
|
|
15
|
+
*/
|
|
16
|
+
export interface BuildManifestOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Specifiers the host page provides through its import map. They stay bare
|
|
19
|
+
* imports in the output. Defaults to `uiBundleShared` from the nearest
|
|
20
|
+
* package.json at or above the Vite root that declares it.
|
|
21
|
+
*/
|
|
22
|
+
shared?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* The bundle's main module: what `@screens/<namespace>/<name>` imports, so
|
|
25
|
+
* the route module a shell mounts. Relative to the Vite root. It is added as
|
|
26
|
+
* a build entry with its exports kept, and its output file is the manifest's
|
|
27
|
+
* `entry`. Defaults to the package.json root export (`exports["."]`); a
|
|
28
|
+
* bundle with neither (a shell) has no `entry`.
|
|
29
|
+
*/
|
|
30
|
+
entry?: string;
|
|
31
|
+
/** Published version. Defaults to the bundle's package.json `version`. */
|
|
32
|
+
version?: string;
|
|
33
|
+
}
|
|
34
|
+
/** One file of the build output. */
|
|
35
|
+
export interface UiBundleBuildFile {
|
|
36
|
+
/** Relative to the build output, `/`-separated. */
|
|
37
|
+
path: string;
|
|
38
|
+
/** Lowercase hex MD5 of the bytes. Core compares it to what was uploaded. */
|
|
39
|
+
md5: string;
|
|
40
|
+
/** Size in bytes. Informational: Core doesn't check it. */
|
|
41
|
+
size: number;
|
|
42
|
+
/**
|
|
43
|
+
* `"revalidate"` when the build can't prove the file is content-hashed, i.e.
|
|
44
|
+
* that its name changes whenever its bytes do. Core then serves it
|
|
45
|
+
* `public,no-cache` with an ETag instead of immutable for a year. Absent for
|
|
46
|
+
* hashed files and HTML. See `hashedFiles`.
|
|
47
|
+
*/
|
|
48
|
+
cache?: "revalidate";
|
|
49
|
+
}
|
|
50
|
+
/** Contents of `ui-bundle.build.json`, as Core's `UiBundleBuildManifest` reads them. */
|
|
51
|
+
export interface UiBundleBuildManifest {
|
|
52
|
+
/** See `BUILD_MANIFEST_VERSION`. */
|
|
53
|
+
manifestVersion: number;
|
|
54
|
+
/** Output file of the route module, for a screen bundle. */
|
|
55
|
+
entry?: string;
|
|
56
|
+
/**
|
|
57
|
+
* CSS files the entry needs, in the order to link them (its imports' CSS
|
|
58
|
+
* before its own). Set when there is an entry. Vite links an entry's CSS
|
|
59
|
+
* from index.html, so a shell importing the entry must add the links itself.
|
|
60
|
+
*/
|
|
61
|
+
entryCss?: string[];
|
|
62
|
+
/**
|
|
63
|
+
* Shared specifiers the output imports, sorted. Core range-checks each, and
|
|
64
|
+
* preloads those of the bundle whose page it serves.
|
|
65
|
+
*/
|
|
66
|
+
externals: string[];
|
|
67
|
+
/** The bundle's peerDependencies, limited to packages of shared specifiers. */
|
|
68
|
+
peerDependencies: Record<string, string>;
|
|
69
|
+
/**
|
|
70
|
+
* A copy of the bundle's `ui-bundle.json`, every key as written. It has to
|
|
71
|
+
* stay verbatim: for a published version, Core checks the bundle's identity
|
|
72
|
+
* (`appNamespace`, `appName`) and `outputDir` from it, and composition reads
|
|
73
|
+
* `composition`. Absent when the bundle has no `ui-bundle.json`.
|
|
74
|
+
*/
|
|
75
|
+
uiBundle?: UIBundleManifest & Record<string, unknown>;
|
|
76
|
+
/** Becomes part of the store key; see `VERSION_PATTERN`. */
|
|
77
|
+
version?: string;
|
|
78
|
+
/** Every file of the build output except this manifest, sorted by path. */
|
|
79
|
+
files: UiBundleBuildFile[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Walks up from `root` to the first package.json that declares `uiBundleShared`
|
|
83
|
+
* and returns that list, or `undefined` if none does. Lets a bundle sit at any
|
|
84
|
+
* depth below the package that owns the allowlist (Core's root package.json).
|
|
85
|
+
*/
|
|
86
|
+
export declare function findSharedAllowlist(root: string): string[] | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* The file package.json's `exports` maps the package root to: `exports` as a
|
|
89
|
+
* string, or `exports["."]`, taking the `import` then `default` condition when
|
|
90
|
+
* it is an object. `main` and `module` are ignored: `npm init` writes
|
|
91
|
+
* `"main": "index.js"` whether or not that file exists.
|
|
92
|
+
*
|
|
93
|
+
* Accepted shapes, all resolving to `./src/routes.tsx`:
|
|
94
|
+
* - `"exports": "./src/routes.tsx"`
|
|
95
|
+
* - `"exports": { ".": "./src/routes.tsx", "./other": "..." }`
|
|
96
|
+
* - `"exports": { "import": "./src/routes.tsx" }`
|
|
97
|
+
* - `"exports": { ".": { "import": { "default": "./src/routes.tsx" } } }`
|
|
98
|
+
*/
|
|
99
|
+
export declare function packageRootExport(pkg: Record<string, unknown>): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Whether Core's `NpmRange` can read `range`: `||` alternatives of
|
|
102
|
+
* space-separated comparators (`>=18 <20`), or a hyphen range (`18 - 19`),
|
|
103
|
+
* each `^`, `~`, `>`, `>=`, `<`, `<=` or `=` and a partial version. That is a
|
|
104
|
+
* subset of npm's ranges: a pre-release (`^19.0.0-rc.1`), `workspace:*`,
|
|
105
|
+
* `catalog:` and `npm:react@^19` aren't in it, and Core would drop the screen
|
|
106
|
+
* with PEER_RANGE_MISMATCH. A number too large for a Java `int` matches nothing.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isCoreRange(range: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* The package a module path belongs to: the last node_modules segment of the
|
|
111
|
+
* path. With nested installs (`node_modules/a/node_modules/react/...`) or pnpm
|
|
112
|
+
* (`node_modules/.pnpm/react@19/node_modules/react/...`), that is the package.
|
|
113
|
+
* The lookahead leaves the `/` after the name, so a nested `/node_modules/`
|
|
114
|
+
* can still match.
|
|
115
|
+
*/
|
|
116
|
+
export declare function nodeModulesPackage(id: string): string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Whether `mount` is a literal path prefix: `/` then one or more segments of the
|
|
119
|
+
* characters a browser leaves unencoded in a URL's path, so a shell can match
|
|
120
|
+
* `location.pathname` against it as is. That leaves out pattern syntax (`:`, `*`),
|
|
121
|
+
* query, fragment, percent-escapes, backslashes, whitespace and non-ASCII. No
|
|
122
|
+
* segment is empty (so no trailing `/`), `.` or `..`. Same rule as Core's
|
|
123
|
+
* `UiBundleCompositionService.isMount`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isMount(mount: string): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Whether two mounts claim the same URL: they're equal, or one is a whole-segment
|
|
128
|
+
* prefix of the other. Same rule as Core's `UiBundleCompositionService.overlaps`.
|
|
129
|
+
*
|
|
130
|
+
* Examples:
|
|
131
|
+
* - `/providers` and `/providers/x` overlap;
|
|
132
|
+
* - `/provider` and `/providers` don't: the prefix has to end at a `/`;
|
|
133
|
+
* - `/accounts` and `/contacts` don't.
|
|
134
|
+
*/
|
|
135
|
+
export declare function mountsOverlap(a: string, b: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Checks screen rows (see `UIBundleScreen` in `@salesforce/ui-bundle/app`)
|
|
138
|
+
* the way Core composes them and returns the problems: a row Core would drop
|
|
139
|
+
* (no `mount`, a `mount` that isn't a literal path, one overlapping an
|
|
140
|
+
* earlier row's), a key Core would ignore, a field of the wrong type, or an
|
|
141
|
+
* access check that isn't `Namespace.checkName`.
|
|
142
|
+
*
|
|
143
|
+
* Problems are collected rather than thrown, so one build reports them all.
|
|
144
|
+
*/
|
|
145
|
+
export declare function validateScreens(screens: unknown): string[];
|
|
146
|
+
/**
|
|
147
|
+
* Checks the `composition` of ui-bundle.json (see `UIBundleComposition` in
|
|
148
|
+
* `@salesforce/ui-bundle/app`) and returns the problems, with paths from
|
|
149
|
+
* `composition`. Whether a bundle with screens has an entry is checked by the
|
|
150
|
+
* plugin, which knows the entry.
|
|
151
|
+
*
|
|
152
|
+
* `self` is the bundle's own `namespace/name`, from the `appNamespace` and
|
|
153
|
+
* `appName` of an internal bundle's ui-bundle.json. When it's known, a bundle
|
|
154
|
+
* listing itself in `screenDependencies` is reported; Core would ignore that
|
|
155
|
+
* entry.
|
|
156
|
+
*/
|
|
157
|
+
export declare function validateComposition(composition: unknown, self?: string): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Wraps `assetFileNames` so the build sees how the bundler names each asset.
|
|
160
|
+
* `named` maps the md5 of an asset's source to whether every pattern the
|
|
161
|
+
* bundler tried for it has a hash. The bundler may call `assetFileNames` for
|
|
162
|
+
* several assets with the same source before it picks an output name, so one
|
|
163
|
+
* pattern without a hash makes the digest false, and a later hashed pattern
|
|
164
|
+
* can't undo that. An asset emitted with an explicit `fileName` never goes
|
|
165
|
+
* through `assetFileNames`, so it isn't in `named`, whatever its name looks
|
|
166
|
+
* like.
|
|
167
|
+
*
|
|
168
|
+
* The pattern may come from a string or a function, and the bundler applies it
|
|
169
|
+
* to the name itself, including the number it appends to keep names unique.
|
|
170
|
+
*/
|
|
171
|
+
export declare function trackAssetNames(output: Rollup.OutputOptions, named: Map<string, boolean>): Rollup.OutputOptions;
|
|
172
|
+
/**
|
|
173
|
+
* Files of `bundle` whose names change with their bytes. Vite's defaults
|
|
174
|
+
* pass, so with a default config every chunk and every asset Vite names is
|
|
175
|
+
* hashed, and only files from public/, sourcemaps and files written under a
|
|
176
|
+
* fixed name are not.
|
|
177
|
+
*
|
|
178
|
+
* - A chunk is hashed when the bundler put a hash in its name. Rollup and
|
|
179
|
+
* Rolldown name a chunk with a placeholder where the hash goes, computed
|
|
180
|
+
* from the chunk's final content, and keep that name as
|
|
181
|
+
* `preliminaryFileName`; a name without a hash is final as is. That holds
|
|
182
|
+
* whatever produced the name: a string option, a function, or an explicit
|
|
183
|
+
* `fileName` (which never has a placeholder).
|
|
184
|
+
* - Assets keep no such name, so an asset is hashed when `assetFileNames`
|
|
185
|
+
* named it (see `trackAssetNames`) with a pattern that has a hash. That
|
|
186
|
+
* covers a function `assetFileNames`, an unnamed asset, and a name made
|
|
187
|
+
* unique with a number. The record is by content, so it can't tell which
|
|
188
|
+
* of several output files with the same bytes `assetFileNames` named, or
|
|
189
|
+
* whether one of them was emitted with an explicit `fileName`. Such a
|
|
190
|
+
* group counts as unhashed, every file in it.
|
|
191
|
+
*
|
|
192
|
+
* A plugin that changes a file's bytes in `generateBundle`, after its name is
|
|
193
|
+
* hashed, is out of reach: the name stays and Core caches it as hashed.
|
|
194
|
+
*
|
|
195
|
+
* Core never infers this from a name, so the build errs the other way: a
|
|
196
|
+
* hashed file marked anyway costs Core a 304 on each revalidation, while an
|
|
197
|
+
* unhashed file served immutable stays stale for a year.
|
|
198
|
+
*/
|
|
199
|
+
export declare function hashedFiles(bundle: Rollup.OutputBundle, namedAssets: ReadonlyMap<string, boolean>): Set<string>;
|
|
200
|
+
/**
|
|
201
|
+
* Build-only plugin for UI bundles Core composes or serves as a published
|
|
202
|
+
* version. It keeps shared specifiers external, so the page's import map
|
|
203
|
+
* resolves them to Core's single copy, adds the route module as an entry, and
|
|
204
|
+
* writes `ui-bundle.build.json` into the build output. `files` lists the files
|
|
205
|
+
* on disk when its `writeBundle` runs: that is after Vite's and other plugins'
|
|
206
|
+
* writeBundle, but not after one ordered `post` after it, or after `closeBundle`.
|
|
207
|
+
*
|
|
208
|
+
* Hooks, in the order Vite calls them:
|
|
209
|
+
* 1. `configResolved`: find the entry and the shared list; fail early on bad config.
|
|
210
|
+
* 2. `options`: add the entry to the build inputs.
|
|
211
|
+
* 3. `buildStart`: watch the JSON files, and warn when the output isn't emptied.
|
|
212
|
+
* 4. `resolveId` / `load`: keep shared specifiers external.
|
|
213
|
+
* 5. `renderStart`: remove a previous build's manifest.
|
|
214
|
+
* 6. `generateBundle`: record `entry`, `entryCss` and `externals` from the
|
|
215
|
+
* output chunks, fail on React's dev JSX runtime, warn about other
|
|
216
|
+
* bundled copies of shared packages, and record which files are hashed.
|
|
217
|
+
* 7. `writeBundle`: validate, list the files on disk, mark the unhashed ones
|
|
218
|
+
* and write the manifest.
|
|
219
|
+
*/
|
|
220
|
+
export declare function createBuildManifestPlugin(options?: BuildManifestOptions): Plugin;
|
|
221
|
+
//# sourceMappingURL=buildManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildManifest.d.ts","sourceRoot":"","sources":["../../src/core/buildManifest.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
+
import { BuildManifestOptions } from './buildManifest';
|
|
2
3
|
import { DesignPluginOptions } from './design';
|
|
3
4
|
import { BasePathResolver } from './env';
|
|
4
5
|
/** Options shared by both org-backed and UI-only (disabled) modes. */
|
|
5
6
|
interface CorePluginSharedOptions extends DesignPluginOptions {
|
|
6
7
|
/** Enable verbose logging */
|
|
7
8
|
debug?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Write `ui-bundle.build.json` and keep Core-shared specifiers (React) as
|
|
11
|
+
* bare imports, for a bundle Core composes through its import map.
|
|
12
|
+
* Build-only; off by default. `true` uses the defaults in
|
|
13
|
+
* {@link BuildManifestOptions}.
|
|
14
|
+
*/
|
|
15
|
+
buildManifest?: boolean | BuildManifestOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Emit a single self-contained `index.html` at build time (required for MCP apps).
|
|
18
|
+
* Requires `vite-plugin-singlefile`. Inlined: JS, CSS, imported assets, and plain
|
|
19
|
+
* JSX `src/assets/...` string literals. NOT inlined (emitted separately, with a
|
|
20
|
+
* build warning): `public/` files and SVG `#fragment` refs (`<use href="icons.svg#a">`).
|
|
21
|
+
* Paths in template literals or variables aren't traced; import those assets
|
|
22
|
+
* explicitly. An `<a href>` to an inlined
|
|
23
|
+
* asset becomes a `data:` link, which browsers block for top-level navigation
|
|
24
|
+
* unless the anchor has a `download` attribute. Output can be large.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
singleFile?: boolean;
|
|
8
29
|
}
|
|
9
30
|
/**
|
|
10
31
|
* Core plugin options, modeled as a discriminated union on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCorePlugins.d.ts","sourceRoot":"","sources":["../../src/core/createCorePlugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"createCorePlugins.d.ts","sourceRoot":"","sources":["../../src/core/createCorePlugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAGX,MAAM,EAGN,MAAM,MAAM,CAAC;AAYd,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EAIN,KAAK,gBAAgB,EAErB,MAAM,OAAO,CAAC;AAEf,sEAAsE;AACtE,UAAU,uBAAwB,SAAQ,mBAAmB;IAC5D,6BAA6B;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC;IAC/C;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,GACtD,CACG;IACA,mEAAmE;IACnE,eAAe,EAAE,IAAI,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,KAAK,CAAC;CAChB,GACD;IACA,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACjB,CACH,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACnC;AA0BD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAChC,OAAO,GAAE,iBAAsB,EAC/B,KAAK,GAAE,SAAc,GACnB,MAAM,EAAE,CA0TV"}
|