vite-plugin-zephyr 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +45 -1
  2. package/dist/index.d.mts +7 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +44 -6
  5. package/dist/index.mjs +3 -0
  6. package/dist/lib/internal/extract/extract-entrypoint.d.mts +11 -0
  7. package/dist/lib/internal/extract/extract-entrypoint.d.ts +2 -1
  8. package/dist/lib/internal/extract/extract-entrypoint.js +53 -38
  9. package/dist/lib/internal/extract/extract-entrypoint.mjs +32 -0
  10. package/dist/lib/internal/extract/extract_mf_plugin.d.mts +10 -0
  11. package/dist/lib/internal/extract/extract_mf_plugin.d.ts +6 -2
  12. package/dist/lib/internal/extract/extract_mf_plugin.js +48 -5
  13. package/dist/lib/internal/extract/extract_mf_plugin.mjs +17 -0
  14. package/dist/lib/internal/extract/extract_vite_assets_map.d.mts +4 -0
  15. package/dist/lib/internal/extract/extract_vite_assets_map.d.ts +2 -1
  16. package/dist/lib/internal/extract/extract_vite_assets_map.js +65 -35
  17. package/dist/lib/internal/extract/extract_vite_assets_map.mjs +49 -0
  18. package/dist/lib/internal/extract/load_public_dir.d.mts +10 -0
  19. package/dist/lib/internal/extract/load_public_dir.d.ts +5 -2
  20. package/dist/lib/internal/extract/load_public_dir.js +57 -19
  21. package/dist/lib/internal/extract/load_public_dir.mjs +31 -0
  22. package/dist/lib/internal/extract/load_static_assets.d.mts +4 -0
  23. package/dist/lib/internal/extract/load_static_assets.d.ts +3 -2
  24. package/dist/lib/internal/extract/load_static_assets.js +60 -35
  25. package/dist/lib/internal/extract/load_static_assets.mjs +29 -0
  26. package/dist/lib/internal/extract/load_static_entries.d.mts +10 -0
  27. package/dist/lib/internal/extract/load_static_entries.d.ts +5 -2
  28. package/dist/lib/internal/extract/load_static_entries.js +56 -14
  29. package/dist/lib/internal/extract/load_static_entries.mjs +31 -0
  30. package/dist/lib/internal/extract/merge_vite_output_assets.d.mts +13 -0
  31. package/dist/lib/internal/extract/merge_vite_output_assets.d.ts +13 -0
  32. package/dist/lib/internal/extract/merge_vite_output_assets.js +68 -0
  33. package/dist/lib/internal/extract/merge_vite_output_assets.mjs +31 -0
  34. package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.d.mts +31 -0
  35. package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.d.ts +11 -0
  36. package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.js +56 -15
  37. package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.mjs +21 -0
  38. package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.d.mts +13 -0
  39. package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.d.ts +1 -0
  40. package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.js +55 -19
  41. package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.mjs +24 -0
  42. package/dist/lib/internal/mf-vite-etl/federation-metadata.d.mts +38 -0
  43. package/dist/lib/internal/mf-vite-etl/federation-metadata.d.ts +38 -0
  44. package/dist/lib/internal/mf-vite-etl/federation-metadata.js +154 -0
  45. package/dist/lib/internal/mf-vite-etl/federation-metadata.mjs +111 -0
  46. package/dist/lib/internal/mf-vite-etl/runtime_plugin.mjs +68 -159
  47. package/dist/lib/internal/partial-build-scope.d.mts +12 -0
  48. package/dist/lib/internal/partial-build-scope.d.ts +12 -0
  49. package/dist/lib/internal/partial-build-scope.js +83 -0
  50. package/dist/lib/internal/partial-build-scope.mjs +43 -0
  51. package/dist/lib/internal/types/zephyr-internal-options.d.mts +13 -0
  52. package/dist/lib/internal/types/zephyr-internal-options.d.ts +6 -2
  53. package/dist/lib/internal/types/zephyr-internal-options.js +18 -1
  54. package/dist/lib/internal/types/zephyr-internal-options.mjs +1 -0
  55. package/dist/lib/internal/types/zephyr-output.d.mts +23 -0
  56. package/dist/lib/internal/types/zephyr-output.d.ts +23 -0
  57. package/dist/lib/internal/types/zephyr-output.js +20 -0
  58. package/dist/lib/internal/types/zephyr-output.mjs +1 -0
  59. package/dist/lib/internal/utils/normalize-entrypoint.d.mts +11 -0
  60. package/dist/lib/internal/utils/normalize-entrypoint.d.ts +1 -0
  61. package/dist/lib/internal/utils/normalize-entrypoint.js +42 -24
  62. package/dist/lib/internal/utils/normalize-entrypoint.mjs +12 -0
  63. package/dist/lib/internal/utils/normalize-vite-path.d.mts +10 -0
  64. package/dist/lib/internal/utils/normalize-vite-path.d.ts +10 -0
  65. package/dist/lib/internal/utils/normalize-vite-path.js +51 -0
  66. package/dist/lib/internal/utils/normalize-vite-path.mjs +11 -0
  67. package/dist/lib/vite-plugin-zephyr-partial.d.mts +6 -0
  68. package/dist/lib/vite-plugin-zephyr-partial.d.ts +5 -8
  69. package/dist/lib/vite-plugin-zephyr-partial.js +75 -27
  70. package/dist/lib/vite-plugin-zephyr-partial.mjs +64 -0
  71. package/dist/lib/vite-plugin-zephyr.d.mts +21 -0
  72. package/dist/lib/vite-plugin-zephyr.d.ts +16 -3
  73. package/dist/lib/vite-plugin-zephyr.js +685 -239
  74. package/dist/lib/vite-plugin-zephyr.mjs +662 -0
  75. package/dist/rslib-runtime.mjs +21 -0
  76. package/package.json +53 -44
  77. package/dist/index.js.map +0 -1
  78. package/dist/lib/internal/extract/extract-entrypoint.js.map +0 -1
  79. package/dist/lib/internal/extract/extract_mf_plugin.js.map +0 -1
  80. package/dist/lib/internal/extract/extract_vite_assets_map.js.map +0 -1
  81. package/dist/lib/internal/extract/load_public_dir.js.map +0 -1
  82. package/dist/lib/internal/extract/load_static_assets.js.map +0 -1
  83. package/dist/lib/internal/extract/load_static_entries.js.map +0 -1
  84. package/dist/lib/internal/mf-vite-etl/ensure_runtime_plugin.js.map +0 -1
  85. package/dist/lib/internal/mf-vite-etl/extract-mf-vite-remotes.js.map +0 -1
  86. package/dist/lib/internal/types/zephyr-internal-options.js.map +0 -1
  87. package/dist/lib/internal/utils/normalize-entrypoint.js.map +0 -1
  88. package/dist/lib/vite-plugin-zephyr-partial.js.map +0 -1
  89. package/dist/lib/vite-plugin-zephyr.js.map +0 -1
  90. package/dist/package.json +0 -85
  91. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,23 +1,64 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID = exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID = void 0;
