vite-plugin-zephyr 0.0.46 → 0.0.48

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.
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ import type { ModuleFederationOptions } from '../../vite-plugin-zephyr';
3
+ export interface ViteMFPlugin {
4
+ _options: ModuleFederationOptions;
5
+ }
6
+ export declare function extract_mf_plugin(plugins: readonly Plugin[]): (Plugin<any> & ViteMFPlugin) | undefined;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extract_mf_plugin = extract_mf_plugin;
4
+ function extract_mf_plugin(plugins) {
5
+ const mfPlugin = plugins.find((plugin) => plugin.name === 'module-federation-vite');
6
+ return mfPlugin;
7
+ }
8
+ //# sourceMappingURL=extract_mf_plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract_mf_plugin.js","sourceRoot":"","sources":["../../../../src/lib/internal/extract/extract_mf_plugin.ts"],"names":[],"mappings":";;AAOA,8CAKC;AALD,SAAgB,iBAAiB,CAAC,OAA0B;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,wBAAwB,CAErE,CAAC;IACd,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"extract_vite_assets_map.js","sourceRoot":"","sources":["../../../../src/lib/internal/extract/extract_vite_assets_map.ts"],"names":[],"mappings":";;AAWA,0DAiBC;AA5BD,+CAMsB;AAEtB,6DAAwD;AAGjD,KAAK,UAAU,uBAAuB,CAC3C,aAA2B,EAC3B,qBAA4C;IAE5C,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAC;IACtD,MAAM,MAAM,GAAG,MAAM,IAAA,qCAAgB,EAAC,qBAAqB,CAAC,CAAC;IAC7D,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAkB,EAAC,eAAe,CAAC,CAAC;IAClE,MAAM,IAAA,oCAAqB,EAAC,eAAe,CAAC,CAAC;IAE7C,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC;IACpD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACnC,EAAE,EACF,MAAM,EACN,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,EAAE,CAAC,EACvC,cAAc,CACf,CAAC;IACF,OAAO,IAAA,6BAAc,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,KAAgC;IACpD,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,SAAS,aAAa,CAAC,KAAgC;IACrD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBACrC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"extract_vite_assets_map.js","sourceRoot":"","sources":["../../../../src/lib/internal/extract/extract_vite_assets_map.ts"],"names":[],"mappings":";;AAUA,0DAiBC;AA3BD,+CAMsB;AAEtB,6DAAwD;AAEjD,KAAK,UAAU,uBAAuB,CAC3C,aAA2B,EAC3B,qBAA4C;IAE5C,MAAM,eAAe,GAAG,aAAa,CAAC,eAAe,CAAC;IACtD,MAAM,MAAM,GAAG,MAAM,IAAA,qCAAgB,EAAC,qBAAqB,CAAC,CAAC;IAC7D,MAAM,eAAe,GAAG,MAAM,IAAA,iCAAkB,EAAC,eAAe,CAAC,CAAC;IAClE,MAAM,IAAA,oCAAqB,EAAC,eAAe,CAAC,CAAC;IAE7C,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC;IACpD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACnC,EAAE,EACF,MAAM,EACN,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,EAAE,CAAC,EACvC,cAAc,CACf,CAAC;IACF,OAAO,IAAA,6BAAc,EAAC,eAAe,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,YAAY,CAAC,KAAgC;IACpD,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,SAAS,aAAa,CAAC,KAAgC;IACrD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,KAAK,CAAC,IAAI,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;gBACrC,CAAC,CAAC,KAAK,CAAC,MAAM;gBACd,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,OAAO,KAAK,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,2 +1,12 @@
1
1
  import type { ZeDependencyPair } from 'zephyr-agent';
2
- export declare function extract_remotes_dependencies(root: string, code: string, id: string): ZeDependencyPair[] | undefined;
2
+ export interface RemoteObjectConfig {
3
+ type?: string;
4
+ name: string;
5
+ entry: string;
6
+ entryGlobalName?: string;
7
+ shareScope?: string;
8
+ }
9
+ export interface PartialViteMFConfig {
10
+ remotes?: Record<string, string | RemoteObjectConfig> | undefined;
11
+ }
12
+ export declare function extract_remotes_dependencies(root: string, mfConfig: PartialViteMFConfig): ZeDependencyPair[] | undefined;
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extract_remotes_dependencies = extract_remotes_dependencies;
4
4
  const zephyr_agent_1 = require("zephyr-agent");
