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
@@ -0,0 +1,51 @@
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
+ normalizeFilesystemVitePath: ()=>normalizeFilesystemVitePath,
32
+ normalizeVitePath: ()=>normalizeVitePath
33
+ });
34
+ const external_node_path_namespaceObject = require("node:path");
35
+ function normalizeVitePath(pathname) {
36
+ return pathname.replace(/\\/g, '/');
37
+ }
38
+ function normalizeFilesystemVitePath(pathname) {
39
+ return pathname.split(external_node_path_namespaceObject.sep).join('/');
40
+ }
41
+ exports.normalizeFilesystemVitePath = __webpack_exports__.normalizeFilesystemVitePath;
42
+ exports.normalizeVitePath = __webpack_exports__.normalizeVitePath;
43
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
44
+ "normalizeFilesystemVitePath",
45
+ "normalizeVitePath"
46
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
47
+ Object.defineProperty(exports, '__esModule', {
48
+ value: true
49
+ });
50
+
51
+ //# sourceMappingURL=normalize-vite-path.js.map
@@ -0,0 +1,11 @@
1
+ import "node:module";
2
+ import { sep } from "node:path";
3
+ function normalizeVitePath(pathname) {
4
+ return pathname.replace(/\\/g, '/');
5
+ }
6
+ function normalizeFilesystemVitePath(pathname) {
7
+ return pathname.split(sep).join('/');
8
+ }
9
+ export { normalizeFilesystemVitePath, normalizeVitePath };
10
+
11
+ //# sourceMappingURL=normalize-vite-path.mjs.map
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite' with {
2
+ 'resolution-mode': 'import'
3
+ };
4
+ import { type VitePartialBuildOptions } from './internal/partial-build-scope.mjs';
5
+ export declare function withZephyrPartial(options?: VitePartialBuildOptions): Plugin;
6
+ //# sourceMappingURL=vite-plugin-zephyr-partial.d.mts.map
@@ -1,9 +1,6 @@
1
- import type { NormalizedOutputOptions, OutputBundle } from 'rollup';
2
- import type { ResolvedConfig } from 'vite';
3
- export declare function withZephyrPartial(): {
4
- name: string;
5
- apply: string;
6
- enforce: string;
7
- configResolved: (config: ResolvedConfig) => Promise<void>;
8
- writeBundle: (options: NormalizedOutputOptions, bundle: OutputBundle) => Promise<void>;
1
+ import type { Plugin } from 'vite' with {
2
+ 'resolution-mode': 'import'
9
3
  };
4
+ import { type VitePartialBuildOptions } from './internal/partial-build-scope';
5
+ export declare function withZephyrPartial(options?: VitePartialBuildOptions): Plugin;
6
+ //# sourceMappingURL=vite-plugin-zephyr-partial.d.ts.map
@@ -1,53 +1,101 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withZephyrPartial = withZephyrPartial;
4
- const zephyr_agent_1 = require("zephyr-agent");
5
- const extract_vite_assets_map_1 = require("./internal/extract/extract_vite_assets_map");
6
- function withZephyrPartial() {
7
- const { zephyr_engine_defer, zephyr_defer_create } = zephyr_agent_1.ZephyrEngine.defer_create();
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
+ withZephyrPartial: ()=>withZephyrPartial
32
+ });
33
+ const external_node_path_namespaceObject = require("node:path");
34
+ const external_zephyr_agent_namespaceObject = require("zephyr-agent");
35
+ const extract_vite_assets_map_js_namespaceObject = require("./internal/extract/extract_vite_assets_map.js");
36
+ const partial_build_scope_js_namespaceObject = require("./internal/partial-build-scope.js");
37
+ function withZephyrPartial(options = {}) {
38
+ if (void 0 !== options.target) (0, external_zephyr_agent_namespaceObject.assertZephyrBuildTarget)(options.target, 'withZephyrPartial({ target })');
39
+ const { zephyr_engine_defer, zephyr_defer_create } = external_zephyr_agent_namespaceObject.ZephyrEngine.defer_create();
40
+ let partialScope;
8
41
  let resolve_vite_internal_options;
9
- const vite_internal_options_defer = new Promise((resolve) => {
42
+ const vite_internal_options_defer = new Promise((resolve)=>{
10
43
  resolve_vite_internal_options = resolve;
11
44
  });
12
45
  return {
13
46
  name: 'with-zephyr-partial',
14
47
  apply: 'build',
15
48
  enforce: 'post',
16
- configResolved: async (config) => {
49
+ configResolved: async (config)=>{
50
+ partialScope = (0, partial_build_scope_js_namespaceObject.requireVitePartialBuildScope)(options);
17
51
  zephyr_defer_create({
18
52
  builder: 'vite',
19
53
  context: config.root,
54
+ target: options.target
20
55
  });
21
56
  resolve_vite_internal_options({
22
57
  root: config.root,
23
58
  configFile: config.configFile,
24
59
  outDir: config.build.outDir,
25
60
  publicDir: config.publicDir,
61
+ target: options.target
26
62
  });
27
63
  },
28
- // writeBundle is called after files are written to disk - safe to read from filesystem
29
- writeBundle: async (options, bundle) => {
30
- var _a;
31
- const vite_internal_options = await vite_internal_options_defer;
32
- vite_internal_options.dir = options.dir;
33
- vite_internal_options.assets = bundle;
34
- // Extract and save assets after bundle is written to disk
64
+ writeBundle: async function(options, bundle) {
65
+ const baseOptions = await vite_internal_options_defer;
66
+ const environmentName = this.environment?.name;
67
+ const outputDir = external_node_path_namespaceObject.resolve(baseOptions.root, options.dir ?? (options.file ? external_node_path_namespaceObject.dirname(options.file) : baseOptions.outDir));
68
+ const vite_internal_options = {
69
+ ...baseOptions,
70
+ dir: options.dir,
71
+ outDir: outputDir,
72
+ assets: bundle
73
+ };
35
74
  try {
75
+ if (!partialScope) throw new external_zephyr_agent_namespaceObject.ZephyrError(external_zephyr_agent_namespaceObject.ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
76
+ message: 'Vite partial build scope was not resolved before writeBundle.'
77
+ });
36
78
  const zephyr_engine = await zephyr_engine_defer;
37
79
  const application_uid = zephyr_engine.application_uid;
38
- const assetsMap = await (0, extract_vite_assets_map_1.extract_vite_assets_map)(zephyr_engine, vite_internal_options);
39
- await (0, zephyr_agent_1.savePartialAssetMap)(application_uid, (_a = vite_internal_options.configFile) !== null && _a !== void 0 ? _a : 'partial', assetsMap);
40
- // todo: initially partial build doesn't have deploy, but code below could enable it if needed
41
- // await zephyr_engine.upload_assets({
42
- // assetsMap,
43
- // // todo: this should be updated if we have remotes
44
- // buildStats: await zeBuildDashData(zephyr_engine),
45
- // });
80
+ const assetsMap = await (0, extract_vite_assets_map_js_namespaceObject.extract_vite_assets_map)(zephyr_engine, vite_internal_options);
81
+ await (0, external_zephyr_agent_namespaceObject.savePartialAssetMap)(application_uid, [
82
+ 'vite-partial',
83
+ vite_internal_options.configFile ?? 'partial',
84
+ environmentName ?? 'default',
85
+ outputDir.replace(/\\/g, '/')
86
+ ].join(':'), assetsMap, partialScope);
87
+ } catch (error) {
88
+ (0, external_zephyr_agent_namespaceObject.handleGlobalError)(error);
46
89
  }
47
- catch (error) {
48
- (0, zephyr_agent_1.logFn)('error', zephyr_agent_1.ZephyrError.format(error));
49
- }
50
- },
90
+ }
51
91
  };
52
92
  }
93
+ exports.withZephyrPartial = __webpack_exports__.withZephyrPartial;
94
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
95
+ "withZephyrPartial"
96
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
97
+ Object.defineProperty(exports, '__esModule', {
98
+ value: true
99
+ });
100
+
53
101
  //# sourceMappingURL=vite-plugin-zephyr-partial.js.map
@@ -0,0 +1,64 @@
1
+ import "node:module";
2
+ import { ZeErrors, ZephyrEngine, ZephyrError, assertZephyrBuildTarget, handleGlobalError, savePartialAssetMap } from "zephyr-agent";
3
+ import { extract_vite_assets_map } from "./internal/extract/extract_vite_assets_map.mjs";
4
+ import { requireVitePartialBuildScope } from "./internal/partial-build-scope.mjs";
5
+ import * as __rspack_external_node_path_806ed179 from "node:path";
6
+ function withZephyrPartial(options = {}) {
7
+ if (void 0 !== options.target) assertZephyrBuildTarget(options.target, 'withZephyrPartial({ target })');
8
+ const { zephyr_engine_defer, zephyr_defer_create } = ZephyrEngine.defer_create();
9
+ let partialScope;
10
+ let resolve_vite_internal_options;
11
+ const vite_internal_options_defer = new Promise((resolve)=>{
12
+ resolve_vite_internal_options = resolve;
13
+ });
14
+ return {
15
+ name: 'with-zephyr-partial',
16
+ apply: 'build',
17
+ enforce: 'post',
18
+ configResolved: async (config)=>{
19
+ partialScope = requireVitePartialBuildScope(options);
20
+ zephyr_defer_create({
21
+ builder: 'vite',
22
+ context: config.root,
23
+ target: options.target
24
+ });
25
+ resolve_vite_internal_options({
26
+ root: config.root,
27
+ configFile: config.configFile,
28
+ outDir: config.build.outDir,
29
+ publicDir: config.publicDir,
30
+ target: options.target
31
+ });
32
+ },
33
+ writeBundle: async function(options, bundle) {
34
+ const baseOptions = await vite_internal_options_defer;
35
+ const environmentName = this.environment?.name;
36
+ const outputDir = __rspack_external_node_path_806ed179.resolve(baseOptions.root, options.dir ?? (options.file ? __rspack_external_node_path_806ed179.dirname(options.file) : baseOptions.outDir));
37
+ const vite_internal_options = {
38
+ ...baseOptions,
39
+ dir: options.dir,
40
+ outDir: outputDir,
41
+ assets: bundle
42
+ };
43
+ try {
44
+ if (!partialScope) throw new ZephyrError(ZeErrors.ERR_DEPLOY_LOCAL_BUILD, {
45
+ message: 'Vite partial build scope was not resolved before writeBundle.'
46
+ });
47
+ const zephyr_engine = await zephyr_engine_defer;
48
+ const application_uid = zephyr_engine.application_uid;
49
+ const assetsMap = await extract_vite_assets_map(zephyr_engine, vite_internal_options);
50
+ await savePartialAssetMap(application_uid, [
51
+ 'vite-partial',
52
+ vite_internal_options.configFile ?? 'partial',
53
+ environmentName ?? 'default',
54
+ outputDir.replace(/\\/g, '/')
55
+ ].join(':'), assetsMap, partialScope);
56
+ } catch (error) {
57
+ handleGlobalError(error);
58
+ }
59
+ }
60
+ };
61
+ }
62
+ export { withZephyrPartial };
63
+
64
+ //# sourceMappingURL=vite-plugin-zephyr-partial.mjs.map
@@ -0,0 +1,21 @@
1
+ import type { Plugin } from 'vite' with {
2
+ 'resolution-mode': 'import'
3
+ };
4
+ import { type ZephyrBuildHooks, type ZephyrBuildTarget } from 'zephyr-agent';
5
+ import { type ModuleFederationOptions } from './internal/mf-vite-etl/ensure_runtime_plugin.mjs';
6
+ import { type VitePartialBuildOptions } from './internal/partial-build-scope.mjs';
7
+ export interface WithZephyrOptions {
8
+ /** Zephyr build target, including the `tap-app` mini-app artifact family. */
9
+ target?: ZephyrBuildTarget;
10
+ hooks?: ZephyrBuildHooks;
11
+ /** One or more Module Federation containers emitted by this Vite build. */
12
+ mfConfig?: ModuleFederationOptions | ModuleFederationOptions[];
13
+ /** Override automatic CSR/SSR detection for Vite environment builds. */
14
+ snapshotType?: 'csr' | 'ssr';
15
+ /** Server entrypoint relative to the shared snapshot root. */
16
+ entrypoint?: string;
17
+ /** Correlates intentionally separate withZephyrPartial producer processes. */
18
+ partialBuild?: VitePartialBuildOptions;
19
+ }
20
+ export declare function withZephyr(options?: WithZephyrOptions): Plugin[];
21
+ //# sourceMappingURL=vite-plugin-zephyr.d.mts.map
@@ -1,8 +1,21 @@
1
- import { type Plugin } from 'vite';
2
- import { type ZephyrBuildHooks } from 'zephyr-agent';
1
+ import type { Plugin } from 'vite' with {
2
+ 'resolution-mode': 'import'
3
+ };
4
+ import { type ZephyrBuildHooks, type ZephyrBuildTarget } from 'zephyr-agent';
3
5
  import { type ModuleFederationOptions } from './internal/mf-vite-etl/ensure_runtime_plugin';
6
+ import { type VitePartialBuildOptions } from './internal/partial-build-scope';
4
7
  export interface WithZephyrOptions {
8
+ /** Zephyr build target, including the `tap-app` mini-app artifact family. */
9
+ target?: ZephyrBuildTarget;
5
10
  hooks?: ZephyrBuildHooks;
6
- mfConfig?: ModuleFederationOptions;
11
+ /** One or more Module Federation containers emitted by this Vite build. */
12
+ mfConfig?: ModuleFederationOptions | ModuleFederationOptions[];
13
+ /** Override automatic CSR/SSR detection for Vite environment builds. */
14
+ snapshotType?: 'csr' | 'ssr';
15
+ /** Server entrypoint relative to the shared snapshot root. */
16
+ entrypoint?: string;
17
+ /** Correlates intentionally separate withZephyrPartial producer processes. */
18
+ partialBuild?: VitePartialBuildOptions;
7
19
  }
8
20
  export declare function withZephyr(options?: WithZephyrOptions): Plugin[];
21
+ //# sourceMappingURL=vite-plugin-zephyr.d.ts.map