4
- exports.getRuntimePluginPath = getRuntimePluginPath;
5
- exports.ensureRuntimePlugin = ensureRuntimePlugin;
6
- const tslib_1 = require("tslib");
7
- const path = tslib_1.__importStar(require("path"));
8
- exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID = 'virtual:zephyr-mf-runtime-plugin';
9
- exports.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID = `\0${exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID}`;
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID: ()=>RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID,
32
+ ZEPHYR_MF_RUNTIME_PLUGIN_ID: ()=>ZEPHYR_MF_RUNTIME_PLUGIN_ID,
33
+ ensureRuntimePlugin: ()=>ensureRuntimePlugin,
34
+ getRuntimePluginPath: ()=>getRuntimePluginPath
35
+ });
36
+ const external_path_namespaceObject = require("path");
37
+ const ZEPHYR_MF_RUNTIME_PLUGIN_ID = 'virtual:zephyr-mf-runtime-plugin';
38
+ const RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID = `\0${ZEPHYR_MF_RUNTIME_PLUGIN_ID}`;
10
39
  function getRuntimePluginPath() {
11
- return path.resolve(__dirname, 'runtime_plugin.mjs');
40
+ return external_path_namespaceObject.resolve(__dirname, 'runtime_plugin.mjs');
12
41
  }
