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
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
"@module-federation/vite" (module) {
|
|
4
|
-
module.exports = require("@module-federation/vite");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
var __webpack_module_cache__ = {};
|
|
8
|
-
function __webpack_require__(moduleId) {
|
|
9
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
-
exports: {}
|
|
13
|
-
};
|
|
14
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
-
return module.exports;
|
|
16
|
-
}
|
|
2
|
+
var __webpack_require__ = {};
|
|
17
3
|
(()=>{
|
|
18
4
|
__webpack_require__.n = (module)=>{
|
|
19
5
|
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
@@ -49,396 +35,553 @@ function __webpack_require__(moduleId) {
|
|
|
49
35
|
};
|
|
50
36
|
})();
|
|
51
37
|
var __webpack_exports__ = {};
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return merged;
|
|
81
|
-
}
|
|
82
|
-
function mergeAssetMaps(maps) {
|
|
83
|
-
const merged = {};
|
|
84
|
-
const paths = new Map();
|
|
85
|
-
for (const assetsMap of maps)for (const [hash, asset] of Object.entries(assetsMap)){
|
|
86
|
-
const existingHash = paths.get(asset.path);
|
|
87
|
-
if (existingHash && existingHash !== hash) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
88
|
-
message: `Vite emitted conflicting partial assets for "${asset.path}".`
|
|
89
|
-
});
|
|
90
|
-
paths.set(asset.path, hash);
|
|
91
|
-
merged[hash] = asset;
|
|
92
|
-
}
|
|
93
|
-
return merged;
|
|
94
|
-
}
|
|
95
|
-
function viteEnvironmentOutputPrefix(environmentName) {
|
|
96
|
-
return `${VITE_ENVIRONMENT_OUTPUT_PREFIX}${encodeURIComponent(environmentName)}:`;
|
|
97
|
-
}
|
|
98
|
-
function viteEnvironmentOutputKey(environmentName, outputDirectory, outputFile, outputFormat, assetsMap) {
|
|
99
|
-
const destination = outputFile ? external_node_path_namespaceObject.join(outputDirectory, external_node_path_namespaceObject.basename(outputFile)) : outputDirectory;
|
|
100
|
-
const assets = Object.values(assetsMap).map((asset)=>[
|
|
101
|
-
asset.path.replace(/\\/g, '/'),
|
|
102
|
-
asset.hash,
|
|
103
|
-
asset.size
|
|
104
|
-
]).sort(([leftPath, leftHash], [rightPath, rightHash])=>leftPath === rightPath ? leftHash.localeCompare(rightHash) : leftPath.localeCompare(rightPath));
|
|
105
|
-
const identity = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(JSON.stringify({
|
|
106
|
-
destination: destination.replace(/\\/g, '/'),
|
|
107
|
-
format: outputFormat ?? null,
|
|
108
|
-
assets
|
|
109
|
-
})).digest('hex');
|
|
110
|
-
return `${viteEnvironmentOutputPrefix(environmentName)}${identity}`;
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
withZephyr: ()=>withZephyr
|
|
41
|
+
});
|
|
42
|
+
const promises_namespaceObject = require("node:fs/promises");
|
|
43
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
44
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
45
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
46
|
+
const external_magic_string_namespaceObject = require("magic-string");
|
|
47
|
+
var external_magic_string_default = /*#__PURE__*/ __webpack_require__.n(external_magic_string_namespaceObject);
|
|
48
|
+
const external_zephyr_agent_namespaceObject = require("zephyr-agent");
|
|
49
|
+
const extract_entrypoint_js_namespaceObject = require("./internal/extract/extract-entrypoint.js");
|
|
50
|
+
const extract_mf_plugin_js_namespaceObject = require("./internal/extract/extract_mf_plugin.js");
|
|
51
|
+
const extract_vite_assets_map_js_namespaceObject = require("./internal/extract/extract_vite_assets_map.js");
|
|
52
|
+
const ensure_runtime_plugin_js_namespaceObject = require("./internal/mf-vite-etl/ensure_runtime_plugin.js");
|
|
53
|
+
const extract_mf_vite_remotes_js_namespaceObject = require("./internal/mf-vite-etl/extract-mf-vite-remotes.js");
|
|
54
|
+
const federation_metadata_js_namespaceObject = require("./internal/mf-vite-etl/federation-metadata.js");
|
|
55
|
+
const partial_build_scope_js_namespaceObject = require("./internal/partial-build-scope.js");
|
|
56
|
+
const DEFAULT_LIBRARY_TYPE = 'module';
|
|
57
|
+
const VITE_ENVIRONMENT_OUTPUT_PREFIX = 'vite-environment:';
|
|
58
|
+
const runtimeRequire = (0, external_node_module_namespaceObject.createRequire)(__filename);
|
|
59
|
+
function mergeClaimedPartialMaps(claims) {
|
|
60
|
+
const merged = {};
|
|
61
|
+
for (const claim of claims)for (const [partialKey, assetsMap] of Object.entries(claim.partialAssetMaps)){
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(merged, partialKey)) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
63
|
+
message: `Vite partial output "${partialKey}" was produced by multiple build scopes.`
|
|
64
|
+
});
|
|
65
|
+
merged[partialKey] = assetsMap;
|
|
111
66
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
67
|
+
return merged;
|
|
68
|
+
}
|
|
69
|
+
function mergeAssetMaps(maps) {
|
|
70
|
+
const merged = {};
|
|
71
|
+
const paths = new Map();
|
|
72
|
+
for (const assetsMap of maps)for (const [hash, asset] of Object.entries(assetsMap)){
|
|
73
|
+
const existingHash = paths.get(asset.path);
|
|
74
|
+
if (existingHash && existingHash !== hash) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
75
|
+
message: `Vite emitted conflicting partial assets for "${asset.path}".`
|
|
76
|
+
});
|
|
77
|
+
paths.set(asset.path, hash);
|
|
78
|
+
merged[hash] = asset;
|
|
123
79
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
80
|
+
return merged;
|
|
81
|
+
}
|
|
82
|
+
function viteEnvironmentOutputPrefix(environmentName) {
|
|
83
|
+
return `${VITE_ENVIRONMENT_OUTPUT_PREFIX}${encodeURIComponent(environmentName)}:`;
|
|
84
|
+
}
|
|
85
|
+
function viteEnvironmentOutputKey(environmentName, outputDirectory, outputFile, outputFormat, assetsMap) {
|
|
86
|
+
const destination = outputFile ? external_node_path_namespaceObject.join(outputDirectory, external_node_path_namespaceObject.basename(outputFile)) : outputDirectory;
|
|
87
|
+
const assets = Object.values(assetsMap).map((asset)=>[
|
|
88
|
+
asset.path.replace(/\\/g, '/'),
|
|
89
|
+
asset.hash,
|
|
90
|
+
asset.size
|
|
91
|
+
]).sort(([leftPath, leftHash], [rightPath, rightHash])=>leftPath === rightPath ? leftHash.localeCompare(rightHash) : leftPath.localeCompare(rightPath));
|
|
92
|
+
const identity = (0, external_node_crypto_namespaceObject.createHash)('sha256').update(JSON.stringify({
|
|
93
|
+
destination: destination.replace(/\\/g, '/'),
|
|
94
|
+
format: outputFormat ?? null,
|
|
95
|
+
assets
|
|
96
|
+
})).digest('hex');
|
|
97
|
+
return `${viteEnvironmentOutputPrefix(environmentName)}${identity}`;
|
|
98
|
+
}
|
|
99
|
+
function parseViteEnvironmentOutputName(key) {
|
|
100
|
+
if (!key.startsWith(VITE_ENVIRONMENT_OUTPUT_PREFIX)) return null;
|
|
101
|
+
const outputIdentity = key.slice(VITE_ENVIRONMENT_OUTPUT_PREFIX.length);
|
|
102
|
+
const separator = outputIdentity.indexOf(':');
|
|
103
|
+
if (separator <= 0 || separator === outputIdentity.length - 1) return null;
|
|
104
|
+
try {
|
|
105
|
+
const environmentName = decodeURIComponent(outputIdentity.slice(0, separator));
|
|
106
|
+
return environmentName || null;
|
|
107
|
+
} catch {
|
|
108
|
+
return null;
|
|
139
109
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
110
|
+
}
|
|
111
|
+
function prefixAssetsMap(assetsMap, prefix) {
|
|
112
|
+
const normalized = prefix?.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
|
|
113
|
+
if (!normalized) return assetsMap;
|
|
114
|
+
return Object.fromEntries(Object.values(assetsMap).map((asset)=>{
|
|
115
|
+
const assetPath = asset.path.replace(/\\/g, '/').replace(/^\/+/, '');
|
|
116
|
+
const prefixedPath = assetPath.startsWith(`${normalized}/`) ? assetPath : `${normalized}/${assetPath}`;
|
|
117
|
+
const prefixedAsset = (0, external_zephyr_agent_namespaceObject.zeBuildAssets)({
|
|
118
|
+
filepath: prefixedPath,
|
|
119
|
+
content: asset.buffer
|
|
147
120
|
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
'server/index.mjs',
|
|
152
|
-
'server/index.cjs',
|
|
153
|
-
'ssr/index.js',
|
|
154
|
-
'ssr/index.mjs',
|
|
155
|
-
'ssr/index.cjs',
|
|
156
|
-
'rsc/index.js',
|
|
157
|
-
'rsc/index.mjs',
|
|
158
|
-
'rsc/index.cjs'
|
|
121
|
+
return [
|
|
122
|
+
prefixedAsset.hash,
|
|
123
|
+
prefixedAsset
|
|
159
124
|
];
|
|
160
|
-
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
function inferServerEntrypoint(partials, override, serverEnvironmentNames) {
|
|
128
|
+
if (override) return normalizeEntrypoint(override);
|
|
129
|
+
const allPaths = Object.values(partials).flatMap((assetsMap)=>Object.values(assetsMap).map((asset)=>asset.path));
|
|
130
|
+
const serverEnvironments = new Set(serverEnvironmentNames);
|
|
131
|
+
const serverPaths = Object.entries(partials).flatMap(([key, assetsMap])=>{
|
|
132
|
+
const environmentName = parseViteEnvironmentOutputName(key);
|
|
133
|
+
return environmentName && serverEnvironments.has(environmentName) ? Object.values(assetsMap).map((asset)=>asset.path) : [];
|
|
134
|
+
});
|
|
135
|
+
const paths = serverEnvironmentNames.length > 0 ? serverPaths : allPaths;
|
|
136
|
+
const preferred = [
|
|
137
|
+
'server/index.js',
|
|
138
|
+
'server/index.mjs',
|
|
139
|
+
'server/index.cjs',
|
|
140
|
+
'ssr/index.js',
|
|
141
|
+
'ssr/index.mjs',
|
|
142
|
+
'ssr/index.cjs',
|
|
143
|
+
'rsc/index.js',
|
|
144
|
+
'rsc/index.mjs',
|
|
145
|
+
'rsc/index.cjs'
|
|
146
|
+
];
|
|
147
|
+
return preferred.find((candidate)=>paths.includes(candidate)) ?? paths.find((candidate)=>/(^|\/)(server|index)\.(mjs|cjs|js)$/.test(candidate));
|
|
148
|
+
}
|
|
149
|
+
function hasLateOutputHook(value) {
|
|
150
|
+
if (Array.isArray(value)) return value.some(hasLateOutputHook);
|
|
151
|
+
if (!value || 'object' != typeof value) return false;
|
|
152
|
+
if ('then' in value) return true;
|
|
153
|
+
return [
|
|
154
|
+
'outputOptions',
|
|
155
|
+
'writeBundle'
|
|
156
|
+
].some((name)=>{
|
|
157
|
+
const hook = value[name];
|
|
158
|
+
return Boolean(hook && 'object' == typeof hook && 'order' in hook && 'post' === hook.order);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function commonDirectory(paths) {
|
|
162
|
+
if (0 === paths.length) return;
|
|
163
|
+
const resolvedPaths = paths.map((item)=>external_node_path_namespaceObject.resolve(item));
|
|
164
|
+
let candidate = resolvedPaths[0];
|
|
165
|
+
while(candidate && !resolvedPaths.every((item)=>{
|
|
166
|
+
const relative = external_node_path_namespaceObject.relative(candidate, item);
|
|
167
|
+
return !relative || !relative.startsWith(`..${external_node_path_namespaceObject.sep}`) && '..' !== relative;
|
|
168
|
+
})){
|
|
169
|
+
const parent = external_node_path_namespaceObject.dirname(candidate);
|
|
170
|
+
if (parent === candidate) return;
|
|
171
|
+
candidate = parent;
|
|
161
172
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
if (candidate === external_node_path_namespaceObject.parse(candidate).root && resolvedPaths.length > 1) return;
|
|
174
|
+
return candidate;
|
|
175
|
+
}
|
|
176
|
+
function normalizeEntrypoint(entrypoint) {
|
|
177
|
+
const normalized = entrypoint.replace(/\\/g, '/').replace(/^\.?\/+/, '');
|
|
178
|
+
const segments = normalized.split('/').filter((segment)=>segment && '.' !== segment);
|
|
179
|
+
if (!normalized || 0 === segments.length || segments.includes('..')) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
180
|
+
message: `Vite entrypoint must be a relative path inside the snapshot: "${entrypoint}".`
|
|
181
|
+
});
|
|
182
|
+
return segments.join('/');
|
|
183
|
+
}
|
|
184
|
+
function uniqueParticipant(base, reserved) {
|
|
185
|
+
let participant = base;
|
|
186
|
+
let suffix = 1;
|
|
187
|
+
const used = new Set(reserved);
|
|
188
|
+
while(used.has(participant))participant = `${base}-${suffix++}`;
|
|
189
|
+
return participant;
|
|
190
|
+
}
|
|
191
|
+
function toModuleFederationConfigArray(mfConfig) {
|
|
192
|
+
if (!mfConfig) return [];
|
|
193
|
+
return Array.isArray(mfConfig) ? mfConfig : [
|
|
194
|
+
mfConfig
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
function attachViteFederationBuildStats(buildStats, federationMetadata) {
|
|
198
|
+
const federation = federationMetadata.federation;
|
|
199
|
+
if (!federation || 0 === federation.length) return buildStats;
|
|
200
|
+
const legacyFederation = 1 === federation.length ? federation[0] : void 0;
|
|
201
|
+
return {
|
|
202
|
+
...buildStats,
|
|
203
|
+
federation,
|
|
204
|
+
...legacyFederation ? {
|
|
205
|
+
remote: legacyFederation.remote,
|
|
206
|
+
mf_manifest: legacyFederation.mf_manifest,
|
|
207
|
+
library_type: legacyFederation.library_type,
|
|
208
|
+
exposes: legacyFederation.exposes,
|
|
209
|
+
shared: legacyFederation.shared
|
|
210
|
+
} : {
|
|
211
|
+
remote: void 0,
|
|
212
|
+
mf_manifest: void 0,
|
|
213
|
+
library_type: void 0,
|
|
214
|
+
exposes: void 0,
|
|
215
|
+
shared: void 0
|
|
173
216
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function loadModuleFederationPlugin() {
|
|
220
|
+
let moduleFederation;
|
|
221
|
+
try {
|
|
222
|
+
moduleFederation = runtimeRequire('@module-federation/vite');
|
|
223
|
+
} catch (error) {
|
|
224
|
+
throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_UNKNOWN, {
|
|
225
|
+
message: `vite-plugin-zephyr: @module-federation/vite is required when mfConfig is provided. Install a compatible version of @module-federation/vite to use Module Federation with withZephyr().${error instanceof Error ? ` Original error: ${error.message}` : ''}`
|
|
182
226
|
});
|
|
183
|
-
return segments.join('/');
|
|
184
|
-
}
|
|
185
|
-
function uniqueParticipant(base, reserved) {
|
|
186
|
-
let participant = base;
|
|
187
|
-
let suffix = 1;
|
|
188
|
-
const used = new Set(reserved);
|
|
189
|
-
while(used.has(participant))participant = `${base}-${suffix++}`;
|
|
190
|
-
return participant;
|
|
191
|
-
}
|
|
192
|
-
function toModuleFederationConfigArray(mfConfig) {
|
|
193
|
-
if (!mfConfig) return [];
|
|
194
|
-
return Array.isArray(mfConfig) ? mfConfig : [
|
|
195
|
-
mfConfig
|
|
196
|
-
];
|
|
197
227
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
228
|
+
if ('function' != typeof moduleFederation.federation) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_UNKNOWN, {
|
|
229
|
+
message: 'vite-plugin-zephyr: failed to load @module-federation/vite federation plugin'
|
|
230
|
+
});
|
|
231
|
+
return moduleFederation.federation;
|
|
232
|
+
}
|
|
233
|
+
function withZephyrCore(options = {}) {
|
|
234
|
+
const { zephyr_engine_defer, zephyr_defer_create } = external_zephyr_agent_namespaceObject.ZephyrEngine.defer_create();
|
|
235
|
+
const hooks = options.hooks;
|
|
236
|
+
const preservesLockedArtifactPaths = 'tap-app' === options.target;
|
|
237
|
+
const buildInvocationId = `vite-${(0, external_node_crypto_namespaceObject.randomUUID)()}`;
|
|
238
|
+
const usesExternalPartialBuild = void 0 !== options.partialBuild || Boolean(process.env['ZE_BUILD_INVOCATION_ID']?.trim());
|
|
239
|
+
const externalPartialScope = usesExternalPartialBuild ? (0, partial_build_scope_js_namespaceObject.resolveVitePartialBuildScope)(options.partialBuild) : void 0;
|
|
240
|
+
let resolve_vite_internal_options;
|
|
241
|
+
const vite_internal_options_defer = new Promise((resolve)=>{
|
|
242
|
+
resolve_vite_internal_options = resolve;
|
|
243
|
+
});
|
|
244
|
+
let cachedSpecifier;
|
|
245
|
+
let entrypoint;
|
|
246
|
+
const configureModuleFederationRuntime = (config)=>preservesLockedArtifactPaths ? config : (0, ensure_runtime_plugin_js_namespaceObject.ensureRuntimePlugin)(config);
|
|
247
|
+
const mfConfigSources = toModuleFederationConfigArray(options.mfConfig).map(configureModuleFederationRuntime);
|
|
248
|
+
const ownedConfigIdentities = new Set(mfConfigSources.flatMap((config)=>(0, federation_metadata_js_namespaceObject.getConfigIdentities)(config)));
|
|
249
|
+
let environmentNames = [];
|
|
250
|
+
let environmentMetadata = new Map();
|
|
251
|
+
let sharedOutputRoot;
|
|
252
|
+
let isWatchMode = false;
|
|
253
|
+
let buildGeneration = 0;
|
|
254
|
+
let applicationContext;
|
|
255
|
+
let uploadMetadata;
|
|
256
|
+
let baseHref = '';
|
|
257
|
+
let isApplicationBuild = false;
|
|
258
|
+
let unsupportedVite6Builder = false;
|
|
259
|
+
let directOutputs = [];
|
|
260
|
+
let directBuildFailed = false;
|
|
261
|
+
let directSsr = false;
|
|
262
|
+
let expectedDirectOutputs = 1;
|
|
263
|
+
let buildManifest;
|
|
264
|
+
let hasLaterWriteHook = false;
|
|
265
|
+
let hasLaterCloseHook = false;
|
|
266
|
+
let hasLaterOutputOptionsHook = false;
|
|
267
|
+
const instantiatedEnvironments = new Set();
|
|
268
|
+
let environmentBuildStarted = false;
|
|
269
|
+
const buildAppStart = {
|
|
270
|
+
name: 'with-zephyr:build-app-start',
|
|
271
|
+
enforce: 'pre',
|
|
272
|
+
sharedDuringBuild: true,
|
|
273
|
+
buildApp: {
|
|
274
|
+
order: 'pre',
|
|
275
|
+
async handler () {
|
|
276
|
+
isApplicationBuild = true;
|
|
217
277
|
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const registerModuleFederationConfigs = (configs)=>{
|
|
281
|
+
for (const config of configs){
|
|
282
|
+
const identities = (0, federation_metadata_js_namespaceObject.getConfigIdentities)(config);
|
|
283
|
+
if (identities.some((identity)=>ownedConfigIdentities.has(identity))) continue;
|
|
284
|
+
const runtimeConfigured = configureModuleFederationRuntime(config);
|
|
285
|
+
if (!mfConfigSources.includes(runtimeConfigured)) {
|
|
286
|
+
mfConfigSources.push(runtimeConfigured);
|
|
287
|
+
for (const identity of (0, federation_metadata_js_namespaceObject.getConfigIdentities)(runtimeConfigured))ownedConfigIdentities.add(identity);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
const getModuleFederationPublicationMetadata = ()=>(0, federation_metadata_js_namespaceObject.createViteModuleFederationPublicationMetadata)(mfConfigSources);
|
|
292
|
+
const publishDirectOutputs = async (outputs)=>{
|
|
293
|
+
const partialClaims = [];
|
|
294
|
+
const zephyrEngine = await zephyr_engine_defer;
|
|
222
295
|
try {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
296
|
+
const outputRoot = commonDirectory(outputs.map((output)=>output.directory));
|
|
297
|
+
if (!outputRoot) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
298
|
+
message: 'Could not determine a shared output root for the Vite build.'
|
|
299
|
+
});
|
|
300
|
+
const serverEntries = new Set();
|
|
301
|
+
const maps = outputs.map((output)=>{
|
|
302
|
+
const prefix = preservesLockedArtifactPaths ? void 0 : external_node_path_namespaceObject.relative(outputRoot, output.directory).split(external_node_path_namespaceObject.sep).join('/');
|
|
303
|
+
for (const entry of output.entrypoints)serverEntries.add(prefix ? `${prefix}/${entry}` : entry);
|
|
304
|
+
return prefixAssetsMap(output.assetsMap, prefix);
|
|
305
|
+
});
|
|
306
|
+
let assetsMap = 1 === maps.length ? maps[0] : mergeAssetMaps(maps);
|
|
307
|
+
if (!isWatchMode && externalPartialScope) {
|
|
308
|
+
const batch = await (0, external_zephyr_agent_namespaceObject.claimPartialAssetMapBatch)(zephyrEngine.application_uid, [
|
|
309
|
+
externalPartialScope
|
|
310
|
+
]);
|
|
311
|
+
if (!batch) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
312
|
+
message: 'Vite partialBuild was configured, but its external partial output was unavailable or already claimed.'
|
|
313
|
+
});
|
|
314
|
+
partialClaims.push(...batch.claims);
|
|
315
|
+
assetsMap = mergeAssetMaps([
|
|
316
|
+
...Object.values(mergeClaimedPartialMaps(partialClaims)),
|
|
317
|
+
assetsMap
|
|
318
|
+
]);
|
|
319
|
+
}
|
|
320
|
+
const snapshotType = options.snapshotType ?? (!preservesLockedArtifactPaths && outputs.some((output)=>output.ssr) ? 'ssr' : 'csr');
|
|
321
|
+
const finalEntrypoint = 'ssr' === snapshotType ? options.entrypoint ? normalizeEntrypoint(options.entrypoint) : 1 === serverEntries.size ? [
|
|
322
|
+
...serverEntries
|
|
323
|
+
][0] : void 0 : preservesLockedArtifactPaths ? void 0 : entrypoint;
|
|
324
|
+
if ('ssr' === snapshotType && (!finalEntrypoint || !Object.values(assetsMap).some((asset)=>asset.path === finalEntrypoint))) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
325
|
+
message: 'Could not identify an emitted Vite server entrypoint. Set withZephyr({ entrypoint }) to an emitted server chunk.'
|
|
326
|
+
});
|
|
327
|
+
if (!zephyrEngine.hasActiveBuild) await zephyrEngine.start_new_build();
|
|
328
|
+
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
329
|
+
await zephyrEngine.upload_assets({
|
|
330
|
+
assetsMap,
|
|
331
|
+
buildStats: attachViteFederationBuildStats(await (0, external_zephyr_agent_namespaceObject.zeBuildDashData)(zephyrEngine), federationMetadata),
|
|
332
|
+
mfConfig: federationMetadata.mfConfig,
|
|
333
|
+
mfConfigs: federationMetadata.mfConfigs,
|
|
334
|
+
hooks,
|
|
335
|
+
entrypoint: finalEntrypoint,
|
|
336
|
+
snapshotType
|
|
227
337
|
});
|
|
338
|
+
await zephyrEngine.build_finished();
|
|
339
|
+
await (0, external_zephyr_agent_namespaceObject.commitPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
340
|
+
} catch (error) {
|
|
341
|
+
zephyrEngine.build_failed();
|
|
342
|
+
if (partialClaims.length > 0) try {
|
|
343
|
+
await (0, external_zephyr_agent_namespaceObject.rollbackPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
344
|
+
} catch (rollbackError) {
|
|
345
|
+
(0, external_zephyr_agent_namespaceObject.logFn)('error', external_zephyr_agent_namespaceObject.ZephyrError.format(rollbackError));
|
|
346
|
+
}
|
|
347
|
+
throw error;
|
|
228
348
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
349
|
+
};
|
|
350
|
+
const plugin = {
|
|
351
|
+
name: 'with-zephyr',
|
|
352
|
+
sharedDuringBuild: true,
|
|
353
|
+
enforce: 'pre',
|
|
354
|
+
config: (config)=>{
|
|
355
|
+
registerModuleFederationConfigs((0, extract_mf_plugin_js_namespaceObject.extract_mf_plugins)(config.plugins ?? []).map((plugin)=>plugin._options));
|
|
356
|
+
return null;
|
|
357
|
+
},
|
|
358
|
+
configResolved: async (config)=>{
|
|
359
|
+
const vite = await import("vite");
|
|
360
|
+
const viteMajor = Number.parseInt(vite.version.split('.')[0] ?? '0', 10);
|
|
361
|
+
if (environmentBuildStarted) {
|
|
362
|
+
instantiatedEnvironments.clear();
|
|
363
|
+
environmentBuildStarted = false;
|
|
364
|
+
}
|
|
365
|
+
const createEnvironment = config.build?.createEnvironment;
|
|
366
|
+
if (createEnvironment) config.build.createEnvironment = function(name, environmentConfig) {
|
|
367
|
+
const environment = createEnvironment.call(this, name, environmentConfig);
|
|
368
|
+
instantiatedEnvironments.add(name);
|
|
369
|
+
return environment;
|
|
370
|
+
};
|
|
371
|
+
isApplicationBuild = false;
|
|
372
|
+
directOutputs = [];
|
|
373
|
+
directBuildFailed = false;
|
|
374
|
+
buildManifest = void 0;
|
|
375
|
+
directSsr = Boolean(config.build?.ssr);
|
|
376
|
+
const configuredOutput = config.build?.rolldownOptions?.output ?? config.build?.rollupOptions?.output;
|
|
377
|
+
expectedDirectOutputs = Array.isArray(configuredOutput) ? configuredOutput.length : config.build?.lib ? config.build.lib.formats?.length ?? 2 : 1;
|
|
378
|
+
const firstBuildAppPlugin = config.getSortedPlugins?.('buildApp')[0];
|
|
379
|
+
if (viteMajor >= 7 && firstBuildAppPlugin && firstBuildAppPlugin !== buildAppStart) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
380
|
+
message: 'Place withZephyr() before other pre-ordered buildApp plugins so Zephyr can collect application output atomically.'
|
|
381
|
+
});
|
|
382
|
+
const writePlugins = config.getSortedPlugins?.('writeBundle');
|
|
383
|
+
hasLaterWriteHook = Boolean(writePlugins?.length && writePlugins.at(-1) !== plugin);
|
|
384
|
+
const closePlugins = config.getSortedPlugins?.('closeBundle');
|
|
385
|
+
hasLaterCloseHook = Boolean(closePlugins?.length && closePlugins.at(-1) !== plugin);
|
|
386
|
+
const outputOptionPlugins = config.getSortedPlugins?.('outputOptions');
|
|
387
|
+
hasLaterOutputOptionsHook = Boolean(outputOptionPlugins?.length && outputOptionPlugins.at(-1) !== plugin);
|
|
388
|
+
const root = config.root;
|
|
389
|
+
baseHref = (0, external_zephyr_agent_namespaceObject.normalizeBasePath)(config.base);
|
|
390
|
+
entrypoint = normalizeEntrypoint(options.entrypoint ?? (0, extract_entrypoint_js_namespaceObject.extractEntrypoint)(config));
|
|
391
|
+
isWatchMode = Boolean(config.build?.watch);
|
|
392
|
+
const configuredEnvironments = config.environments ?? {};
|
|
393
|
+
environmentNames = Object.keys(configuredEnvironments);
|
|
394
|
+
unsupportedVite6Builder = 6 === viteMajor && (Boolean(config.builder) || environmentNames.length > 1);
|
|
395
|
+
environmentMetadata = new Map(Object.entries(configuredEnvironments).map(([name, environment])=>[
|
|
396
|
+
name,
|
|
397
|
+
{
|
|
398
|
+
consumer: environment.consumer,
|
|
399
|
+
outputDir: environment.build?.outDir ? external_node_path_namespaceObject.resolve(root, environment.build.outDir) : void 0
|
|
400
|
+
}
|
|
401
|
+
]));
|
|
402
|
+
const outputDirectories = [
|
|
403
|
+
...environmentMetadata.values()
|
|
404
|
+
].map(({ outputDir })=>outputDir).filter((value)=>!!value);
|
|
405
|
+
sharedOutputRoot = preservesLockedArtifactPaths || outputDirectories.length !== environmentNames.length ? void 0 : commonDirectory(outputDirectories);
|
|
406
|
+
zephyr_defer_create({
|
|
407
|
+
builder: 'vite',
|
|
408
|
+
context: root,
|
|
409
|
+
target: options.target
|
|
410
|
+
});
|
|
411
|
+
resolve_vite_internal_options({
|
|
412
|
+
root,
|
|
413
|
+
outDir: config.build?.outDir,
|
|
414
|
+
publicDir: config.publicDir,
|
|
415
|
+
target: options.target
|
|
416
|
+
});
|
|
417
|
+
registerModuleFederationConfigs((0, extract_mf_plugin_js_namespaceObject.extract_mf_plugins)(config.plugins ?? []).map((plugin)=>plugin._options));
|
|
418
|
+
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
419
|
+
const mfConfigs = federationMetadata.mfConfigs ?? [];
|
|
420
|
+
if (mfConfigs.length > 0 && !preservesLockedArtifactPaths) try {
|
|
421
|
+
const dependencyPairs = [
|
|
422
|
+
...new Map(mfConfigs.flatMap((mfConfig)=>(0, extract_mf_vite_remotes_js_namespaceObject.extract_remotes_dependencies)(root, mfConfig) ?? []).map((dependency)=>[
|
|
423
|
+
`${dependency.name}:${dependency.version}`,
|
|
424
|
+
dependency
|
|
425
|
+
])).values()
|
|
426
|
+
];
|
|
427
|
+
if (dependencyPairs.length > 0) {
|
|
428
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
429
|
+
await zephyr_engine.resolve_remote_dependencies(dependencyPairs, DEFAULT_LIBRARY_TYPE);
|
|
430
|
+
external_zephyr_agent_namespaceObject.ze_log.remotes(`Resolved ${dependencyPairs.length} remote dependencies in configResolved`);
|
|
267
431
|
}
|
|
432
|
+
} catch (error) {
|
|
433
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
268
434
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
435
|
+
try {
|
|
436
|
+
const loaded = vite.loadEnv(config.mode || 'production', root, '');
|
|
437
|
+
for (const [k, v] of Object.entries(loaded))if (k.startsWith('ZE_PUBLIC_') && 'string' == typeof v && !(k in process.env)) process.env[k] = v;
|
|
438
|
+
} catch {}
|
|
439
|
+
},
|
|
440
|
+
resolveId: async (source)=>{
|
|
441
|
+
if (source === ensure_runtime_plugin_js_namespaceObject.ZEPHYR_MF_RUNTIME_PLUGIN_ID) return ensure_runtime_plugin_js_namespaceObject.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID;
|
|
442
|
+
try {
|
|
443
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
444
|
+
if (!cachedSpecifier) cachedSpecifier = `env:vars:${zephyr_engine.application_uid}`;
|
|
445
|
+
if (source === cachedSpecifier) {
|
|
446
|
+
if ('development' === process.env['NODE_ENV']) return '/zephyr-manifest.json';
|
|
447
|
+
return {
|
|
448
|
+
id: source,
|
|
449
|
+
external: true
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
} catch {}
|
|
453
|
+
return null;
|
|
454
|
+
},
|
|
455
|
+
load: async (id)=>{
|
|
456
|
+
if (id === ensure_runtime_plugin_js_namespaceObject.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID) return (0, promises_namespaceObject.readFile)((0, ensure_runtime_plugin_js_namespaceObject.getRuntimePluginPath)(), 'utf8');
|
|
457
|
+
return null;
|
|
458
|
+
},
|
|
459
|
+
transform: {
|
|
460
|
+
order: 'post',
|
|
461
|
+
filter: {
|
|
462
|
+
id: /\.(mjs|cjs|js|ts|jsx|tsx)/
|
|
277
463
|
},
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
baseHref = (0, external_zephyr_agent_namespaceObject.normalizeBasePath)(config.base);
|
|
283
|
-
entrypoint = normalizeEntrypoint(options.entrypoint ?? (0, extract_entrypoint_js_namespaceObject.extractEntrypoint)(config));
|
|
284
|
-
isWatchMode = Boolean(config.build?.watch);
|
|
285
|
-
const configuredEnvironments = config.environments ?? {};
|
|
286
|
-
environmentNames = Object.keys(configuredEnvironments);
|
|
287
|
-
environmentMetadata = new Map(Object.entries(configuredEnvironments).map(([name, environment])=>[
|
|
288
|
-
name,
|
|
289
|
-
{
|
|
290
|
-
consumer: environment.consumer,
|
|
291
|
-
outputDir: environment.build?.outDir ? external_node_path_namespaceObject.resolve(root, environment.build.outDir) : void 0
|
|
292
|
-
}
|
|
293
|
-
]));
|
|
294
|
-
const outputDirectories = [
|
|
295
|
-
...environmentMetadata.values()
|
|
296
|
-
].map(({ outputDir })=>outputDir).filter((value)=>!!value);
|
|
297
|
-
sharedOutputRoot = preservesLockedArtifactPaths || outputDirectories.length !== environmentNames.length ? void 0 : commonDirectory(outputDirectories);
|
|
298
|
-
zephyr_defer_create({
|
|
299
|
-
builder: 'vite',
|
|
300
|
-
context: root,
|
|
301
|
-
target: options.target
|
|
302
|
-
});
|
|
303
|
-
resolve_vite_internal_options({
|
|
304
|
-
root,
|
|
305
|
-
outDir: config.build?.outDir,
|
|
306
|
-
publicDir: config.publicDir,
|
|
307
|
-
target: options.target
|
|
308
|
-
});
|
|
309
|
-
registerModuleFederationConfigs((0, extract_mf_plugin_js_namespaceObject.extract_mf_plugins)(config.plugins ?? []).map((plugin)=>plugin._options));
|
|
310
|
-
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
311
|
-
const mfConfigs = federationMetadata.mfConfigs ?? [];
|
|
312
|
-
if (mfConfigs.length > 0 && !preservesLockedArtifactPaths) try {
|
|
313
|
-
const dependencyPairs = [
|
|
314
|
-
...new Map(mfConfigs.flatMap((mfConfig)=>(0, extract_mf_vite_remotes_js_namespaceObject.extract_remotes_dependencies)(root, mfConfig) ?? []).map((dependency)=>[
|
|
315
|
-
`${dependency.name}:${dependency.version}`,
|
|
316
|
-
dependency
|
|
317
|
-
])).values()
|
|
318
|
-
];
|
|
319
|
-
if (dependencyPairs.length > 0) {
|
|
464
|
+
handler: async (code, id)=>{
|
|
465
|
+
if (preservesLockedArtifactPaths) return null;
|
|
466
|
+
try {
|
|
467
|
+
if (!id.includes('node_modules')) {
|
|
320
468
|
const zephyr_engine = await zephyr_engine_defer;
|
|
321
|
-
|
|
322
|
-
|
|
469
|
+
if (!cachedSpecifier) cachedSpecifier = `env:vars:${zephyr_engine.application_uid}`;
|
|
470
|
+
const res = (0, external_zephyr_agent_namespaceObject.rewriteEnvReadsToVirtualModule)(String(code), cachedSpecifier);
|
|
471
|
+
if (res && 'string' == typeof res.code && res.code !== code) {
|
|
472
|
+
code = res.code;
|
|
473
|
+
return {
|
|
474
|
+
code,
|
|
475
|
+
map: new (external_magic_string_default())(code).generateMap({
|
|
476
|
+
hires: true
|
|
477
|
+
})
|
|
478
|
+
};
|
|
479
|
+
}
|
|
323
480
|
}
|
|
481
|
+
return null;
|
|
324
482
|
} catch (error) {
|
|
325
483
|
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
484
|
+
return null;
|
|
326
485
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
renderChunk: {
|
|
489
|
+
order: 'post',
|
|
490
|
+
handler (code) {
|
|
491
|
+
if (preservesLockedArtifactPaths || !cachedSpecifier) return null;
|
|
492
|
+
const importWithoutAttribute = new RegExp(`import\\s+([^\\s]+)\\s+from\\s*['"]${cachedSpecifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, 'g');
|
|
493
|
+
const nextCode = code.replace(importWithoutAttribute, `import $1 from '${cachedSpecifier}' with { type: 'json' }`);
|
|
494
|
+
return nextCode === code ? null : {
|
|
495
|
+
code: nextCode,
|
|
496
|
+
map: null
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
generateBundle: async function() {
|
|
501
|
+
if (preservesLockedArtifactPaths) return;
|
|
502
|
+
try {
|
|
503
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
504
|
+
const dependencies = zephyr_engine.federated_dependencies || [];
|
|
505
|
+
const manifestContent = isApplicationBuild || isWatchMode ? (0, external_zephyr_agent_namespaceObject.createManifestContent)(dependencies, true) : buildManifest ??= (0, external_zephyr_agent_namespaceObject.createManifestContent)(dependencies, true);
|
|
506
|
+
this.emitFile({
|
|
507
|
+
type: 'asset',
|
|
508
|
+
fileName: 'zephyr-manifest.json',
|
|
509
|
+
source: manifestContent
|
|
510
|
+
});
|
|
511
|
+
} catch (error) {
|
|
512
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
513
|
+
this.emitFile({
|
|
514
|
+
type: 'asset',
|
|
515
|
+
fileName: 'zephyr-manifest.json',
|
|
516
|
+
source: JSON.stringify({
|
|
517
|
+
version: '1.0.0',
|
|
518
|
+
timestamp: new Date().toISOString(),
|
|
519
|
+
dependencies: {},
|
|
520
|
+
zeVars: {}
|
|
521
|
+
}, null, 2)
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
},
|
|
525
|
+
configureServer: async (server)=>{
|
|
526
|
+
try {
|
|
527
|
+
const zephyr_engine = await zephyr_engine_defer;
|
|
528
|
+
if (!cachedSpecifier) cachedSpecifier = `env:vars:${zephyr_engine.application_uid}`;
|
|
529
|
+
server.middlewares.use((req, res, next)=>{
|
|
530
|
+
(async ()=>{
|
|
531
|
+
if (!req.url) return void next();
|
|
532
|
+
const requestUrl = req.url.split('?')[0];
|
|
533
|
+
if ('/zephyr-manifest.json' === requestUrl) try {
|
|
534
|
+
const dependencies = zephyr_engine.federated_dependencies || [];
|
|
535
|
+
const manifestContent = (0, external_zephyr_agent_namespaceObject.createManifestContent)(dependencies, true);
|
|
536
|
+
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
537
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
538
|
+
res.end(manifestContent);
|
|
539
|
+
return;
|
|
540
|
+
} catch (error) {
|
|
541
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
372
542
|
}
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
543
|
+
next();
|
|
544
|
+
})();
|
|
545
|
+
});
|
|
546
|
+
} catch {}
|
|
547
|
+
},
|
|
548
|
+
outputOptions: {
|
|
549
|
+
order: 'post',
|
|
550
|
+
handler (output) {
|
|
551
|
+
if (!isApplicationBuild && !isWatchMode && (hasLaterOutputOptionsHook || hasLateOutputHook(output.plugins))) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
552
|
+
message: 'Zephyr cannot verify post-ordered or asynchronous output-plugin writers. Use normal outputOptions and writeBundle ordering in synchronous output plugins.'
|
|
553
|
+
});
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
buildStart () {
|
|
558
|
+
environmentBuildStarted = true;
|
|
559
|
+
},
|
|
560
|
+
buildEnd (error) {
|
|
561
|
+
if (error) directBuildFailed = true;
|
|
562
|
+
},
|
|
563
|
+
renderError () {
|
|
564
|
+
directBuildFailed = true;
|
|
565
|
+
},
|
|
566
|
+
closeBundle: {
|
|
567
|
+
order: 'post',
|
|
568
|
+
sequential: true,
|
|
569
|
+
async handler () {
|
|
570
|
+
if (isApplicationBuild || isWatchMode || 0 === directOutputs.length) return;
|
|
571
|
+
const outputs = directOutputs;
|
|
572
|
+
directOutputs = [];
|
|
573
|
+
if (directBuildFailed || outputs.length !== expectedDirectOutputs) return;
|
|
394
574
|
try {
|
|
395
|
-
|
|
396
|
-
const dependencies = zephyr_engine.federated_dependencies || [];
|
|
397
|
-
const manifestContent = (0, external_zephyr_agent_namespaceObject.createManifestContent)(dependencies, true);
|
|
398
|
-
this.emitFile({
|
|
399
|
-
type: 'asset',
|
|
400
|
-
fileName: 'zephyr-manifest.json',
|
|
401
|
-
source: manifestContent
|
|
402
|
-
});
|
|
575
|
+
await publishDirectOutputs(outputs);
|
|
403
576
|
} catch (error) {
|
|
404
577
|
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
405
|
-
this.emitFile({
|
|
406
|
-
type: 'asset',
|
|
407
|
-
fileName: 'zephyr-manifest.json',
|
|
408
|
-
source: JSON.stringify({
|
|
409
|
-
version: '1.0.0',
|
|
410
|
-
timestamp: new Date().toISOString(),
|
|
411
|
-
dependencies: {},
|
|
412
|
-
zeVars: {}
|
|
413
|
-
}, null, 2)
|
|
414
|
-
});
|
|
415
578
|
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
(async ()=>{
|
|
423
|
-
if (!req.url) return void next();
|
|
424
|
-
const requestUrl = req.url.split('?')[0];
|
|
425
|
-
if ('/zephyr-manifest.json' === requestUrl) try {
|
|
426
|
-
const dependencies = zephyr_engine.federated_dependencies || [];
|
|
427
|
-
const manifestContent = (0, external_zephyr_agent_namespaceObject.createManifestContent)(dependencies, true);
|
|
428
|
-
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
429
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
430
|
-
res.end(manifestContent);
|
|
431
|
-
return;
|
|
432
|
-
} catch (error) {
|
|
433
|
-
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
434
|
-
}
|
|
435
|
-
next();
|
|
436
|
-
})();
|
|
437
|
-
});
|
|
438
|
-
} catch {}
|
|
439
|
-
},
|
|
440
|
-
writeBundle: async function(outputOptions, bundle) {
|
|
441
|
-
const partialClaims = [];
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
writeBundle: {
|
|
582
|
+
order: 'post',
|
|
583
|
+
sequential: true,
|
|
584
|
+
async handler (outputOptions, bundle) {
|
|
442
585
|
try {
|
|
443
586
|
const [vite_internal_options, zephyr_engine] = await Promise.all([
|
|
444
587
|
vite_internal_options_defer,
|
|
@@ -447,6 +590,9 @@ var __webpack_exports__ = {};
|
|
|
447
590
|
zephyr_engine.buildProperties.baseHref = baseHref;
|
|
448
591
|
const environmentName = this.environment?.name;
|
|
449
592
|
const isMultiEnvironment = environmentNames.length > 1;
|
|
593
|
+
if (!isWatchMode && unsupportedVite6Builder) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
594
|
+
message: 'Vite 6 application-builder publication requires Vite 7 or newer. Vite 6 supports only single-environment builds without a builder configuration.'
|
|
595
|
+
});
|
|
450
596
|
if (isWatchMode && isMultiEnvironment) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
451
597
|
message: "Vite multi-environment watch publication is not supported because environment rebuilds do not expose an atomic application generation."
|
|
452
598
|
});
|
|
@@ -454,7 +600,13 @@ var __webpack_exports__ = {};
|
|
|
454
600
|
const resolvedEnvironmentName = environmentName ?? [
|
|
455
601
|
...environmentMetadata.entries()
|
|
456
602
|
].find(([, metadata])=>metadata.outputDir === outputDirectory)?.[0] ?? (1 === environmentNames.length ? environmentNames[0] : void 0);
|
|
457
|
-
const coordinateWithBuildApp =
|
|
603
|
+
const coordinateWithBuildApp = isApplicationBuild && !isWatchMode;
|
|
604
|
+
if (!coordinateWithBuildApp && instantiatedEnvironments.size > 1) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
605
|
+
message: 'Use builder.buildApp() to publish multiple Vite environments atomically; individual builder.build(environment) calls cannot finalize the application.'
|
|
606
|
+
});
|
|
607
|
+
if (!coordinateWithBuildApp && !isWatchMode && (hasLaterWriteHook || hasLaterCloseHook)) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
608
|
+
message: 'Zephyr must be the last writeBundle and closeBundle hook. Use normal hook ordering for other plugins so publication cannot precede a failed build.'
|
|
609
|
+
});
|
|
458
610
|
if (coordinateWithBuildApp && !resolvedEnvironmentName) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
459
611
|
message: `Could not associate Vite output directory "${outputDirectory}" with an environment.`
|
|
460
612
|
});
|
|
@@ -476,7 +628,7 @@ var __webpack_exports__ = {};
|
|
|
476
628
|
assets: bundle,
|
|
477
629
|
publicDir: isMultiEnvironment && resolvedEnvironmentName && environmentMetadata.get(resolvedEnvironmentName)?.consumer === 'server' ? void 0 : vite_internal_options.publicDir
|
|
478
630
|
};
|
|
479
|
-
|
|
631
|
+
const assetsMap = await (0, extract_vite_assets_map_js_namespaceObject.extract_vite_assets_map)(zephyr_engine, extractionOptions);
|
|
480
632
|
if (coordinateWithBuildApp) {
|
|
481
633
|
if (!resolvedEnvironmentName) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
482
634
|
message: `Could not associate Vite output directory "${outputDirectory}" with an environment.`
|
|
@@ -488,203 +640,187 @@ var __webpack_exports__ = {};
|
|
|
488
640
|
});
|
|
489
641
|
return;
|
|
490
642
|
}
|
|
491
|
-
|
|
492
|
-
const batch = await (0, external_zephyr_agent_namespaceObject.claimPartialAssetMapBatch)(zephyr_engine.application_uid, [
|
|
493
|
-
externalPartialScope
|
|
494
|
-
]);
|
|
495
|
-
if (!batch) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
496
|
-
message: 'Vite partialBuild was configured, but its external partial output was unavailable or already claimed.'
|
|
497
|
-
});
|
|
498
|
-
partialClaims.push(...batch.claims);
|
|
499
|
-
const partials = mergeClaimedPartialMaps(partialClaims);
|
|
500
|
-
assetsMap = mergeAssetMaps([
|
|
501
|
-
...Object.values(partials),
|
|
502
|
-
assetsMap
|
|
503
|
-
]);
|
|
504
|
-
}
|
|
505
|
-
if (!zephyr_engine.hasActiveBuild) await zephyr_engine.start_new_build();
|
|
506
|
-
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
507
|
-
await zephyr_engine.upload_assets({
|
|
643
|
+
const output = {
|
|
508
644
|
assetsMap,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
645
|
+
directory: outputDirectory,
|
|
646
|
+
entrypoints: Object.values(bundle).flatMap((asset)=>'chunk' === asset.type && asset.isEntry ? [
|
|
647
|
+
asset.fileName
|
|
648
|
+
] : []),
|
|
649
|
+
ssr: directSsr || void 0 !== resolvedEnvironmentName && environmentMetadata.get(resolvedEnvironmentName)?.consumer === 'server'
|
|
650
|
+
};
|
|
651
|
+
if (isWatchMode) await publishDirectOutputs([
|
|
652
|
+
output
|
|
653
|
+
]);
|
|
654
|
+
else directOutputs.push(output);
|
|
518
655
|
} catch (error) {
|
|
656
|
+
directBuildFailed = true;
|
|
519
657
|
try {
|
|
520
658
|
const zephyr_engine = await zephyr_engine_defer;
|
|
521
659
|
zephyr_engine.build_failed();
|
|
522
660
|
} catch {}
|
|
523
|
-
if (partialClaims.length > 0) try {
|
|
524
|
-
const zephyr_engine = await zephyr_engine_defer;
|
|
525
|
-
await (0, external_zephyr_agent_namespaceObject.rollbackPartialAssetMapClaimBatch)(zephyr_engine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
526
|
-
} catch (restoreError) {
|
|
527
|
-
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(restoreError);
|
|
528
|
-
}
|
|
529
661
|
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
530
662
|
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
if (0 === environments.length) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
544
|
-
message: 'Vite exposed no build environments for Zephyr publication.'
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
buildApp: {
|
|
666
|
+
order: 'post',
|
|
667
|
+
async handler (builder) {
|
|
668
|
+
isApplicationBuild = true;
|
|
669
|
+
const environments = Object.entries(builder.environments);
|
|
670
|
+
if (isWatchMode) {
|
|
671
|
+
if (environments.length > 1) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
672
|
+
message: "Vite multi-environment watch publication is not supported because environment rebuilds do not expose an atomic application generation."
|
|
545
673
|
});
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
if (0 === environments.length) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
677
|
+
message: 'Vite exposed no build environments for Zephyr publication.'
|
|
678
|
+
});
|
|
679
|
+
let incomplete = environments.filter(([, environment])=>!environment.isBuilt).map(([name])=>name);
|
|
680
|
+
if (incomplete.length === environments.length) {
|
|
681
|
+
for (const [, environment] of environments)await builder.build(environment);
|
|
682
|
+
incomplete = environments.filter(([, environment])=>!environment.isBuilt).map(([name])=>name);
|
|
683
|
+
}
|
|
684
|
+
if (incomplete.length > 0) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
685
|
+
message: `Vite completed without these environments: ${incomplete.join(', ')}. Zephyr will not publish partial compiler output.`
|
|
686
|
+
});
|
|
687
|
+
const partialClaims = [];
|
|
688
|
+
const generation = buildGeneration++;
|
|
689
|
+
try {
|
|
690
|
+
const zephyrEngine = await zephyr_engine_defer;
|
|
691
|
+
zephyrEngine.buildProperties.baseHref = baseHref;
|
|
692
|
+
const claimScopes = [
|
|
693
|
+
{
|
|
694
|
+
invocationId: buildInvocationId,
|
|
695
|
+
generation
|
|
696
|
+
},
|
|
697
|
+
...externalPartialScope ? [
|
|
698
|
+
externalPartialScope
|
|
699
|
+
] : []
|
|
700
|
+
];
|
|
701
|
+
const batch = await (0, external_zephyr_agent_namespaceObject.claimPartialAssetMapBatch)(zephyrEngine.application_uid, claimScopes);
|
|
702
|
+
if (!batch) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
703
|
+
message: externalPartialScope ? 'Vite could not atomically claim both environment and configured external partial output.' : 'Vite environment output was unavailable or already claimed.'
|
|
704
|
+
});
|
|
705
|
+
partialClaims.push(...batch.claims);
|
|
706
|
+
const claimedPartials = mergeClaimedPartialMaps(partialClaims);
|
|
707
|
+
if (0 === Object.keys(claimedPartials).length) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
708
|
+
message: 'Vite produced no environment assets for Zephyr publication.'
|
|
709
|
+
});
|
|
710
|
+
const expectedEnvironmentNames = new Set(environments.map(([name])=>name));
|
|
711
|
+
const environmentOutputCounts = new Map(environments.map(([name])=>[
|
|
712
|
+
name,
|
|
713
|
+
0
|
|
714
|
+
]));
|
|
715
|
+
const unexpectedEnvironmentOutputs = [];
|
|
716
|
+
for (const key of Object.keys(claimedPartials)){
|
|
717
|
+
if (!key.startsWith(VITE_ENVIRONMENT_OUTPUT_PREFIX)) continue;
|
|
718
|
+
const environmentName = parseViteEnvironmentOutputName(key);
|
|
719
|
+
if (!environmentName || !expectedEnvironmentNames.has(environmentName)) {
|
|
720
|
+
unexpectedEnvironmentOutputs.push(key);
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
environmentOutputCounts.set(environmentName, (environmentOutputCounts.get(environmentName) ?? 0) + 1);
|
|
550
724
|
}
|
|
551
|
-
|
|
552
|
-
|
|
725
|
+
const missingEnvironmentOutputs = environments.map(([name])=>name).filter((name)=>0 === environmentOutputCounts.get(name)).map(viteEnvironmentOutputPrefix);
|
|
726
|
+
if (missingEnvironmentOutputs.length > 0) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
727
|
+
message: `Vite did not produce Zephyr output for: ${missingEnvironmentOutputs.join(', ')}`
|
|
553
728
|
});
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
729
|
+
if (unexpectedEnvironmentOutputs.length > 0) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
730
|
+
message: 'Vite found stale or unexpected environment output for: ' + unexpectedEnvironmentOutputs.join(', ')
|
|
731
|
+
});
|
|
732
|
+
const serverEnvironmentNames = environments.filter(([name, environment])=>environment.config?.consumer === 'server' || environmentMetadata.get(name)?.consumer === 'server').map(([name])=>name);
|
|
733
|
+
const inferredSsr = serverEnvironmentNames.length > 0;
|
|
734
|
+
const snapshotType = options.snapshotType ?? (!preservesLockedArtifactPaths && inferredSsr ? 'ssr' : 'csr');
|
|
735
|
+
const finalEntrypoint = 'ssr' === snapshotType ? inferServerEntrypoint(claimedPartials, options.entrypoint, serverEnvironmentNames) : preservesLockedArtifactPaths ? void 0 : options.entrypoint ?? entrypoint;
|
|
736
|
+
if ('ssr' === snapshotType && !finalEntrypoint) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
737
|
+
message: 'Could not infer a Vite server entrypoint. Set withZephyr({ entrypoint }).'
|
|
738
|
+
});
|
|
739
|
+
if ('ssr' === snapshotType && finalEntrypoint && !Object.values(claimedPartials).some((assetsMap)=>Object.values(assetsMap).some((asset)=>asset.path === finalEntrypoint))) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
740
|
+
message: `Vite server entrypoint "${finalEntrypoint}" was not emitted in the coordinated snapshot.`
|
|
741
|
+
});
|
|
742
|
+
uploadMetadata = {
|
|
743
|
+
snapshotType,
|
|
744
|
+
entrypoint: finalEntrypoint
|
|
745
|
+
};
|
|
746
|
+
applicationContext ??= new external_zephyr_agent_namespaceObject.ApplicationContext({
|
|
747
|
+
applicationUid: zephyrEngine.application_uid,
|
|
748
|
+
prepare: ()=>zephyrEngine.hasActiveBuild ? void 0 : zephyrEngine.start_new_build(),
|
|
749
|
+
publish: async ({ assetsMap })=>{
|
|
750
|
+
if (!uploadMetadata) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
751
|
+
message: 'Vite upload metadata was not prepared.'
|
|
752
|
+
});
|
|
753
|
+
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
754
|
+
await zephyrEngine.upload_assets({
|
|
755
|
+
assetsMap,
|
|
756
|
+
buildStats: attachViteFederationBuildStats(await (0, external_zephyr_agent_namespaceObject.zeBuildDashData)(zephyrEngine), federationMetadata),
|
|
757
|
+
mfConfig: federationMetadata.mfConfig,
|
|
758
|
+
mfConfigs: federationMetadata.mfConfigs,
|
|
759
|
+
hooks,
|
|
760
|
+
snapshotType: uploadMetadata.snapshotType,
|
|
761
|
+
entrypoint: uploadMetadata.entrypoint
|
|
762
|
+
});
|
|
763
|
+
},
|
|
764
|
+
finish: ()=>zephyrEngine.build_finished(),
|
|
765
|
+
onFailure: ()=>zephyrEngine.build_failed()
|
|
766
|
+
});
|
|
767
|
+
const outputParticipant = uniqueParticipant('vite-output', environments.map(([name])=>name));
|
|
768
|
+
const session = applicationContext.beginBuild({
|
|
769
|
+
invocationId: `${buildInvocationId}:${generation}`,
|
|
770
|
+
generation,
|
|
771
|
+
participants: [
|
|
772
|
+
...environments.map(([name, environment])=>({
|
|
773
|
+
name,
|
|
774
|
+
role: environment.config?.consumer ?? environmentMetadata.get(name)?.consumer ?? name
|
|
775
|
+
})),
|
|
560
776
|
{
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
},
|
|
564
|
-
...externalPartialScope ? [
|
|
565
|
-
externalPartialScope
|
|
566
|
-
] : []
|
|
567
|
-
];
|
|
568
|
-
const batch = await (0, external_zephyr_agent_namespaceObject.claimPartialAssetMapBatch)(zephyrEngine.application_uid, claimScopes);
|
|
569
|
-
if (!batch) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
570
|
-
message: externalPartialScope ? 'Vite could not atomically claim both environment and configured external partial output.' : 'Vite environment output was unavailable or already claimed.'
|
|
571
|
-
});
|
|
572
|
-
partialClaims.push(...batch.claims);
|
|
573
|
-
const claimedPartials = mergeClaimedPartialMaps(partialClaims);
|
|
574
|
-
if (0 === Object.keys(claimedPartials).length) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
575
|
-
message: 'Vite produced no environment assets for Zephyr publication.'
|
|
576
|
-
});
|
|
577
|
-
const expectedEnvironmentNames = new Set(environments.map(([name])=>name));
|
|
578
|
-
const environmentOutputCounts = new Map(environments.map(([name])=>[
|
|
579
|
-
name,
|
|
580
|
-
0
|
|
581
|
-
]));
|
|
582
|
-
const unexpectedEnvironmentOutputs = [];
|
|
583
|
-
for (const key of Object.keys(claimedPartials)){
|
|
584
|
-
if (!key.startsWith(VITE_ENVIRONMENT_OUTPUT_PREFIX)) continue;
|
|
585
|
-
const environmentName = parseViteEnvironmentOutputName(key);
|
|
586
|
-
if (!environmentName || !expectedEnvironmentNames.has(environmentName)) {
|
|
587
|
-
unexpectedEnvironmentOutputs.push(key);
|
|
588
|
-
continue;
|
|
777
|
+
name: outputParticipant,
|
|
778
|
+
role: snapshotType
|
|
589
779
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
entrypoint: finalEntrypoint
|
|
612
|
-
};
|
|
613
|
-
applicationContext ??= new external_zephyr_agent_namespaceObject.ApplicationContext({
|
|
614
|
-
applicationUid: zephyrEngine.application_uid,
|
|
615
|
-
prepare: ()=>zephyrEngine.hasActiveBuild ? void 0 : zephyrEngine.start_new_build(),
|
|
616
|
-
publish: async ({ assetsMap })=>{
|
|
617
|
-
if (!uploadMetadata) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
|
|
618
|
-
message: 'Vite upload metadata was not prepared.'
|
|
619
|
-
});
|
|
620
|
-
const federationMetadata = getModuleFederationPublicationMetadata();
|
|
621
|
-
await zephyrEngine.upload_assets({
|
|
622
|
-
assetsMap,
|
|
623
|
-
buildStats: attachViteFederationBuildStats(await (0, external_zephyr_agent_namespaceObject.zeBuildDashData)(zephyrEngine), federationMetadata),
|
|
624
|
-
mfConfig: federationMetadata.mfConfig,
|
|
625
|
-
mfConfigs: federationMetadata.mfConfigs,
|
|
626
|
-
hooks,
|
|
627
|
-
snapshotType: uploadMetadata.snapshotType,
|
|
628
|
-
entrypoint: uploadMetadata.entrypoint
|
|
629
|
-
});
|
|
630
|
-
},
|
|
631
|
-
finish: ()=>zephyrEngine.build_finished(),
|
|
632
|
-
onFailure: ()=>zephyrEngine.build_failed()
|
|
633
|
-
});
|
|
634
|
-
const outputParticipant = uniqueParticipant('vite-output', environments.map(([name])=>name));
|
|
635
|
-
const session = applicationContext.beginBuild({
|
|
636
|
-
invocationId: `${buildInvocationId}:${generation}`,
|
|
637
|
-
generation,
|
|
638
|
-
participants: [
|
|
639
|
-
...environments.map(([name, environment])=>({
|
|
640
|
-
name,
|
|
641
|
-
role: environment.config?.consumer ?? environmentMetadata.get(name)?.consumer ?? name
|
|
642
|
-
})),
|
|
643
|
-
{
|
|
644
|
-
name: outputParticipant,
|
|
645
|
-
role: snapshotType
|
|
646
|
-
}
|
|
647
|
-
]
|
|
648
|
-
});
|
|
649
|
-
for (const [name] of environments)session.completeParticipant(name);
|
|
650
|
-
for (const [key, assetsMap] of Object.entries(claimedPartials))session.contribute({
|
|
651
|
-
participant: outputParticipant,
|
|
652
|
-
key,
|
|
653
|
-
assetsMap
|
|
654
|
-
});
|
|
655
|
-
session.completeParticipant(outputParticipant);
|
|
656
|
-
await session.publish();
|
|
657
|
-
await (0, external_zephyr_agent_namespaceObject.commitPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
658
|
-
} catch (error) {
|
|
659
|
-
try {
|
|
660
|
-
const zephyrEngine = await zephyr_engine_defer;
|
|
661
|
-
zephyrEngine.build_failed();
|
|
662
|
-
} catch {}
|
|
663
|
-
if (partialClaims.length > 0) try {
|
|
664
|
-
const zephyrEngine = await zephyr_engine_defer;
|
|
665
|
-
await (0, external_zephyr_agent_namespaceObject.rollbackPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
666
|
-
} catch (restoreError) {
|
|
667
|
-
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(restoreError);
|
|
668
|
-
}
|
|
669
|
-
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
780
|
+
]
|
|
781
|
+
});
|
|
782
|
+
for (const [name] of environments)session.completeParticipant(name);
|
|
783
|
+
for (const [key, assetsMap] of Object.entries(claimedPartials))session.contribute({
|
|
784
|
+
participant: outputParticipant,
|
|
785
|
+
key,
|
|
786
|
+
assetsMap
|
|
787
|
+
});
|
|
788
|
+
session.completeParticipant(outputParticipant);
|
|
789
|
+
await session.publish();
|
|
790
|
+
await (0, external_zephyr_agent_namespaceObject.commitPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
791
|
+
} catch (error) {
|
|
792
|
+
try {
|
|
793
|
+
const zephyrEngine = await zephyr_engine_defer;
|
|
794
|
+
zephyrEngine.build_failed();
|
|
795
|
+
} catch {}
|
|
796
|
+
if (partialClaims.length > 0) try {
|
|
797
|
+
const zephyrEngine = await zephyr_engine_defer;
|
|
798
|
+
await (0, external_zephyr_agent_namespaceObject.rollbackPartialAssetMapClaimBatch)(zephyrEngine.application_uid, partialClaims.map(({ claimId })=>claimId));
|
|
799
|
+
} catch (restoreError) {
|
|
800
|
+
(0, external_zephyr_agent_namespaceObject.logFn)('error', external_zephyr_agent_namespaceObject.ZephyrError.format(restoreError));
|
|
670
801
|
}
|
|
802
|
+
(0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
|
|
671
803
|
}
|
|
672
804
|
}
|
|
673
|
-
};
|
|
674
|
-
}
|
|
675
|
-
function withZephyr(options = {}) {
|
|
676
|
-
if (void 0 !== options.target) (0, external_zephyr_agent_namespaceObject.assertZephyrBuildTarget)(options.target, 'withZephyr({ target })');
|
|
677
|
-
const plugins = [];
|
|
678
|
-
const mfConfigs = toModuleFederationConfigArray(options.mfConfig);
|
|
679
|
-
if (mfConfigs.length > 0) {
|
|
680
|
-
const federation = loadModuleFederationPlugin();
|
|
681
|
-
const preservesLockedArtifactPaths = 'tap-app' === options.target;
|
|
682
|
-
for (const mfConfig of mfConfigs)plugins.push(...federation(preservesLockedArtifactPaths ? mfConfig : (0, ensure_runtime_plugin_js_namespaceObject.ensureRuntimePlugin)(mfConfig)));
|
|
683
805
|
}
|
|
684
|
-
|
|
685
|
-
|
|
806
|
+
};
|
|
807
|
+
return [
|
|
808
|
+
plugin,
|
|
809
|
+
buildAppStart
|
|
810
|
+
];
|
|
811
|
+
}
|
|
812
|
+
function withZephyr(options = {}) {
|
|
813
|
+
if (void 0 !== options.target) (0, external_zephyr_agent_namespaceObject.assertZephyrBuildTarget)(options.target, 'withZephyr({ target })');
|
|
814
|
+
const plugins = [];
|
|
815
|
+
const mfConfigs = toModuleFederationConfigArray(options.mfConfig);
|
|
816
|
+
if (mfConfigs.length > 0) {
|
|
817
|
+
const federation = loadModuleFederationPlugin();
|
|
818
|
+
const preservesLockedArtifactPaths = 'tap-app' === options.target;
|
|
819
|
+
for (const mfConfig of mfConfigs)plugins.push(...federation(preservesLockedArtifactPaths ? mfConfig : (0, ensure_runtime_plugin_js_namespaceObject.ensureRuntimePlugin)(mfConfig)));
|
|
686
820
|
}
|
|
687
|
-
|
|
821
|
+
plugins.push(...withZephyrCore(options));
|
|
822
|
+
return plugins;
|
|
823
|
+
}
|
|
688
824
|
exports.withZephyr = __webpack_exports__.withZephyr;
|
|
689
825
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
690
826
|
"withZephyr"
|