5
- const remote_map_parser_1 = require("./remote_map_parser");
6
- function extract_remotes_dependencies(root, code, id) {
5
+ function extract_remotes_dependencies(root, mfConfig) {
7
6
  const { zephyrDependencies } = (0, zephyr_agent_1.readPackageJson)(root);
8
7
  if (zephyrDependencies) {
9
8
  return Object.entries(zephyrDependencies).map(([name, version]) => {
@@ -13,15 +12,14 @@ function extract_remotes_dependencies(root, code, id) {
13
12
  };
14
13
  });
15
14
  }
16
- const dependencyPairs = [];
17
- const extractedRemotes = (0, remote_map_parser_1.parseRemoteMap)(code, id);
18
- if (extractedRemotes === undefined)
15
+ if (!mfConfig.remotes)
19
16
  return;
20
- const { remotesMap } = extractedRemotes;
21
- for (const remote of remotesMap) {
22
- const { name, entry: version } = remote;
23
- dependencyPairs.push({ name, version });
24
- }
17
+ const dependencyPairs = Object.entries(mfConfig.remotes).map(([name, remote]) => {
18
+ if (typeof remote === 'string') {
19
+ return { name, version: remote };
20
+ }
21
+ return { name, version: remote.entry };
22
+ });
25
23
  return dependencyPairs;
26
24
  }
27
25
  //# sourceMappingURL=extract-mf-vite-remotes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"extract-mf-vite-remotes.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/extract-mf-vite-remotes.ts"],"names":[],"mappings":";;AAIA,oEA2BC;AA9BD,+CAA+C;AAC/C,2DAAqD;AAErD,SAAgB,4BAA4B,CAC1C,IAAY,EACZ,IAAY,EACZ,EAAU;IAEV,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAA,8BAAe,EAAC,IAAI,CAAC,CAAC;IACrD,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE;YAChE,OAAO;gBACL,IAAI;gB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AQ,EAAE,CAAC;YAC/B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACzC,CAAC,CACF,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import type { ZeResolvedDependency } from 'zephyr-agent';
2
- export declare function load_resolved_remotes(resolved_remotes: ZeResolvedDependency[], code: string, id: string): string | undefined;
2
+ export declare function load_resolved_remotes(resolved_remotes: ZeResolvedDependency[], code: string): string;
@@ -1,26 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.load_resolved_remotes = load_resolved_remotes;
4
- const remote_map_parser_1 = require("./remote_map_parser");
5
- function load_resolved_remotes(resolved_remotes, code, id) {
6
- const extractedRemotes = (0, remote_map_parser_1.parseRemoteMap)(code, id);
7
- if (extractedRemotes === undefined)
8
- return;
9
- const remotes = [];
10
- const { remotesMap, startIndex, endIndex } = extractedRemotes;
11
- for (const remote of remotesMap) {
12
- const { name, entry, type } = remote;
13
- const remoteDetails = resolved_remotes.find((r) => r.name === name && r.version === entry);
14
- if (!remoteDetails)
15
- continue;
16
- const updatedUrl = (0, remote_map_parser_1.replaceProtocolAndHost)(entry, remoteDetails.remote_entry_url);
17
- remotes.push({
18
- name,
19
- type,
20
- entryGlobalName: name,
21
- entry: updatedUrl,
22
- });
4
+ const zephyr_agent_1 = require("zephyr-agent");
5
+ const runtime_plugins_parser_1 = require("./runtime_plugins_parser");
6
+ const runtime_plugin_1 = require("./runtime_plugin");
7
+ function load_resolved_remotes(resolved_remotes, code) {
8
+ const startTime = Date.now();
9
+ try {
10
+ const runtimePluginsExtraction = (0, runtime_plugins_parser_1.parseRuntimePlugin)(code);
11
+ if (!runtimePluginsExtraction)
12
+ return code;
13
+ const { pluginsArray, startIndex, endIndex } = runtimePluginsExtraction;
14
+ // Add Zephyr plugin to the array
15
+ // We need to add a Zephyr plugin to the end of the array
16
+ // The array is in format: [plugin1(), plugin2(), ...] or []
17
+ let updatedPluginsArray;
18
+ const runtimePlugin = (0, runtime_plugin_1.generateRuntimePlugin)(resolved_remotes);
19
+ if (pluginsArray === '[]') {
20
+ // Handle empty array case
21
+ updatedPluginsArray = `[${runtimePlugin}]`;
22
+ }
23
+ else {
24
+ // Handle non-empty array case
25
+ updatedPluginsArray = pluginsArray.replace(/\]$/, `, ${runtimePlugin}]`);
26
+ }
27
+ // Replace the original array with the updated one
28
+ const updatedCode = code.substring(0, startIndex) + updatedPluginsArray + code.substring(endIndex);
29
+ const endTime = Date.now();
30
+ (0, zephyr_agent_1.ze_log)(`load_resolved_remotes took ${endTime - startTime}ms`);
31
+ return updatedCode;
32
+ }
33
+ catch (error) {
34
+ (0, zephyr_agent_1.ze_log)('Error in load_resolved_remotes:', error);
35
+ return code; // Return original code in case of error
23
36
  }
24
- return code.slice(0, startIndex) + JSON.stringify(remotes) + code.slice(endIndex);
25
37
  }
26
38
  //# sourceMappingURL=load_resolved_remotes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load_resolved_remotes.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/load_resolved_remotes.ts"],"names":[],"mappings":";;AAIA,sDA0BC;AA5BD,2DAA6E;AAE7E,SAAgB,qBAAqB,CACnC,gBAAwC,EACxC,IAAY,EACZ,EAAU;IAEV,MAAM,gBAAgB,GAAG,IAAA,kCAAc,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAClD,IAAI,gBAAgB,KAAK,SAAS;QAAE,OAAO;IAE3C,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC;IAC9D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE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D,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;YAC1B,0BAA0B;YAC1B,mBAAmB,GAAG,IAAI,aAAa,GAAG,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,8BAA8B;YAC9B,mBAAmB,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,aAAa,GAAG,CAAC,CAAC;QAC3E,CAAC;QAED,kDAAkD;QAClD,MAAM,WAAW,GACf,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEjF,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,IAAA,qBAAM,EAAC,8BAA8B,OAAO,GAAG,SAAS,IAAI,CAAC,CAAC;QAC9D,OAAO,WAAW,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,qBAAM,EAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,CAAC,wCAAwC;IACvD,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { ZeResolvedDependency } from 'zephyr-agent';
2
+ export declare function generateRuntimePlugin(resolved_remotes: ZeResolvedDependency[]): string;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateRuntimePlugin = generateRuntimePlugin;
4
+ function generateRuntimePlugin(resolved_remotes) {
5
+ const remoteMap = Object.fromEntries(resolved_remotes.map((remote) => [remote.name, remote]));
6
+ const runtimePlugin = {
7
+ name: 'zephyr-runtime-remote-resolver',
8
+ beforeInit: (args) => {
9
+ const resolvedRemoteMap = JSON.parse('__REMOTE_MAP__');
10
+ const _windows = typeof window !== 'undefined' ? window : globalThis;
11
+ args.userOptions.remotes.forEach((remote) => {
12
+ const resolvedRemote = resolvedRemoteMap[remote.name];
13
+ if (!resolvedRemote)
14
+ return;
15
+ const sessionEdgeURL = _windows.sessionStorage.getItem(resolvedRemote.application_uid);
16
+ const urlOverwrite = sessionEdgeURL !== null && sessionEdgeURL !== void 0 ? sessionEdgeURL : resolvedRemote.remote_entry_url;
17
+ // @ts-expect-error overwriting entry if needed
18
+ remote.entry = urlOverwrite;
19
+ });
20
+ return args;
21
+ },
22
+ };
23
+ return objectToTemplate(runtimePlugin).replace('__REMOTE_MAP__', JSON.stringify(remoteMap));
24
+ }
25
+ function objectToTemplate(obj) {
26
+ const entries = Object.entries(obj).map(([key, value]) => {
27
+ if (typeof value === 'function') {
28
+ return `${key}: ${value.toString()}`;
29
+ }
30
+ else if (typeof value === 'object' && value !== null) {
31
+ return `${key}: ${objectToTemplate(value)}`;
32
+ }
33
+ else if (typeof value === 'string') {
34
+ return `${key}: "${value}"`;
35
+ }
36
+ else {
37
+ return `${key}: ${value}`;
38
+ }
39
+ });
40
+ return `{ ${entries.join(', ')} }`;
41
+ }
42
+ //# sourceMappingURL=runtime_plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime_plugin.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/runtime_plugin.ts"],"names":[],"mappings":";;AAGA,sDA+BC;AA/BD,SAAgB,qBAAqB,CAAC,gBAAwC;IAC5E,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;IAEF,MAAM,aAAa,GAA4B;QAC7C,IAAI,EAAE,gCAAgC;QACtC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;YACnB,MAAM,iBAAiB,GACrB,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC/B,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC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AK,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACrC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface RuntimePluginsExtraction {
2
+ pluginsArray: string;
3
+ startIndex: number;
4
+ endIndex: number;
5
+ }
6
+ export declare function parseRuntimePlugin(code: string): RuntimePluginsExtraction | undefined;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseRuntimePlugin = parseRuntimePlugin;
4
+ const tslib_1 = require("tslib");
5
+ const acorn_1 = tslib_1.__importDefault(require("acorn"));
6
+ const acorn_walk_1 = tslib_1.__importDefault(require("acorn-walk"));
7
+ const zephyr_agent_1 = require("zephyr-agent");
8
+ function parseRuntimePlugin(code) {
9
+ // Parse the code into an AST
10
+ const ast = acorn_1.default.parse(code, {
11
+ ecmaVersion: 'latest',
12
+ sourceType: 'module',
13
+ locations: true,
14
+ ranges: true,
15
+ });
16
+ let pluginsArrayNode;
17
+ // Find the plugins array in the runtimeInit call
18
+ acorn_walk_1.default.simple(ast, {
19
+ CallExpression(node) {
20
+ var _a, _b;
21
+ if (((_a = node.callee) === null || _a === void 0 ? void 0 : _a.name) === 'runtimeInit' && ((_b = node.arguments) === null || _b === void 0 ? void 0 : _b.length) > 0) {
22
+ const initArg = node.arguments[0];
23
+ if (initArg.type === 'ObjectExpression') {
24
+ for (const prop of initArg.properties) {
25
+ if (prop.key.type === 'Identifier' &&
26
+ prop.key.name === 'plugins' &&
27
+ prop.value.type === 'ArrayExpression') {
28
+ pluginsArrayNode = prop.value;
29
+ break;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ },
35
+ });
36
+ if (!pluginsArrayNode ||
37
+ !('start' in pluginsArrayNode) ||
38
+ !('end' in pluginsArrayNode)) {
39
+ (0, zephyr_agent_1.ze_log)('Could not find plugins array in remote entry');
40
+ return undefined;
41
+ }
42
+ // Extract the plugins array
43
+ const startIndex = pluginsArrayNode.start;
44
+ const endIndex = pluginsArrayNode.end;
45
+ const pluginsArray = code.slice(startIndex, endIndex);
46
+ return { pluginsArray, startIndex, endIndex };
47
+ }
48
+ //# sourceMappingURL=runtime_plugins_parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime_plugins_parser.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/runtime_plugins_parser.ts"],"names":[],"mappings":";;AAUA,gDAgDC;;AA1DD,0DAA0B;AAC1B,oEAA8B;AAC9B,+CAAsC;AAQtC,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,6BAA6B;IAC7B,MAAM,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IAEH,IAAI,gBAAwC,CAAC;IAE7C,iDAAiD;IACjD,oBAAI,CAAC,MAAM,CAAC,GAAG,EAAE;QACf,cAAc,CAAC,IAAS;;YACtB,IAAI,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,MAAK,aAAa,IAAI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,MAAM,IAAG,CAAC,EAAE,CAAC;gBACtE,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAElC,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBACxC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;wBACtC,IACE,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;4BAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS;4BAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,iBAAiB,EACrC,CAAC;4BACD,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC;4BAC9B,MAAM;wBACR,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,IACE,CAAC,gBAAgB;QACjB,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC;QAC9B,CAAC,CAAC,KAAK,IAAI,gBAAgB,CAAC,EAC5B,CAAC;QACD,IAAA,qBAAM,EAAC,8CAA8C,CAAC,CAAC;QACvD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,4BAA4B;IAC5B,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC;IAC1C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC;IACtC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC"}
@@ -6,6 +6,7 @@ const vite_1 = require("@module-federation/vite");
6
6
  const extract_vite_assets_map_1 = require("./internal/extract/extract_vite_assets_map");
7
7
  const extract_mf_vite_remotes_1 = require("./internal/mf-vite-etl/extract-mf-vite-remotes");
8
8
  const load_resolved_remotes_1 = require("./internal/mf-vite-etl/load_resolved_remotes");
9
+ const extract_mf_plugin_1 = require("./internal/extract/extract_mf_plugin");
9
10
  function withZephyr(_options) {
10
11
  const mfConfig = _options === null || _options === void 0 ? void 0 : _options.mfConfig;
11
12
  const plugins = [];
@@ -22,12 +23,15 @@ function zephyrPlugin() {
22
23
  resolve_vite_internal_options = resolve;
23
24
  });
24
25
  let root;
26
+ let mfPlugin;
25
27
  return {
26
28
  name: 'with-zephyr',
27
29
  enforce: 'post',
28
30
  configResolved: async (config) => {
29
- var _a;
31
+ var _a, _b;
30
32
  root = config.root;
33
+ if (config.command === 'serve')
34
+ return;
31
35
  zephyr_defer_create({
32
36
  builder: 'vite',
33
37
  context: config.root,
@@ -37,17 +41,20 @@ function zephyrPlugin() {
37
41
  outDir: (_a = config.build) === null || _a === void 0 ? void 0 : _a.outDir,
38
42
  publicDir: config.publicDir,
39
43
  });
44
+ mfPlugin = (0, extract_mf_plugin_1.extract_mf_plugin)((_b = config.plugins) !== null && _b !== void 0 ? _b : []);
40
45
  },
41
46
  transform: async (code, id) => {
42
47
  try {
43
- const dependencyPairs = (0, extract_mf_vite_remotes_1.extract_remotes_dependencies)(root, code, id);
48
+ if (!id.includes('virtual:mf-REMOTE_ENTRY_ID') || !mfPlugin)
49
+ return code;
50
+ const dependencyPairs = (0, extract_mf_vite_remotes_1.extract_remotes_dependencies)(root, mfPlugin._options);
44
51
  if (!dependencyPairs)
45
52
  return code;
46
53
  const zephyr_engine = await zephyr_engine_defer;
47
54
  const resolved_remotes = await zephyr_engine.resolve_remote_dependencies(dependencyPairs);
48
55
  if (!resolved_remotes)
49
56
  return code;
50
- return (0, load_resolved_remotes_1.load_resolved_remotes)(resolved_remotes, code, id);
57
+ return (0, load_resolved_remotes_1.load_resolved_remotes)(resolved_remotes, code);
51
58
  }
52
59
  catch (error) {
53
60
  (0, zephyr_agent_1.logFn)('error', zephyr_agent_1.ZephyrError.format(error));
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin-zephyr.js","sourceRoot":"","sources":["../../src/lib/vite-plugin-zephyr.ts"],"names":[],"mappings":";;AAcA,gCAQC;AArBD,+CAAiF;AAEjF,kDAAqD;AACrD,wFAAqF;AACrF,4FAA8F;AAC9F,wFAAqF;AAQrF,SAAgB,UAAU,CAAC,QAAkC;IAC3D,MAAM,QAAQ,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC;IACpC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,GAAI,IAAA,iBAAU,EAAC,QAAQ,CAAc,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE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ACH,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-zephyr",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "Vite plugin for Zephyr",
5
5
  "repository": {
6
6
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-zephyr",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "Vite plugin for Zephyr",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "json5": "2.2.3",
25
25
  "rollup": "^4.36.0",
26
26
  "vite": "^6.2.4",
27
- "zephyr-agent": "0.0.46"
27
+ "zephyr-agent": "0.0.48"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/is-ci": "3.0.4",
@@ -1,20 +0,0 @@
1
- export interface RemoteEntry {
2
- name: string;
3
- entryGlobalName?: string;
4
- entry: string;
5
- type?: string;
6
- }
7
- export interface RemoteMapExtraction {
8
- remotesMap: RemoteEntry[];
9
- startIndex: number;
10
- endIndex: number;
11
- }
12
- /**
13
- * Parses the provided code to extract the remotes object.
14
- *
15
- * @param code - The code containing the remotes object declaration.
16
- * @returns An object containing the remotes object and the start and end indices of the
17
- * remotes object declaration in the code, or undefined if parsing fails.
18
- */
19
- export declare function parseRemoteMap(code: string, id: string): RemoteMapExtraction | undefined;
20
- export declare function replaceProtocolAndHost(originalUrl: string, newProtocolAndHost: string): string;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseRemoteMap = parseRemoteMap;
4
- exports.replaceProtocolAndHost = replaceProtocolAndHost;
5
- const tslib_1 = require("tslib");
6
- const json5_1 = tslib_1.__importDefault(require("json5"));
7
- const acorn_1 = tslib_1.__importDefault(require("acorn"));
8
- const acorn_walk_1 = tslib_1.__importDefault(require("acorn-walk"));
9
- const zephyr_agent_1 = require("zephyr-agent");
10
- /**
11
- * Parses the provided code to extract the remotes object.
12
- *
13
- * @param code - The code containing the remotes object declaration.
14
- * @returns An object containing the remotes object and the start and end indices of the
15
- * remotes object declaration in the code, or undefined if parsing fails.
16
- */
17
- function parseRemoteMap(code, id) {
18
- if (!id.includes('localSharedImportMap')) {
19
- return undefined;
20
- }
21
- let arrayNode;
22
- const startTime = Date.now();
23
- // Parse the code into an AST
24
- const ast = acorn_1.default.parse(code, {
25
- ecmaVersion: 'latest',
26
- sourceType: 'module',
27
- locations: true, // Include line and column numbers
28
- ranges: true, // Include start and end indices
29
- });
30
- // Visitor function to find the variable declaration
31
- function findUsedRemotes(node) {
32
- if (node.type === 'VariableDeclaration' && node.kind === 'const') {
33
- for (const declarator of node.declarations) {
34
- if (declarator.id.type === 'Identifier' &&
35
- declarator.id.name === 'usedRemotes' &&
36
- declarator.init) {
37
- // Found the 'usedRemotes' variable
38
- arrayNode = declarator.init;
39
- break;
40
- }
41
- }
42
- }
43
- }
44
- acorn_walk_1.default.simple(ast, {
45
- VariableDeclaration: findUsedRemotes,
46
- });
47
- const endTime = Date.now();
48
- (0, zephyr_agent_1.ze_log)(`parseRemoteMap took ${endTime - startTime}ms`);
49
- if (!arrayNode) {
50
- return;
51
- }
52
- (0, zephyr_agent_1.ze_log)('vite.arrayNode found: ', arrayNode);
53
- // Get start and end indices
54
- const startIndex = arrayNode.start;
55
- const endIndex = arrayNode.end;
56
- // Extract the array text from the code
57
- const arrayText = code.slice(startIndex, endIndex);
58
- let remotesArray;
59
- try {
60
- // Use a faster JSON parser if possible
61
- remotesArray = JSON.parse(arrayText);
62
- (0, zephyr_agent_1.ze_log)('vite.parseRemoteMap.remotesArray: ', remotesArray);
63
- }
64
- catch (error) {
65
- // Fallback to json5 only if necessary
66
- try {
67
- remotesArray = json5_1.default.parse(arrayText);
68
- }
69
- catch (innerError) {
70
- (0, zephyr_agent_1.ze_log)('Failed to parse remotes array: ', arrayText, 'with error: ', innerError);
71
- return;
72
- }
73
- if (!Array.isArray(remotesArray)) {
74
- (0, zephyr_agent_1.ze_log)('Failed to parse remotes array: ', arrayText, 'with error: ', error);
75
- return;
76
- }
77
- }
78
- return {
79
- remotesMap: remotesArray,
80
- startIndex,
81
- endIndex,
82
- };
83
- }
84
- function replaceProtocolAndHost(originalUrl, newProtocolAndHost) {
85
- (0, zephyr_agent_1.ze_log)('vite.replaceProtocalAndHost.originalUrl: ', originalUrl);
86
- (0, zephyr_agent_1.ze_log)('vite.replaceProtocalAndHost: ', newProtocolAndHost);
87
- const url = new URL(originalUrl);
88
- const newUrl = new URL(newProtocolAndHost);
89
- // Replace protocol and hostname
90
- url.protocol = newUrl.protocol;
91
- url.hostname = newUrl.hostname;
92
- url.port = '';
93
- (0, zephyr_agent_1.ze_log)('vite.transformedUrl: ', url.toString());
94
- return url.toString();
95
- }
96
- //# sourceMappingURL=remote_map_parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote_map_parser.js","sourceRoot":"","sources":["../../../../src/lib/internal/mf-vite-etl/remote_map_parser.ts"],"names":[],"mappings":";;AAyBA,wCAgFC;AAED,wDAiBC;;AA5HD,0DAA0B;AAC1B,0DAA0B;AAC1B,oEAA8B;AAC9B,+CAAsC;AAetC;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,IAAY,EACZ,EAAU;IAEV,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QACzC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,SAAiC,CAAC;IAEtC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,6BAA6B;IAC7B,MAAM,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,QAAQ;QACpB,SAAS,EAAE,IAAI,EAAE,kCAAkC;QACnD,MAAM,EAAE,IAAI,EAAE,gCAAgC;KAC/C,CAAC,CAAC;I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