13
42
  function ensureRuntimePlugin(mfConfig) {
14
- var _a;
15
- const runtimePlugins = [...((_a = mfConfig.runtimePlugins) !== null && _a !== void 0 ? _a : [])];
16
- if (!runtimePlugins.includes(exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID)) {
17
- // MF serializes runtime plugins into remoteEntry.js, so inject ours before build.
18
- runtimePlugins.push(exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID);
19
- }
43
+ const runtimePlugins = [
44
+ ...mfConfig.runtimePlugins ?? []
45
+ ];
46
+ if (!runtimePlugins.includes(ZEPHYR_MF_RUNTIME_PLUGIN_ID)) runtimePlugins.push(ZEPHYR_MF_RUNTIME_PLUGIN_ID);
20
47
  mfConfig.runtimePlugins = runtimePlugins;
21
48
  return mfConfig;
22
49
  }
50
+ exports.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID = __webpack_exports__.RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID;
51
+ exports.ZEPHYR_MF_RUNTIME_PLUGIN_ID = __webpack_exports__.ZEPHYR_MF_RUNTIME_PLUGIN_ID;
52
+ exports.ensureRuntimePlugin = __webpack_exports__.ensureRuntimePlugin;
53
+ exports.getRuntimePluginPath = __webpack_exports__.getRuntimePluginPath;
54
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
55
+ "RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID",
56
+ "ZEPHYR_MF_RUNTIME_PLUGIN_ID",
57
+ "ensureRuntimePlugin",
58
+ "getRuntimePluginPath"
59
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
60
+ Object.defineProperty(exports, '__esModule', {
61
+ value: true
62
+ });
63
+
23
64
  //# sourceMappingURL=ensure_runtime_plugin.js.map
@@ -0,0 +1,21 @@
1
+ import "node:module";
2
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
3
+ import { dirname as __rspack_dirname } from "node:path";
4
+ var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
5
+ import * as __rspack_external_path from "path";
6
+ const ZEPHYR_MF_RUNTIME_PLUGIN_ID = 'virtual:zephyr-mf-runtime-plugin';
7
+ const RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID = `\0${ZEPHYR_MF_RUNTIME_PLUGIN_ID}`;
8
+ function getRuntimePluginPath() {
9
+ return __rspack_external_path.resolve(__rspack_import_meta_dirname__, 'runtime_plugin.mjs');
10
+ }
11
+ function ensureRuntimePlugin(mfConfig) {
12
+ const runtimePlugins = [
13
+ ...mfConfig.runtimePlugins ?? []
14
+ ];
15
+ if (!runtimePlugins.includes(ZEPHYR_MF_RUNTIME_PLUGIN_ID)) runtimePlugins.push(ZEPHYR_MF_RUNTIME_PLUGIN_ID);
16
+ mfConfig.runtimePlugins = runtimePlugins;
17
+ return mfConfig;
18
+ }
19
+ export { RESOLVED_ZEPHYR_MF_RUNTIME_PLUGIN_ID, ZEPHYR_MF_RUNTIME_PLUGIN_ID, ensureRuntimePlugin, getRuntimePluginPath };
20
+
21
+ //# sourceMappingURL=ensure_runtime_plugin.mjs.map
@@ -0,0 +1,13 @@
1
+ import type { ZeDependencyPair } from 'zephyr-agent';
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;
13
+ //# sourceMappingURL=extract-mf-vite-remotes.d.mts.map
@@ -10,3 +10,4 @@ export interface PartialViteMFConfig {
10
10
  remotes?: Record<string, string | RemoteObjectConfig> | undefined;
11
11
  }
12
12
  export declare function extract_remotes_dependencies(root: string, mfConfig: PartialViteMFConfig): ZeDependencyPair[] | undefined;
