vite-plugin-zephyr 1.0.2 → 1.0.3-next.2
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/dist/lib/internal/mf-vite-etl/runtime_plugin.mjs +159 -23
- package/dist/lib/vite-plugin-zephyr.js +3 -44
- package/dist/lib/vite-plugin-zephyr.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/dist/lib/internal/mf-vite-etl/inject_resolved_remotes.d.ts +0 -13
- package/dist/lib/internal/mf-vite-etl/inject_resolved_remotes.js +0 -41
- package/dist/lib/internal/mf-vite-etl/inject_resolved_remotes.js.map +0 -1
|
@@ -1,40 +1,176 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Zephyr Runtime Plugin for Module Federation This file MUST
|
|
3
|
-
* format (.mjs) for Vite/Rollup compatibility
|
|
2
|
+
* Zephyr Runtime Plugin for Module Federation. This file MUST stay in ESM
|
|
3
|
+
* format (.mjs) for Vite/Rollup compatibility.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Keep this runtime logic aligned with the xpack runtime plugin at
|
|
6
|
+
* `libs/zephyr-xpack-internal/src/xpack-extract/runtime-plugin.ts`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* We intentionally duplicate logic in both plugins for now. Once zephyr-agent
|
|
9
|
+
* supports ESM runtime exports, we can move to a shared runtime
|
|
10
|
+
* implementation.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const globalCacheKey = '__ZEPHYR_MANIFEST_CACHE__';
|
|
14
|
+
const _global = typeof window !== 'undefined' ? window : globalThis;
|
|
15
|
+
|
|
16
|
+
function getGlobalManifestCache() {
|
|
17
|
+
if (!_global[globalCacheKey]) {
|
|
18
|
+
_global[globalCacheKey] = new Map();
|
|
19
|
+
}
|
|
20
|
+
return _global[globalCacheKey];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getScriptBaseUrl() {
|
|
24
|
+
if (typeof document !== 'undefined' && document.currentScript) {
|
|
25
|
+
try {
|
|
26
|
+
const src = document.currentScript.src;
|
|
27
|
+
if (src) {
|
|
28
|
+
const url = new URL(src);
|
|
29
|
+
return `${url.protocol}//${url.host}`;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// Failed to parse URL, fall through to default.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getRemotes(args) {
|
|
40
|
+
if (Array.isArray(args?.options?.remotes)) {
|
|
41
|
+
return args.options.remotes;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (Array.isArray(args?.userOptions?.remotes)) {
|
|
45
|
+
return args.userOptions.remotes;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function createZephyrRuntimePlugin(options = {}) {
|
|
52
|
+
const defaultManifestUrl = `${getScriptBaseUrl()}/zephyr-manifest.json`;
|
|
53
|
+
const { manifestUrl = defaultManifestUrl } = options;
|
|
54
|
+
|
|
55
|
+
let processedRemotes;
|
|
56
|
+
|
|
57
|
+
async function fetchManifest(url) {
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch(url);
|
|
60
|
+
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const manifest = await response.json().catch(() => undefined);
|
|
66
|
+
|
|
67
|
+
if (!manifest) {
|
|
68
|
+
console.error('[Zephyr] Failed to parse manifest JSON');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return manifest;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('[Zephyr] Unexpected error fetching manifest:', error);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const manifestCache = getGlobalManifestCache();
|
|
80
|
+
|
|
81
|
+
if (!manifestCache.has(manifestUrl)) {
|
|
82
|
+
manifestCache.set(manifestUrl, fetchManifest(manifestUrl));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const zephyrManifestPromise = manifestCache.get(manifestUrl);
|
|
14
86
|
|
|
15
|
-
export default function () {
|
|
16
87
|
return {
|
|
17
88
|
name: 'zephyr-runtime-remote-resolver',
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const _windows = typeof window !== 'undefined' ? window : globalThis;
|
|
89
|
+
async beforeRequest(args) {
|
|
90
|
+
const zephyrManifest = await zephyrManifestPromise;
|
|
21
91
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
92
|
+
if (!processedRemotes) {
|
|
93
|
+
processedRemotes = identifyRemotes(args, zephyrManifest);
|
|
94
|
+
}
|
|
27
95
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
96
|
+
const remoteName =
|
|
97
|
+
typeof args?.id === 'string' ? args.id.split('/')[0] : undefined;
|
|
31
98
|
|
|
32
|
-
|
|
99
|
+
if (!remoteName || !processedRemotes[remoteName]) {
|
|
100
|
+
return args;
|
|
101
|
+
}
|
|
33
102
|
|
|
34
|
-
|
|
35
|
-
|
|
103
|
+
const resolvedUrl = getResolvedRemoteUrl(processedRemotes[remoteName]);
|
|
104
|
+
const remotes = getRemotes(args);
|
|
105
|
+
|
|
106
|
+
const targetRemote = remotes.find(
|
|
107
|
+
(remote) =>
|
|
108
|
+
hasEntry(remote) &&
|
|
109
|
+
(remote.name === remoteName || remote.alias === remoteName)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (!targetRemote) {
|
|
113
|
+
return args;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
targetRemote.entry = resolvedUrl;
|
|
36
117
|
|
|
37
118
|
return args;
|
|
38
119
|
},
|
|
39
120
|
};
|
|
40
121
|
}
|
|
122
|
+
|
|
123
|
+
function identifyRemotes(args, zephyrManifest) {
|
|
124
|
+
const identifiedRemotes = {};
|
|
125
|
+
|
|
126
|
+
if (!zephyrManifest) {
|
|
127
|
+
return identifiedRemotes;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const remotes = getRemotes(args);
|
|
131
|
+
if (!remotes.length) {
|
|
132
|
+
return identifiedRemotes;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const dependencies = zephyrManifest.dependencies ?? {};
|
|
136
|
+
|
|
137
|
+
remotes.forEach((remote) => {
|
|
138
|
+
const resolvedRemote =
|
|
139
|
+
dependencies[remote.name] ?? dependencies[remote.alias ?? ''];
|
|
140
|
+
if (resolvedRemote) {
|
|
141
|
+
identifiedRemotes[remote.name] = resolvedRemote;
|
|
142
|
+
if (remote.alias && remote.alias !== remote.name) {
|
|
143
|
+
identifiedRemotes[remote.alias] = resolvedRemote;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return identifiedRemotes;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function hasEntry(remote) {
|
|
152
|
+
return (
|
|
153
|
+
remote !== null &&
|
|
154
|
+
remote !== undefined &&
|
|
155
|
+
typeof remote === 'object' &&
|
|
156
|
+
'entry' in remote &&
|
|
157
|
+
typeof remote.entry === 'string'
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getResolvedRemoteUrl(resolvedRemote) {
|
|
162
|
+
const _window = typeof window !== 'undefined' ? window : globalThis;
|
|
163
|
+
|
|
164
|
+
const sessionEdgeURL = _window.sessionStorage?.getItem?.(
|
|
165
|
+
resolvedRemote.application_uid
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
let edgeUrl = sessionEdgeURL ?? resolvedRemote.remote_entry_url;
|
|
169
|
+
|
|
170
|
+
if (edgeUrl.indexOf('@') !== -1) {
|
|
171
|
+
const [, url] = edgeUrl.split('@');
|
|
172
|
+
edgeUrl = url;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return edgeUrl;
|
|
176
|
+
}
|
|
@@ -11,7 +11,6 @@ const extract_mf_plugin_1 = require("./internal/extract/extract_mf_plugin");
|
|
|
11
11
|
const extract_vite_assets_map_1 = require("./internal/extract/extract_vite_assets_map");
|
|
12
12
|
const ensure_runtime_plugin_1 = require("./internal/mf-vite-etl/ensure_runtime_plugin");
|
|
13
13
|
const extract_mf_vite_remotes_1 = require("./internal/mf-vite-etl/extract-mf-vite-remotes");
|
|
14
|
-
const inject_resolved_remotes_1 = require("./internal/mf-vite-etl/inject_resolved_remotes");
|
|
15
14
|
const DEFAULT_LIBRARY_TYPE = 'module';
|
|
16
15
|
function loadModuleFederationPlugin() {
|
|
17
16
|
let moduleFederation;
|
|
@@ -75,7 +74,7 @@ function withZephyrCore(options = {}) {
|
|
|
75
74
|
mfConfig !== null && mfConfig !== void 0 ? mfConfig : (mfConfig = detectedMfConfig);
|
|
76
75
|
if (mfConfig) {
|
|
77
76
|
try {
|
|
78
|
-
// Resolve remotes early so
|
|
77
|
+
// Resolve remotes early so zephyr-manifest.json includes runtime dependencies.
|
|
79
78
|
const dependencyPairs = (0, extract_mf_vite_remotes_1.extract_remotes_dependencies)(root, mfConfig);
|
|
80
79
|
if (dependencyPairs) {
|
|
81
80
|
const zephyr_engine = await zephyr_engine_defer;
|
|
@@ -132,27 +131,12 @@ function withZephyrCore(options = {}) {
|
|
|
132
131
|
},
|
|
133
132
|
transform: {
|
|
134
133
|
order: 'post',
|
|
135
|
-
// Limit the hook to source-like files
|
|
134
|
+
// Limit the hook to source-like files only.
|
|
136
135
|
filter: {
|
|
137
|
-
id:
|
|
136
|
+
id: /\.(mjs|cjs|js|ts|jsx|tsx)/,
|
|
138
137
|
},
|
|
139
138
|
handler: async (code, id) => {
|
|
140
139
|
try {
|
|
141
|
-
// In dev, MF serves remoteEntry.js from memory; inject resolved remotes there.
|
|
142
|
-
if (mfConfig && code.includes('"__REMOTE_MAP__"')) {
|
|
143
|
-
const zephyr_engine = await zephyr_engine_defer;
|
|
144
|
-
const resolved_remotes = zephyr_engine.federated_dependencies;
|
|
145
|
-
if (resolved_remotes === null || resolved_remotes === void 0 ? void 0 : resolved_remotes.length) {
|
|
146
|
-
zephyr_agent_1.ze_log.remotes(`[transform] Transforming remoteEntry.js with ${resolved_remotes.length} remotes for dev mode`);
|
|
147
|
-
const result = (0, inject_resolved_remotes_1.inject_resolved_remotes_map)(resolved_remotes, code);
|
|
148
|
-
if (result !== code) {
|
|
149
|
-
return {
|
|
150
|
-
code: result,
|
|
151
|
-
map: null,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
140
|
// Rewrite ZE_PUBLIC_* reads in app code; node_modules stay untouched.
|
|
157
141
|
if (!id.includes('node_modules')) {
|
|
158
142
|
const zephyr_engine = await zephyr_engine_defer;
|
|
@@ -179,31 +163,6 @@ function withZephyrCore(options = {}) {
|
|
|
179
163
|
},
|
|
180
164
|
},
|
|
181
165
|
generateBundle: async function (_outputOptions, bundle) {
|
|
182
|
-
if (mfConfig) {
|
|
183
|
-
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
184
|
-
if (fileName === 'remoteEntry.js' &&
|
|
185
|
-
chunk &&
|
|
186
|
-
typeof chunk === 'object' &&
|
|
187
|
-
'type' in chunk &&
|
|
188
|
-
chunk.type === 'chunk' &&
|
|
189
|
-
'code' in chunk) {
|
|
190
|
-
try {
|
|
191
|
-
// Build mode writes remoteEntry.js to disk, so patch the emitted chunk here.
|
|
192
|
-
const zephyr_engine = await zephyr_engine_defer;
|
|
193
|
-
const resolved_remotes = zephyr_engine.federated_dependencies;
|
|
194
|
-
if (!(resolved_remotes === null || resolved_remotes === void 0 ? void 0 : resolved_remotes.length)) {
|
|
195
|
-
zephyr_agent_1.ze_log.remotes('No resolved remotes found in generateBundle');
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
chunk.code = (0, inject_resolved_remotes_1.inject_resolved_remotes_map)(resolved_remotes, chunk.code);
|
|
199
|
-
zephyr_agent_1.ze_log.remotes(`[generateBundle] Injected ${resolved_remotes.length} resolved remotes into remoteEntry.js for build mode`);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
(0, zephyr_agent_1.handleGlobalError)(error);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
166
|
if (cachedSpecifier) {
|
|
208
167
|
for (const [, chunk] of Object.entries(bundle)) {
|
|
209
168
|
if (chunk &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;AA8UA,gCAUC;;AAxVD,+CAA4C;AAC5C,wEAAuC;AAEvC,+BAAkF;AAClF,+CAUsB;AACtB,8EAA0E;AAC1E,4EAAyE;AACzE,wFAAqF;AACrF,wFAMsD;AACtD,4FAA8F;AAG9F,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAOtC,SAAS,0BAA0B;IACjC,IAAI,gBAEH,CAAC;IAEF,IAAI,CAAC;QACH,gBAAgB,GAAG,OAAO,CAAC,yBAAyB,CAEnD,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,0BAAW,CAAC,uBAAQ,CAAC,WAAW,EAAE;YAC1C,OAAO,EAAE,yLAAyL,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,oBAAoB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;SACtQ,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO,gBAAgB,CAAC,UAAU,KAAK,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GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;oBAC/D,2BAA2B;oBAC3B,mBAAmB;iBACpB,CAAC,CAAC;gBAEH,qBAAqB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;gBACxC,qBAAqB,CAAC,MAAM,GAAG,MAAM,CAAC;gBAEtC,MAAM,SAAS,GAAG,MAAM,IAAA,iDAAuB,EAC7C,aAAa,EACb,qBAAqB,CACtB,CAAC;gBAEF,MAAM,aAAa,CAAC,aAAa,CAAC;oBAChC,SAAS;oBACT,UAAU,EAAE,MAAM,IAAA,8BAAe,EAAC,aAAa,CAAC;oBAChD,KAAK;oBACL,UAAU;oBACV,YAAY,EAAE,KAAK;iBACpB,CAAC,CAAC;gBAEH,MAAM,aAAa,CAAC,cAAc,EAAE,CAAC;YACvC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAA,gCAAiB,EAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,UAA6B,EAAE;IACxD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,UAAU,GAAG,0BAA0B,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAA,2CAAmB,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-zephyr",
|
|
3
|
-
"version": "1.0.2",
|
|
3
|
+
"version": "1.0.3-next.2",
|
|
4
4
|
"description": "Vite plugin for Zephyr",
|
|
5
5
|
"$schema": "https://raw.githubusercontent.com/vitejs/vite-plugin-registry/refs/heads/main/data/schema/extended-package-json.schema.json",
|
|
6
6
|
"keywords": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-zephyr",
|
|
3
|
-
"version": "1.0.2",
|
|
3
|
+
"version": "1.0.3-next.2",
|
|
4
4
|
"description": "Vite plugin for Zephyr",
|
|
5
5
|
"$schema": "https://raw.githubusercontent.com/vitejs/vite-plugin-registry/refs/heads/main/data/schema/extended-package-json.schema.json",
|
|
6
6
|
"keywords": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"acorn-walk": "^8.3.4",
|
|
41
41
|
"magic-string": "0.30.21",
|
|
42
42
|
"tslib": "^2.8.1",
|
|
43
|
-
"zephyr-agent": "1.0.2"
|
|
43
|
+
"zephyr-agent": "1.0.3-next.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@module-federation/vite": "^1.13.2",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ZeResolvedDependency } from 'zephyr-agent';
|
|
2
|
-
/**
|
|
3
|
-
* Injects resolved remote dependencies into the remoteEntry.js code by replacing the
|
|
4
|
-
* **REMOTE_MAP** placeholder with actual resolved data.
|
|
5
|
-
*
|
|
6
|
-
* This approach is much more robust than AST parsing because:
|
|
7
|
-
*
|
|
8
|
-
* - Works regardless of minification/bundling changes
|
|
9
|
-
* - No dependency on function name patterns
|
|
10
|
-
* - Handles all import aliasing variations
|
|
11
|
-
* - Simple string replacement instead of complex AST manipulation
|
|
12
|
-
*/
|
|
13
|
-
export declare function inject_resolved_remotes_map(resolved_remotes: ZeResolvedDependency[], code: string): string;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inject_resolved_remotes_map = inject_resolved_remotes_map;
|
|
4
|
-
const zephyr_agent_1 = require("zephyr-agent");
|
|
5
|
-
// The placeholder used in runtime_plugin.mjs that we'll replace with actual data
|
|
6
|
-
const REMOTE_MAP_TEMPLATE = '"__REMOTE_MAP__"';
|
|
7
|
-
/**
|
|
8
|
-
* Injects resolved remote dependencies into the remoteEntry.js code by replacing the
|
|
9
|
-
* **REMOTE_MAP** placeholder with actual resolved data.
|
|
10
|
-
*
|
|
11
|
-
* This approach is much more robust than AST parsing because:
|
|
12
|
-
*
|
|
13
|
-
* - Works regardless of minification/bundling changes
|
|
14
|
-
* - No dependency on function name patterns
|
|
15
|
-
* - Handles all import aliasing variations
|
|
16
|
-
* - Simple string replacement instead of complex AST manipulation
|
|
17
|
-
*/
|
|
18
|
-
function inject_resolved_remotes_map(resolved_remotes, code) {
|
|
19
|
-
const startTime = Date.now();
|
|
20
|
-
try {
|
|
21
|
-
// Check if placeholder exists in the code
|
|
22
|
-
if (!code.includes(REMOTE_MAP_TEMPLATE)) {
|
|
23
|
-
zephyr_agent_1.ze_log.mf('Placeholder not found in remoteEntry.js - runtime plugin may not be configured');
|
|
24
|
-
return code;
|
|
25
|
-
}
|
|
26
|
-
// Build the remote map from resolved dependencies
|
|
27
|
-
const remoteMap = Object.fromEntries(resolved_remotes.map((remote) => [remote.name, remote]));
|
|
28
|
-
// Replace the placeholder with actual JSON data
|
|
29
|
-
// The placeholder is already quoted as '"__REMOTE_MAP__"' so we replace the whole thing
|
|
30
|
-
const updatedCode = code.replace(REMOTE_MAP_TEMPLATE, JSON.stringify(remoteMap));
|
|
31
|
-
const endTime = Date.now();
|
|
32
|
-
zephyr_agent_1.ze_log.remotes(`inject_resolved_remotes_map took ${endTime - startTime}ms`);
|
|
33
|
-
zephyr_agent_1.ze_log.remotes(`Injected ${resolved_remotes.length} resolved remotes into remoteEntry.js`);
|
|
34
|
-
return updatedCode;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
zephyr_agent_1.ze_log.remotes('Error in inject_resolved_remotes_map:', error);
|
|
38
|
-
return code; // Return original code in case of error
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=inject_resolved_remotes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inject_resolved_remotes.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/inject_resolved_remotes.ts"],"names":[],"mappings":";;AAiBA,kEAmCC;AAnDD,+CAAsC;AAEtC,iFAAiF;AACjF,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,SAAgB,2BAA2B,CACzC,gBAAwC,EACxC,IAAY;IAEZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,IAAI,CAAC;QACH,0CAA0C;QAC1C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxC,qBAAM,CAAC,EAAE,CACP,gFAAgF,CACjF,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QAED,kDAAkD;QAClD,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAClC,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CACxD,CAAC;QAEF,gDAAgD;QAChD,wFAAwF;QACxF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;QAEjF,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,qBAAM,CAAC,OAAO,CAAC,oCAAoC,OAAO,GAAG,SAAS,IAAI,CAAC,CAAC;QAC5E,qBAAM,CAAC,OAAO,CACZ,YAAY,gBAAgB,CAAC,MAAM,uCAAuC,CAC3E,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qBAAM,CAAC,OAAO,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,CAAC,wCAAwC;IACvD,CAAC;AACH,CAAC"}
|