vite-plugin-zephyr 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -5
- package/dist/index.mjs +0 -1
- package/dist/lib/internal/extract/extract-entrypoint.mjs +0 -1
- package/dist/lib/internal/extract/extract_mf_plugin.mjs +0 -1
- package/dist/lib/internal/extract/extract_vite_assets_map.mjs +0 -1
- package/dist/lib/internal/extract/load_public_dir.mjs +0 -1
- package/dist/lib/internal/extract/load_static_assets.mjs +0 -1
- package/dist/lib/internal/extract/load_static_entries.mjs +0 -1
- package/dist/lib/internal/extract/merge_vite_output_assets.mjs +0 -1
- package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.mjs +0 -1
- package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.mjs +0 -1
- package/dist/lib/internal/mf-vite-etl/federation-metadata.mjs +0 -1
- package/dist/lib/internal/mf-vite-etl/runtime_plugin.mjs +33 -10
- package/dist/lib/internal/partial-build-scope.mjs +0 -1
- package/dist/lib/internal/types/zephyr-internal-options.mjs +1 -1
- package/dist/lib/internal/types/zephyr-output.mjs +1 -1
- package/dist/lib/internal/utils/normalize-entrypoint.mjs +0 -1
- package/dist/lib/internal/utils/normalize-vite-path.mjs +0 -1
- package/dist/lib/vite-plugin-zephyr-partial.mjs +0 -1
- package/dist/lib/vite-plugin-zephyr.js +696 -560
- package/dist/lib/vite-plugin-zephyr.mjs +245 -100
- package/package.json +2 -2
- package/dist/rslib-runtime~0.mjs +0 -21
package/README.md
CHANGED
|
@@ -58,11 +58,52 @@ export default defineConfig({
|
|
|
58
58
|
|
|
59
59
|
### Multi-Environment and SSR Builds
|
|
60
60
|
|
|
61
|
-
Vite
|
|
62
|
-
child environments and
|
|
63
|
-
that each current environment contributed output; persisted
|
|
64
|
-
are merged atomically.
|
|
65
|
-
path
|
|
61
|
+
Vite 7 and 8 application-builder invocations collect output across `client`, `server`,
|
|
62
|
+
RSC, or custom child environments and publish once through the `buildApp` hook. The
|
|
63
|
+
plugin validates that each current environment contributed output; persisted
|
|
64
|
+
partial-build contributions are merged atomically. Programmatic `vite.build()` calls,
|
|
65
|
+
including Slidev builds, use the direct single-environment upload path, as do Vite 5
|
|
66
|
+
and single-environment watch builds.
|
|
67
|
+
|
|
68
|
+
When `createBuilder()` instantiates multiple environments, publish through
|
|
69
|
+
`builder.buildApp()`. Calling `builder.build(environment)` individually is rejected to
|
|
70
|
+
prevent separate, incomplete deployments. This check tracks actual environment
|
|
71
|
+
creation, so ordinary legacy SSR builds can still select one server environment.
|
|
72
|
+
|
|
73
|
+
Non-watch programmatic builds collect every output format and publish one combined
|
|
74
|
+
snapshot when the bundler closes, after all expected writes succeed. External partial
|
|
75
|
+
output is claimed and committed once for that snapshot. Library `formats` and explicit
|
|
76
|
+
output arrays are both supported. Separate output directories are preserved relative
|
|
77
|
+
to their common root; TAP artifact paths remain unchanged.
|
|
78
|
+
|
|
79
|
+
Direct SSR builds infer `snapshotType: 'ssr'` from the selected server build and use its
|
|
80
|
+
emitted entry chunk, including renamed or hashed filenames. Explicit `snapshotType` and
|
|
81
|
+
`entrypoint` options take precedence. Multiple server entry chunks require an explicit
|
|
82
|
+
emitted `entrypoint`. TAP builds do not infer SSR unless explicitly requested.
|
|
83
|
+
|
|
84
|
+
For direct non-watch publication, Zephyr must observe the final `outputOptions`,
|
|
85
|
+
`writeBundle` and `closeBundle` hooks. Output plugins are checked after normal option
|
|
86
|
+
hooks have returned their changes. Later post-ordered hooks and unresolved asynchronous
|
|
87
|
+
output plugins are rejected because they could change the writers or fail after Zephyr
|
|
88
|
+
records success. Application-builder and watch publication keep their own lifecycles.
|
|
89
|
+
|
|
90
|
+
If publication and partial-claim rollback both fail, the rollback error is logged
|
|
91
|
+
separately and the original publication error keeps the configured throw-or-log behavior.
|
|
92
|
+
|
|
93
|
+
Vite 6 does not dispatch plugin `buildApp` hooks. Its non-watch publication supports only
|
|
94
|
+
a single environment without an explicit `builder` configuration; other configurations
|
|
95
|
+
are rejected to avoid publishing incomplete output. Use Vite 7 or newer for coordinated
|
|
96
|
+
application builds.
|
|
97
|
+
|
|
98
|
+
Place `withZephyr()` before other plugins that combine `enforce: 'pre'` with a
|
|
99
|
+
pre-ordered `buildApp` hook. Zephyr checks this order before building so it can start
|
|
100
|
+
collecting output before any application build hook compiles an environment. The
|
|
101
|
+
ordering check also applies to legacy builds carrying those plugins.
|
|
102
|
+
|
|
103
|
+
Files generated by a framework after `vite.build()` returns are outside the Vite upload
|
|
104
|
+
lifecycle. For example, Slidev can generate a PDF, an OG image, `404.html`, and
|
|
105
|
+
`_redirects` after Vite finishes; those files need a separate post-build publication
|
|
106
|
+
step if they must be included.
|
|
66
107
|
|
|
67
108
|
```typescript
|
|
68
109
|
withZephyr({
|
package/dist/index.mjs
CHANGED
|
@@ -4,15 +4,38 @@ function getGlobalManifestCache() {
|
|
|
4
4
|
if (!_global[globalCacheKey]) _global[globalCacheKey] = new Map();
|
|
5
5
|
return _global[globalCacheKey];
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const manifestFileName = 'zephyr-manifest.json';
|
|
8
|
+
function toHttpUrl(value) {
|
|
9
|
+
if (!value) return;
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(value);
|
|
12
|
+
return 'http:' === url.protocol || 'https:' === url.protocol ? url : void 0;
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getModuleUrl() {
|
|
18
|
+
try {
|
|
19
|
+
return import.meta.url;
|
|
20
|
+
} catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getDocumentBaseUrl() {
|
|
25
|
+
if ("u" < typeof document || 'function' != typeof document.querySelector) return;
|
|
26
|
+
if (!document.querySelector('base[href]')) return;
|
|
27
|
+
try {
|
|
28
|
+
return toHttpUrl(new URL('.', document.baseURI).href);
|
|
29
|
+
} catch {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function resolveManifestUrl(moduleUrl) {
|
|
34
|
+
const script = toHttpUrl(moduleUrl);
|
|
35
|
+
const documentBase = getDocumentBaseUrl();
|
|
36
|
+
if (documentBase && (!script || script.origin === documentBase.origin)) return `${documentBase.href}${manifestFileName}`;
|
|
37
|
+
if (script) return `${script.origin}/${manifestFileName}`;
|
|
38
|
+
return `/${manifestFileName}`;
|
|
16
39
|
}
|
|
17
40
|
function getRemotes(args) {
|
|
18
41
|
if (Array.isArray(args?.options?.remotes)) return args.options.remotes;
|
|
@@ -20,7 +43,7 @@ function getRemotes(args) {
|
|
|
20
43
|
return [];
|
|
21
44
|
}
|
|
22
45
|
export default function createZephyrRuntimePlugin(options = {}) {
|
|
23
|
-
const defaultManifestUrl =
|
|
46
|
+
const defaultManifestUrl = resolveManifestUrl(getModuleUrl());
|
|
24
47
|
const { manifestUrl = defaultManifestUrl } = options;
|
|
25
48
|
let processedRemotes;
|
|
26
49
|
async function fetchManifest(url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "node:module";
|
|
2
1
|
import { ZeErrors, ZephyrEngine, ZephyrError, assertZephyrBuildTarget, handleGlobalError, savePartialAssetMap } from "zephyr-agent";
|
|
3
2
|
import { extract_vite_assets_map } from "./internal/extract/extract_vite_assets_map.mjs";
|
|
4
3
|
import { requireVitePartialBuildScope } from "./internal/partial-build-scope.mjs";
|