13
+ //# sourceMappingURL=extract-mf-vite-remotes.d.ts.map
@@ -1,25 +1,61 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extract_remotes_dependencies = extract_remotes_dependencies;
4
- const zephyr_agent_1 = require("zephyr-agent");
5
- function extract_remotes_dependencies(root, mfConfig) {
6
- const { zephyrDependencies } = (0, zephyr_agent_1.readPackageJson)(root);
7
- if (zephyrDependencies) {
8
- return Object.entries(zephyrDependencies).map(([name, version]) => {
9
- return {
10
- name,
11
- version,
12
- };
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
13
25
  });
14
- }
15
- if (!mfConfig.remotes)
16
- return;
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 };
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ extract_remotes_dependencies: ()=>extract_remotes_dependencies
32
+ });
33
+ const external_zephyr_agent_namespaceObject = require("zephyr-agent");
34
+ function extract_remotes_dependencies(root, mfConfig) {
35
+ const { zephyrDependencies } = (0, external_zephyr_agent_namespaceObject.readPackageJson)(root);
36
+ if (zephyrDependencies) return Object.entries(zephyrDependencies).map(([name, version])=>({
37
+ name,
38
+ version
39
+ }));
40
+ if (!mfConfig.remotes) return;
41
+ const dependencyPairs = Object.entries(mfConfig.remotes).map(([name, remote])=>{
42
+ if ('string' == typeof remote) return {
43
+ name,
44
+ version: remote
45
+ };
46
+ return {
47
+ name,
48
+ version: remote.entry
49
+ };
22
50
  });
23
51
  return dependencyPairs;
24
52
  }
53
+ exports.extract_remotes_dependencies = __webpack_exports__.extract_remotes_dependencies;
54
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
55
+ "extract_remotes_dependencies"
56
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
57
+ Object.defineProperty(exports, '__esModule', {
58
+ value: true
59
+ });
60
+
25
61
  //# sourceMappingURL=extract-mf-vite-remotes.js.map
