@vc-shell/mf-module 2.0.0-alpha.11

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/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # [2.0.0-alpha.11](https://github.com/VirtoCommerce/vc-shell/compare/v2.0.0-alpha.10...v2.0.0-alpha.11) (2026-03-13)
2
+
3
+ **Note:** Version bump only for package @vc-shell/mf-module
4
+
5
+ # [2.0.0-alpha.10](https://github.com/VirtoCommerce/vc-shell/compare/v2.0.0-alpha.9...v2.0.0-alpha.10) (2026-03-13)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **mf-module:** add exports field for proper ESM resolution ([a951353](https://github.com/VirtoCommerce/vc-shell/commit/a951353743aa0d583c7cb206b6a84be3781b8477))
11
+
12
+
13
+ ### Features
14
+
15
+ * **mf-module:** create package for remote module build config ([5cde74b](https://github.com/VirtoCommerce/vc-shell/commit/5cde74b8c7e6369da79d98c5d43edbc451681744))
@@ -0,0 +1,7 @@
1
+ import type { UserConfig } from "vite";
2
+ import type { DynamicModuleOptions } from "./types.js";
3
+ export default function dynamicModuleConfiguration(pkg: {
4
+ name: string;
5
+ version: string;
6
+ }, options: DynamicModuleOptions): UserConfig;
7
+ //# sourceMappingURL=dynamic-module-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-module-config.d.ts","sourceRoot":"","sources":["../src/dynamic-module-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACtC,OAAO,EAAE,oBAAoB,GAC5B,UAAU,CAsBZ"}
@@ -0,0 +1,27 @@
1
+ import vue from "@vitejs/plugin-vue";
2
+ import { federation } from "@module-federation/vite";
3
+ import { REMOTE_SHARED } from "@vc-shell/mf-config";
4
+ import { stripExternalStyles } from "./strip-external-styles.js";
5
+ export default function dynamicModuleConfiguration(pkg, options) {
6
+ const entry = options.entry ?? "./src/modules/index.ts";
7
+ return {
8
+ plugins: [
9
+ stripExternalStyles(),
10
+ vue(),
11
+ federation({
12
+ name: pkg.name,
13
+ filename: "remoteEntry.js",
14
+ exposes: options.exposes ?? {
15
+ "./module": entry,
16
+ },
17
+ shared: { ...REMOTE_SHARED },
18
+ dts: false,
19
+ }),
20
+ ],
21
+ build: {
22
+ target: "esnext",
23
+ outDir: "dist",
24
+ },
25
+ };
26
+ }
27
+ //# sourceMappingURL=dynamic-module-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamic-module-config.js","sourceRoot":"","sources":["../src/dynamic-module-config.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,GAAsC,EACtC,OAA6B;IAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,wBAAwB,CAAC;IAExD,OAAO;QACL,OAAO,EAAE;YACP,mBAAmB,EAAE;YACrB,GAAG,EAAE;YACL,UAAU,CAAC;gBACT,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,QAAQ,EAAE,gBAAgB;gBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI;oBAC1B,UAAU,EAAE,KAAK;iBAClB;gBACD,MAAM,EAAE,EAAE,GAAG,aAAa,EAAE;gBAC5B,GAAG,EAAE,KAAK;aACX,CAAC;SACH;QACD,KAAK,EAAE;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,MAAM;SACf;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type UserConfig } from "vite";
2
+ import type { DynamicModuleOptions } from "./types.js";
3
+ export type { DynamicModuleOptions, CompatibilityOptions } from "./types.js";
4
+ export { stripExternalStyles } from "./strip-external-styles.js";
5
+ /**
6
+ * Generate a Vite configuration for a dynamic MF module.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // vite.config.ts
11
+ * import { getDynamicModuleConfiguration } from "@vc-shell/mf-module";
12
+ *
13
+ * export default getDynamicModuleConfiguration({
14
+ * compatibility: { framework: "^2.0.0" },
15
+ * });
16
+ * ```
17
+ */
18
+ export declare function getDynamicModuleConfiguration(options: DynamicModuleOptions): UserConfig;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAKpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAY9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,oBAAoB,GAAG,UAAU,CAMvF"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ import { mergeConfig } from "vite";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import { cwd } from "node:process";
5
+ import dynamicModuleConfiguration from "./dynamic-module-config.js";
6
+ export { stripExternalStyles } from "./strip-external-styles.js";
7
+ const getPackageJson = () => {
8
+ try {
9
+ const packageJsonPath = join(cwd(), "package.json");
10
+ return JSON.parse(readFileSync(packageJsonPath, "utf-8"));
11
+ }
12
+ catch (error) {
13
+ console.error("Error reading package.json:", error);
14
+ return { name: "unknown-module", version: "0.0.0", dependencies: {} };
15
+ }
16
+ };
17
+ /**
18
+ * Generate a Vite configuration for a dynamic MF module.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // vite.config.ts
23
+ * import { getDynamicModuleConfiguration } from "@vc-shell/mf-module";
24
+ *
25
+ * export default getDynamicModuleConfiguration({
26
+ * compatibility: { framework: "^2.0.0" },
27
+ * });
28
+ * ```
29
+ */
30
+ export function getDynamicModuleConfiguration(options) {
31
+ const pkg = getPackageJson();
32
+ console.log(`Building dynamic module: ${pkg.name}@${pkg.version}`);
33
+ const baseConfig = dynamicModuleConfiguration(pkg, options);
34
+ return mergeConfig(baseConfig, options);
35
+ }
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,0BAA0B,MAAM,yBAAyB,CAAC;AAIjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACxE,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAA6B;IACzE,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,4BAA4B,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,0BAA0B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,OAAO,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Strips CSS/style from shared dependencies and files outside the module root.
4
+ * Remote MF modules should not emit CSS from shared deps (framework, vue, etc.)
5
+ * because the host app already provides all base styles, component CSS, and fonts.
6
+ *
7
+ * Uses SHARED_DEP_NAMES as the single source of truth — the same list that
8
+ * controls JS sharing also controls CSS exclusion.
9
+ */
10
+ export declare function stripExternalStyles(): Plugin;
11
+ //# sourceMappingURL=strip-external-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-external-styles.d.ts","sourceRoot":"","sources":["../src/strip-external-styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAMnC;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CA4C5C"}
@@ -0,0 +1,56 @@
1
+ import { SHARED_DEP_NAMES } from "@vc-shell/mf-config";
2
+ import { cwd } from "node:process";
3
+ import { resolve } from "node:path";
4
+ import { realpathSync } from "node:fs";
5
+ /**
6
+ * Strips CSS/style from shared dependencies and files outside the module root.
7
+ * Remote MF modules should not emit CSS from shared deps (framework, vue, etc.)
8
+ * because the host app already provides all base styles, component CSS, and fonts.
9
+ *
10
+ * Uses SHARED_DEP_NAMES as the single source of truth — the same list that
11
+ * controls JS sharing also controls CSS exclusion.
12
+ */
13
+ export function stripExternalStyles() {
14
+ let normalizedRoot;
15
+ const sharedDepPatterns = SHARED_DEP_NAMES.map(name => `/node_modules/${name}/`);
16
+ return {
17
+ name: "strip-external-styles",
18
+ enforce: "pre",
19
+ buildStart() {
20
+ // Resolve symlinks once at build start, not at import time.
21
+ // This handles yarn link, portal:, and other symlink scenarios.
22
+ try {
23
+ normalizedRoot = realpathSync(resolve(cwd()));
24
+ }
25
+ catch {
26
+ normalizedRoot = resolve(cwd());
27
+ }
28
+ },
29
+ transform(code, id) {
30
+ const isStyleFile = /\.(css|scss|sass|less|styl)$/.test(id) || /type=style/.test(id);
31
+ if (!isStyleFile)
32
+ return null;
33
+ // Normalize the incoming id to handle symlinked deps
34
+ let normalizedId;
35
+ try {
36
+ // Strip query params (e.g. ?type=style) before resolving
37
+ const idPath = id.split("?")[0];
38
+ normalizedId = realpathSync(idPath);
39
+ }
40
+ catch {
41
+ normalizedId = id.split("?")[0];
42
+ }
43
+ // Rule 1: Strip styles from shared dependencies
44
+ if (sharedDepPatterns.some(p => normalizedId.includes(p))) {
45
+ return { code: "", map: null };
46
+ }
47
+ // Rule 2: Strip styles from files outside the module root (symlink/portal scenario)
48
+ if (!normalizedId.startsWith(normalizedRoot)) {
49
+ return { code: "", map: null };
50
+ }
51
+ // Rule 3: Keep everything else (module's own styles)
52
+ return null;
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=strip-external-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-external-styles.js","sourceRoot":"","sources":["../src/strip-external-styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;;;GAOG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AC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;gBAC7C,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;YACjC,CAAC;YAED,qDAAqD;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { UserConfig } from "vite";
2
+ /**
3
+ * Compatibility options for dynamic modules
4
+ */
5
+ export interface CompatibilityOptions {
6
+ /**
7
+ * Compatible framework version range
8
+ * @example "^1.1.0"
9
+ */
10
+ framework: string;
11
+ /**
12
+ * Compatible modules version ranges
13
+ * @example { "@vc-shell/module-catalog": "^1.0.0" }
14
+ */
15
+ modules?: Record<string, string>;
16
+ }
17
+ /**
18
+ * Dynamic module configuration options (Module Federation)
19
+ */
20
+ export interface DynamicModuleOptions extends UserConfig {
21
+ /**
22
+ * Entry point for the module
23
+ * @default "./src/modules/index.ts"
24
+ */
25
+ entry?: string;
26
+ /**
27
+ * Custom MF exposes map. Overrides default `{ "./module": entry }`.
28
+ */
29
+ exposes?: Record<string, string>;
30
+ /**
31
+ * Compatibility constraints (metadata only — not used during build).
32
+ * Used by the runtime registry API for version filtering.
33
+ */
34
+ compatibility?: CompatibilityOptions;
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;OAGG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@vc-shell/mf-module",
3
+ "description": "Module Federation build config for VC Shell remote modules",
4
+ "version": "2.0.0-alpha.11",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -b --clean && tsc && tsc-alias",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest"
21
+ },
22
+ "dependencies": {
23
+ "@module-federation/vite": "^1.12.2",
24
+ "@vc-shell/mf-config": "2.0.0-alpha.11"
25
+ },
26
+ "devDependencies": {
27
+ "@vc-shell/ts-config": "2.0.0-alpha.11",
28
+ "@vitejs/plugin-vue": "^5.2.3",
29
+ "tsc-alias": "^1.8.8",
30
+ "typescript": "^5.8.3",
31
+ "vite": "^6.0.0",
32
+ "vitest": "^3.2.4",
33
+ "vue": "^3.5.30"
34
+ },
35
+ "peerDependencies": {
36
+ "@vitejs/plugin-vue": "^5.0.0",
37
+ "vite": "^5.0.0 || ^6.0.0"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://registry.npmjs.org/"
42
+ }
43
+ }