@bleedingdev/modern-js-create 3.4.0-ultramodern.15 → 3.4.0-ultramodern.17

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.
@@ -124,6 +124,7 @@ function normalizeCompactConfig(workspaceRoot, sourcePath, config) {
124
124
  role: 'remote' === app.moduleFederation.role ? 'remote' : 'host',
125
125
  name: 'string' == typeof app.moduleFederation.name ? app.moduleFederation.name : void 0,
126
126
  exposes: Array.isArray(app.moduleFederation.exposes) ? app.moduleFederation.exposes.filter((expose)=>'string' == typeof expose) : void 0,
127
+ exposePaths: null === app.moduleFederation.exposePaths || 'object' != typeof app.moduleFederation.exposePaths || Array.isArray(app.moduleFederation.exposePaths) ? void 0 : Object.fromEntries(Object.entries(app.moduleFederation.exposePaths).filter((entry)=>'string' == typeof entry[0] && 'string' == typeof entry[1])),
127
128
  verticalRefs: Array.isArray(app.moduleFederation.verticalRefs) ? app.moduleFederation.verticalRefs.filter((ref)=>'string' == typeof ref) : void 0,
128
129
  hostOnly: true === app.moduleFederation.hostOnly,
129
130
  noExposes: true === app.moduleFederation.noExposes
@@ -212,10 +213,15 @@ function workspaceAppsFromToolingConfig(config) {
212
213
  };
213
214
  const domain = app.domain ?? app.id;
214
215
  const packageSuffix = app.packageSuffix ?? domain;
215
- const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>[
216
+ const exposePaths = app.moduleFederation?.exposePaths ?? {};
217
+ const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>{
218
+ const configuredPath = exposePaths[expose];
219
+ const inferredPath = './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : `./src/components/${(0, naming_cjs_namespaceObject.toKebabCase)(expose.replace(/^\.\//u, ''))}.tsx`;
220
+ return [
216
221
  expose,
217
- './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : ''
218
- ]));
222
+ configuredPath ?? inferredPath
223
+ ];
224
+ }));
219
225
  return {
220
226
  id: app.id,
221
227
  directory: app.path,
@@ -80,6 +80,7 @@ function normalizeCompactConfig(workspaceRoot, sourcePath, config) {
80
80
  role: 'remote' === app.moduleFederation.role ? 'remote' : 'host',
81
81
  name: 'string' == typeof app.moduleFederation.name ? app.moduleFederation.name : void 0,
82
82
  exposes: Array.isArray(app.moduleFederation.exposes) ? app.moduleFederation.exposes.filter((expose)=>'string' == typeof expose) : void 0,
83
+ exposePaths: null === app.moduleFederation.exposePaths || 'object' != typeof app.moduleFederation.exposePaths || Array.isArray(app.moduleFederation.exposePaths) ? void 0 : Object.fromEntries(Object.entries(app.moduleFederation.exposePaths).filter((entry)=>'string' == typeof entry[0] && 'string' == typeof entry[1])),
83
84
  verticalRefs: Array.isArray(app.moduleFederation.verticalRefs) ? app.moduleFederation.verticalRefs.filter((ref)=>'string' == typeof ref) : void 0,
84
85
  hostOnly: true === app.moduleFederation.hostOnly,
85
86
  noExposes: true === app.moduleFederation.noExposes
@@ -168,10 +169,15 @@ function workspaceAppsFromToolingConfig(config) {
168
169
  };
169
170
  const domain = app.domain ?? app.id;
170
171
  const packageSuffix = app.packageSuffix ?? domain;
171
- const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>[
172
+ const exposePaths = app.moduleFederation?.exposePaths ?? {};
173
+ const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>{
174
+ const configuredPath = exposePaths[expose];
175
+ const inferredPath = './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : `./src/components/${toKebabCase(expose.replace(/^\.\//u, ''))}.tsx`;
176
+ return [
172
177
  expose,
173
- './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : ''
174
- ]));
178
+ configuredPath ?? inferredPath
179
+ ];
180
+ }));
175
181
  return {
176
182
  id: app.id,
177
183
  directory: app.path,
@@ -81,6 +81,7 @@ function normalizeCompactConfig(workspaceRoot, sourcePath, config) {
81
81
  role: 'remote' === app.moduleFederation.role ? 'remote' : 'host',
82
82
  name: 'string' == typeof app.moduleFederation.name ? app.moduleFederation.name : void 0,
83
83
  exposes: Array.isArray(app.moduleFederation.exposes) ? app.moduleFederation.exposes.filter((expose)=>'string' == typeof expose) : void 0,
84
+ exposePaths: null === app.moduleFederation.exposePaths || 'object' != typeof app.moduleFederation.exposePaths || Array.isArray(app.moduleFederation.exposePaths) ? void 0 : Object.fromEntries(Object.entries(app.moduleFederation.exposePaths).filter((entry)=>'string' == typeof entry[0] && 'string' == typeof entry[1])),
84
85
  verticalRefs: Array.isArray(app.moduleFederation.verticalRefs) ? app.moduleFederation.verticalRefs.filter((ref)=>'string' == typeof ref) : void 0,
85
86
  hostOnly: true === app.moduleFederation.hostOnly,
86
87
  noExposes: true === app.moduleFederation.noExposes
@@ -169,10 +170,15 @@ function workspaceAppsFromToolingConfig(config) {
169
170
  };
170
171
  const domain = app.domain ?? app.id;
171
172
  const packageSuffix = app.packageSuffix ?? domain;
172
- const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>[
173
+ const exposePaths = app.moduleFederation?.exposePaths ?? {};
174
+ const exposes = Object.fromEntries((app.moduleFederation?.exposes ?? []).map((expose)=>{
175
+ const configuredPath = exposePaths[expose];
176
+ const inferredPath = './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : `./src/components/${toKebabCase(expose.replace(/^\.\//u, ''))}.tsx`;
177
+ return [
173
178
  expose,
174
- './Route' === expose ? './src/federation-entry.tsx' : './Widget' === expose ? `./src/components/${domain}-widget.tsx` : ''
175
- ]));
179
+ configuredPath ?? inferredPath
180
+ ];
181
+ }));
176
182
  return {
177
183
  id: app.id,
178
184
  directory: app.path,
@@ -15,6 +15,7 @@ export type UltramodernToolingConfigApp = {
15
15
  role?: 'host' | 'remote';
16
16
  name?: string;
17
17
  exposes?: string[];
18
+ exposePaths?: Record<string, string>;
18
19
  verticalRefs?: string[];
19
20
  hostOnly?: boolean;
20
21
  noExposes?: boolean;
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
24
- "version": "3.4.0-ultramodern.15",
24
+ "version": "3.4.0-ultramodern.17",
25
25
  "types": "./dist/types/index.d.ts",
26
26
  "main": "./dist/esm-node/index.js",
27
27
  "bin": {
@@ -77,7 +77,7 @@
77
77
  "@modern-js/codesmith": "2.6.9",
78
78
  "oxfmt": "0.55.0",
79
79
  "ultracite": "7.8.3",
80
- "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.4.0-ultramodern.15"
80
+ "@modern-js/i18n-utils": "npm:@bleedingdev/modern-js-i18n-utils@3.4.0-ultramodern.17"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@rslib/core": "0.23.0",
@@ -99,6 +99,6 @@
99
99
  "test": "rm -rf dist && rslib build -c rslibconfig.mts && rstest --passWithNoTests"
100
100
  },
101
101
  "ultramodern": {
102
- "frameworkVersion": "3.4.0-ultramodern.15"
102
+ "frameworkVersion": "3.4.0-ultramodern.17"
103
103
  }
104
104
  }
@@ -6,6 +6,20 @@ function normalizeUrlWithTrailingSlash(url) {
6
6
  return url.endsWith('/') ? url : `${url}/`;
7
7
  }
8
8
 
9
+ function resolveModuleFederationPublicPath(publicPath, manifestUrl) {
10
+ if (typeof publicPath !== 'string' || publicPath.trim().length === 0) {
11
+ return undefined;
12
+ }
13
+
14
+ try {
15
+ return normalizeUrlWithTrailingSlash(
16
+ new URL(publicPath.trim(), manifestUrl).toString(),
17
+ );
18
+ } catch {
19
+ return undefined;
20
+ }
21
+ }
22
+
9
23
  async function fetchText(url) {
10
24
  const response = await fetch(url);
11
25
  return {
@@ -721,7 +735,8 @@ async function validateModuleFederationManifestEvidence(evidence, app, publicUrl
721
735
  const budgets = qualityGates.budgets ?? {};
722
736
 
723
737
  const manifestRoute = routes.mfManifest ?? '/mf-manifest.json';
724
- const manifest = await fetchText(joinUrl(publicUrl, manifestRoute));
738
+ const manifestUrl = joinUrl(publicUrl, manifestRoute);
739
+ const manifest = await fetchText(manifestUrl);
725
740
  const manifestJson = parseMaybeJson(manifest.body);
726
741
  evidence.assertions.push({
727
742
  type: 'mf-manifest',
@@ -754,17 +769,26 @@ async function validateModuleFederationManifestEvidence(evidence, app, publicUrl
754
769
  manifest.accessControlAllowOrigin === '*',
755
770
  `${app.id} MF manifest is missing Cloudflare CORS headers`,
756
771
  );
757
- const expectedPublicPath = normalizeUrlWithTrailingSlash(publicUrl);
772
+ const expectedPublicPath = normalizeUrlWithTrailingSlash(
773
+ new URL('.', manifestUrl).toString(),
774
+ );
758
775
  const manifestPublicPath = manifestJson?.metaData?.publicPath;
776
+ const resolvedPublicPath = resolveModuleFederationPublicPath(
777
+ manifestPublicPath,
778
+ manifestUrl,
779
+ );
759
780
  evidence.assertions.push({
760
781
  type: 'mf-manifest-public-path',
761
782
  expected: expectedPublicPath,
762
783
  actual: manifestPublicPath,
763
- status: manifestPublicPath === expectedPublicPath ? 'pass' : 'fail',
784
+ resolved: resolvedPublicPath,
785
+ status: resolvedPublicPath === expectedPublicPath ? 'pass' : 'fail',
764
786
  });
765
787
  assert(
766
- manifestPublicPath === expectedPublicPath,
767
- `${app.id} MF manifest publicPath must resolve remote assets from ${expectedPublicPath}`,
788
+ resolvedPublicPath === expectedPublicPath,
789
+ `${app.id} MF manifest publicPath must resolve remote assets from ${expectedPublicPath}; got ${String(
790
+ manifestPublicPath,
791
+ )}`,
768
792
  );
769
793
  }
770
794
 
@@ -848,4 +872,4 @@ async function validateApp(app, publicUrl) {
848
872
  return evidence;
849
873
  }
850
874
 
851
- export { validateApp };
875
+ export { resolveModuleFederationPublicPath, validateApp };