@@ -0,0 +1,24 @@
1
+ import "node:module";
2
+ import { readPackageJson } from "zephyr-agent";
3
+ function extract_remotes_dependencies(root, mfConfig) {
4
+ const { zephyrDependencies } = readPackageJson(root);
5
+ if (zephyrDependencies) return Object.entries(zephyrDependencies).map(([name, version])=>({
6
+ name,
7
+ version
8
+ }));
9
+ if (!mfConfig.remotes) return;
10
+ const dependencyPairs = Object.entries(mfConfig.remotes).map(([name, remote])=>{
11
+ if ('string' == typeof remote) return {
12
+ name,
13
+ version: remote
14
+ };
15
+ return {
16
+ name,
17
+ version: remote.entry
18
+ };
19
+ });
20
+ return dependencyPairs;
21
+ }
22
+ export { extract_remotes_dependencies };
23
+
24
+ //# sourceMappingURL=extract-mf-vite-remotes.mjs.map
@@ -0,0 +1,38 @@
1
+ import type { ModuleFederationManifestOptions, ModuleFederationOptions } from './ensure_runtime_plugin.mjs';
2
+ /** The established single-container snapshot shape. */
3
+ export interface ViteLegacyModuleFederationConfig {
4
+ name: string;
5
+ filename: string;
6
+ exposes?: Record<string, string>;
7
+ remotes?: Record<string, string>;
8
+ shared?: Record<string, unknown>;
9
+ runtimePlugins?: string[];
10
+ manifest?: boolean | ModuleFederationManifestOptions;
11
+ }
12
+ /** Serializable dashboard metadata for one independently addressable Vite container. */
13
+ export interface ViteModuleFederationBuildMetadata {
14
+ name?: string;
15
+ remote?: string;
16
+ mf_manifest?: string;
17
+ library_type?: string;
18
+ exposes?: ModuleFederationOptions['exposes'];
19
+ shared?: ModuleFederationOptions['shared'];
20
+ }
21
+ export interface ViteModuleFederationPublicationMetadata {
22
+ mfConfig?: ViteLegacyModuleFederationConfig;
23
+ mfConfigs?: ModuleFederationOptions[];
24
+ federation?: ViteModuleFederationBuildMetadata[];
25
+ }
26
+ /**
27
+ * A Vite MF container is publicly identified by its `name` and emitted entry `filename`.
28
+ * Two configs that share either identity describe the same container.
29
+ */
30
+ export declare function getConfigIdentities(config: ModuleFederationOptions): string[];
31
+ /**
32
+ * Snapshot metadata must include every configured Vite container. Exact duplicate plugin
33
+ * wrappers are harmless, while divergent configs with one public identity are ambiguous
34
+ * and must fail before a snapshot chooses one arbitrarily.
35
+ */
36
+ export declare function mergeViteModuleFederationConfigs(configLists: readonly (readonly ModuleFederationOptions[] | undefined)[]): ModuleFederationOptions[];
37
+ export declare function createViteModuleFederationPublicationMetadata(configs: readonly ModuleFederationOptions[]): ViteModuleFederationPublicationMetadata;
38
+ //# sourceMappingURL=federation-metadata.d.mts.map
@@ -0,0 +1,38 @@
1
+ import type { ModuleFederationManifestOptions, ModuleFederationOptions } from './ensure_runtime_plugin';
2
+ /** The established single-container snapshot shape. */
3
+ export interface ViteLegacyModuleFederationConfig {
4
+ name: string;
5
+ filename: string;
6
+ exposes?: Record<string, string>;
7
+ remotes?: Record<string, string>;
8
+ shared?: Record<string, unknown>;
9
+ runtimePlugins?: string[];
10
+ manifest?: boolean | ModuleFederationManifestOptions;
11
+ }
12
+ /** Serializable dashboard metadata for one independently addressable Vite container. */
13
+ export interface ViteModuleFederationBuildMetadata {
14
+ name?: string;
15
+ remote?: string;
16
+ mf_manifest?: string;
17
+ library_type?: string;
18
+ exposes?: ModuleFederationOptions['exposes'];
19
+ shared?: ModuleFederationOptions['shared'];
20
+ }
21
+ export interface ViteModuleFederationPublicationMetadata {
22
+ mfConfig?: ViteLegacyModuleFederationConfig;
23
+ mfConfigs?: ModuleFederationOptions[];
24
+ federation?: ViteModuleFederationBuildMetadata[];
25
+ }
26
+ /**
27
+ * A Vite MF container is publicly identified by its `name` and emitted entry `filename`.
28
+ * Two configs that share either identity describe the same container.
29
+ */
30
+ export declare function getConfigIdentities(config: ModuleFederationOptions): string[];
31
+ /**
32
+ * Snapshot metadata must include every configured Vite container. Exact duplicate plugin
33
+ * wrappers are harmless, while divergent configs with one public identity are ambiguous
34
+ * and must fail before a snapshot chooses one arbitrarily.
35
+ */
36
+ export declare function mergeViteModuleFederationConfigs(configLists: readonly (readonly ModuleFederationOptions[] | undefined)[]): ModuleFederationOptions[];
37
+ export declare function createViteModuleFederationPublicationMetadata(configs: readonly ModuleFederationOptions[]): ViteModuleFederationPublicationMetadata;
38
+ //# sourceMappingURL=federation-metadata.d.ts.map
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ createViteModuleFederationPublicationMetadata: ()=>createViteModuleFederationPublicationMetadata,
32
+ getConfigIdentities: ()=>getConfigIdentities,
33
+ mergeViteModuleFederationConfigs: ()=>mergeViteModuleFederationConfigs
34
+ });
35
+ const external_zephyr_agent_namespaceObject = require("zephyr-agent");
36
+ function nonEmptyString(value) {
37
+ return 'string' == typeof value && value.trim() ? value : void 0;
38
+ }
39
+ function serializeConfig(config) {
40
+ try {
41
+ const serialized = JSON.stringify(config);
42
+ if (!serialized) throw new Error('configuration did not serialize to JSON');
43
+ return JSON.parse(serialized);
44
+ } catch {
45
+ throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
46
+ message: 'Vite Module Federation configuration must be JSON-serializable before Zephyr can publish it.'
47
+ });
48
+ }
49
+ }
50
+ function stableJson(value) {
51
+ if (null === value || 'object' != typeof value) return JSON.stringify(value) ?? 'undefined';
52
+ if (Array.isArray(value)) return `[${value.map((item)=>stableJson(item)).join(',')}]`;
53
+ const record = value;
54
+ return `{${Object.keys(record).sort().map((key)=>`${JSON.stringify(key)}:${stableJson(record[key])}`).join(',')}}`;
55
+ }
56
+ function getConfigIdentities(config) {
57
+ return [
58
+ nonEmptyString(config.name) ? `name:${config.name}` : void 0,
59
+ nonEmptyString(config.filename) ? `entry:${config.filename}` : void 0
60
+ ].filter((identity)=>!!identity);
61
+ }
62
+ function mergeViteModuleFederationConfigs(configLists) {
63
+ const byFingerprint = new Set();
64
+ const byIdentity = new Map();
65
+ const merged = [];
66
+ for (const sourceConfig of configLists.flatMap((configs)=>configs ?? [])){
67
+ const config = serializeConfig(sourceConfig);
68
+ const fingerprint = stableJson(config);
69
+ if (!byFingerprint.has(fingerprint)) {
70
+ for (const identity of getConfigIdentities(config)){
71
+ const existing = byIdentity.get(identity);
72
+ if (existing && existing !== fingerprint) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
73
+ message: `Conflicting Vite Module Federation configuration for ${identity}.`
74
+ });
75
+ }
76
+ byFingerprint.add(fingerprint);
77
+ for (const identity of getConfigIdentities(config))byIdentity.set(identity, fingerprint);
78
+ merged.push(config);
79
+ }
80
+ }
81
+ return merged;
82
+ }
83
+ function stringRecord(value) {
84
+ if (!value || 'object' != typeof value || Array.isArray(value) || !Object.values(value).every((entry)=>'string' == typeof entry)) return;
85
+ return value;
86
+ }
87
+ function getLegacyConfig(configs) {
88
+ const config = 1 === configs.length ? configs[0] : void 0;
89
+ const name = nonEmptyString(config?.name);
90
+ const filename = nonEmptyString(config?.filename);
91
+ if (!config || !name || !filename) return;
92
+ const remotes = stringRecord(config.remotes);
93
+ return {
94
+ name,
95
+ filename,
96
+ ...config.exposes ? {
97
+ exposes: config.exposes
98
+ } : {},
99
+ ...remotes ? {
100
+ remotes
101
+ } : {},
102
+ ...config.shared ? {
103
+ shared: config.shared
104
+ } : {},
105
+ ...config.runtimePlugins ? {
106
+ runtimePlugins: config.runtimePlugins
107
+ } : {},
108
+ ...void 0 !== config.manifest ? {
109
+ manifest: config.manifest
110
+ } : {}
111
+ };
112
+ }
113
+ function libraryType(library) {
114
+ if ('string' == typeof library) return library;
115
+ if (library && !Array.isArray(library)) return library.type;
116
+ }
117
+ function createViteModuleFederationPublicationMetadata(configs) {
118
+ const mfConfigs = mergeViteModuleFederationConfigs([
119
+ configs
120
+ ]);
121
+ const mfConfig = getLegacyConfig(mfConfigs);
122
+ const federation = mfConfigs.map((config)=>({
123
+ name: config.name,
124
+ remote: config.filename,
125
+ mf_manifest: (0, external_zephyr_agent_namespaceObject.resolveMfManifestPath)(config.manifest),
126
+ library_type: libraryType(config.library),
127
+ exposes: config.exposes,
128
+ shared: config.shared
129
+ }));
130
+ return {
131
+ ...mfConfigs.length > 0 ? {
132
+ mfConfigs
133
+ } : {},
134
+ ...mfConfig ? {
135
+ mfConfig
136
+ } : {},
137
+ ...federation.length > 0 ? {
138
+ federation
139
+ } : {}
140
+ };
141
+ }
142
+ exports.createViteModuleFederationPublicationMetadata = __webpack_exports__.createViteModuleFederationPublicationMetadata;
143
+ exports.getConfigIdentities = __webpack_exports__.getConfigIdentities;
144
+ exports.mergeViteModuleFederationConfigs = __webpack_exports__.mergeViteModuleFederationConfigs;
145
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
146
+ "createViteModuleFederationPublicationMetadata",
147
+ "getConfigIdentities",
148
+ "mergeViteModuleFederationConfigs"
149
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
150
+ Object.defineProperty(exports, '__esModule', {
151
+ value: true
152
+ });
153
+
154
+ //# sourceMappingURL=federation-metadata.js.map
@@ -0,0 +1,111 @@
1
+ import "node:module";
2
+ import { ZeErrors, ZephyrError, resolveMfManifestPath } from "zephyr-agent";
3
+ function nonEmptyString(value) {
4
+ return 'string' == typeof value && value.trim() ? value : void 0;
5
+ }
6
+ function serializeConfig(config) {
7
+ try {
8
+ const serialized = JSON.stringify(config);
9
+ if (!serialized) throw new Error('configuration did not serialize to JSON');
10
+ return JSON.parse(serialized);
11
+ } catch {
12
+ throw new ZephyrError(ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
13
+ message: 'Vite Module Federation configuration must be JSON-serializable before Zephyr can publish it.'
14
+ });
15
+ }
16
+ }
17
+ function stableJson(value) {
18
+ if (null === value || 'object' != typeof value) return JSON.stringify(value) ?? 'undefined';
19
+ if (Array.isArray(value)) return `[${value.map((item)=>stableJson(item)).join(',')}]`;
20
+ const record = value;
21
+ return `{${Object.keys(record).sort().map((key)=>`${JSON.stringify(key)}:${stableJson(record[key])}`).join(',')}}`;
22
+ }
23
+ function getConfigIdentities(config) {
24
+ return [
25
+ nonEmptyString(config.name) ? `name:${config.name}` : void 0,
26
+ nonEmptyString(config.filename) ? `entry:${config.filename}` : void 0
27
+ ].filter((identity)=>!!identity);
28
+ }
29
+ function mergeViteModuleFederationConfigs(configLists) {
30
+ const byFingerprint = new Set();
31
+ const byIdentity = new Map();
32
+ const merged = [];
33
+ for (const sourceConfig of configLists.flatMap((configs)=>configs ?? [])){
34
+ const config = serializeConfig(sourceConfig);
35
+ const fingerprint = stableJson(config);
36
+ if (!byFingerprint.has(fingerprint)) {
37
+ for (const identity of getConfigIdentities(config)){
38
+ const existing = byIdentity.get(identity);
39
+ if (existing && existing !== fingerprint) throw new ZephyrError(ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
40
+ message: `Conflicting Vite Module Federation configuration for ${identity}.`
41
+ });
42
+ }
43
+ byFingerprint.add(fingerprint);
44
+ for (const identity of getConfigIdentities(config))byIdentity.set(identity, fingerprint);
45
+ merged.push(config);
46
+ }
47
+ }
48
+ return merged;
49
+ }
50
+ function stringRecord(value) {
51
+ if (!value || 'object' != typeof value || Array.isArray(value) || !Object.values(value).every((entry)=>'string' == typeof entry)) return;
52
+ return value;
53
+ }
54
+ function getLegacyConfig(configs) {
55
+ const config = 1 === configs.length ? configs[0] : void 0;
56
+ const name = nonEmptyString(config?.name);
57
+ const filename = nonEmptyString(config?.filename);
58
+ if (!config || !name || !filename) return;
59
+ const remotes = stringRecord(config.remotes);
60
+ return {
61
+ name,
62
+ filename,
63
+ ...config.exposes ? {
64
+ exposes: config.exposes
65
+ } : {},
66
+ ...remotes ? {
67
+ remotes
68
+ } : {},
69
+ ...config.shared ? {
70
+ shared: config.shared
71
+ } : {},
72
+ ...config.runtimePlugins ? {
73
+ runtimePlugins: config.runtimePlugins
74
+ } : {},
75
+ ...void 0 !== config.manifest ? {
76
+ manifest: config.manifest
77
+ } : {}
78
+ };
79
+ }
80
+ function libraryType(library) {
81
+ if ('string' == typeof library) return library;
82
+ if (library && !Array.isArray(library)) return library.type;
83
+ }
84
+ function createViteModuleFederationPublicationMetadata(configs) {
85
+ const mfConfigs = mergeViteModuleFederationConfigs([
86
+ configs
87
+ ]);
88
+ const mfConfig = getLegacyConfig(mfConfigs);
89
+ const federation = mfConfigs.map((config)=>({
90
+ name: config.name,
91
+ remote: config.filename,
92
+ mf_manifest: resolveMfManifestPath(config.manifest),
93
+ library_type: libraryType(config.library),
94
+ exposes: config.exposes,
95
+ shared: config.shared
96
+ }));
97
+ return {
98
+ ...mfConfigs.length > 0 ? {
99
+ mfConfigs
100
+ } : {},
101
+ ...mfConfig ? {
102
+ mfConfig
103
+ } : {},
104
+ ...federation.length > 0 ? {
105
+ federation
106
+ } : {}
107
+ };
108
+ }
109
+ export { createViteModuleFederationPublicationMetadata, getConfigIdentities, mergeViteModuleFederationConfigs };
110
+
111
+ //# sourceMappingURL=federation-metadata.mjs.map