vite-plugin-zephyr 1.3.0 → 1.4.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 CHANGED
@@ -58,11 +58,52 @@ export default defineConfig({
58
58
 
59
59
  ### Multi-Environment and SSR Builds
60
60
 
61
- Vite 6, 7, and 8 environment builds are collected across `client`, `server`, RSC, or custom
62
- child environments and published once after `buildApp` completes. The plugin validates
63
- that each current environment contributed output; persisted partial-build contributions
64
- are merged atomically. Vite 5 and watch builds use the direct single-environment upload
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
@@ -1,3 +1,2 @@
1
- import "node:module";
2
1
  export { withZephyr } from "./lib/vite-plugin-zephyr.mjs";
3
2
  export { withZephyrPartial } from "./lib/vite-plugin-zephyr-partial.mjs";
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { ze_log } from "zephyr-agent";
3
2
  import { normalizeEntrypoint } from "../utils/normalize-entrypoint.mjs";
4
3
  function extractEntrypoint(config) {
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  function isPlugin(plugin) {
3
2
  return !!plugin && 'object' == typeof plugin && 'name' in plugin;
4
3
  }
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { buildAssetsMap } from "zephyr-agent";
3
2
  import { loadStaticAssets } from "./load_static_assets.mjs";
4
3
  import { mergeViteOutputAssets } from "./merge_vite_output_assets.mjs";
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { basename, resolve } from "node:path";
3
2
  import { readDirRecursiveWithContents } from "zephyr-agent";
4
3
  import { normalizeFilesystemVitePath, normalizeVitePath } from "../utils/normalize-vite-path.mjs";
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { load_public_dir } from "./load_public_dir.mjs";
3
2
  import { load_static_entries } from "./load_static_entries.mjs";
4
3
  import { mergeViteOutputAssets } from "./merge_vite_output_assets.mjs";
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { basename, resolve } from "node:path";
3
2
  import { readDirRecursiveWithContents } from "zephyr-agent";
4
3
  import { normalizeFilesystemVitePath, normalizeVitePath } from "../utils/normalize-vite-path.mjs";
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { ZeErrors, ZephyrError } from "zephyr-agent";
3
2
  import { normalizeVitePath } from "../utils/normalize-vite-path.mjs";
4
3
  function outputBytes(asset) {
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
3
2
  import { dirname as __rspack_dirname } from "node:path";
4
3
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { readPackageJson } from "zephyr-agent";
3
2
  function extract_remotes_dependencies(root, mfConfig) {
4
3
  const { zephyrDependencies } = readPackageJson(root);
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { ZeErrors, ZephyrError, resolveMfManifestPath } from "zephyr-agent";
3
2
  function nonEmptyString(value) {
4
3
  return 'string' == typeof value && value.trim() ? value : void 0;
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { ZeErrors, ZephyrError } from "zephyr-agent";
3
2
  function firstDefined(parts) {
4
3
  return parts.every((part)=>!!part) ? parts.join(':') : void 0;
@@ -1 +1 @@
1
- import "node:module";
1
+ export { };
@@ -1 +1 @@
1
- import "node:module";
1
+ export { };
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  function normalizeEntrypoint(entrypoint) {
3
2
  let normalized = entrypoint.trim();
4
3
  normalized = normalized.split('\\').join('/');
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  import { sep } from "node:path";
3
2
  function normalizeVitePath(pathname) {
4
3
  return pathname.replace(/\\/g, '/');
@@ -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";