Skip to content

Commit

Permalink
feat: use Cloudbeds remote manifests by default, making it a drop-in …
Browse files Browse the repository at this point in the history
…configuration-less plugin
  • Loading branch information
steven-pribilinskiy committed Jul 21, 2022
1 parent 1538466 commit d154b38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export const DIR_DIST = 'dist';
export const FEDERATION_CONFIG_FILE = 'federation.config.json';

export const DIR_EMITTED = '@types';

export const DIR_DIST = 'dist';
export const DIR_DOWNLOADED = '@remote-types';
export const FEDERATION_CONFIG_FILE = 'federation.config.json';

export const DEFAULT_SYNC_TYPES_INTERVAL_IN_SECONDS = 60;

export const CLOUDBEDS_DEV_FRONTEND_ASSETS_DOMAIN = 'https://cb-front.cloudbeds-dev.com';
export const CLOUDBEDS_DEV_REMOTES_MANIFEST = 'use-devbox-name';
export const CLOUDBEDS_MFD_COMMON_MANIFEST_FILE_NAME = 'mfd-common-remote-entry.json';
export const CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME = 'remote-entries.json';
7 changes: 3 additions & 4 deletions src/helpers/cloudbedsRemoteManifests.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {
CLOUDBEDS_DEV_FRONTEND_ASSETS_DOMAIN,
CLOUDBEDS_DEV_REMOTES_MANIFEST,
CLOUDBEDS_MFD_COMMON_MANIFEST_FILE_NAME,
CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME,
} from '../constants';
import { ModuleFederationTypesPluginOptions, RemoteManifestUrls } from '../types';

export function getRemoteManifestUrls(options?: ModuleFederationTypesPluginOptions): RemoteManifestUrls | undefined {
let baseUrl = options?.cloudbedsRemoteManifestsBaseUrl;
if (baseUrl) {
if (baseUrl === CLOUDBEDS_DEV_REMOTES_MANIFEST) {
if (!options?.doNotUseCloudbedsRemoteManifests) {
let baseUrl = options?.cloudbedsRemoteManifestsBaseUrl;
if (!baseUrl || baseUrl === 'use-devbox-name') {
baseUrl = `${CLOUDBEDS_DEV_FRONTEND_ASSETS_DOMAIN}/remotes/dev-ga`;
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/compileTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function rewritePathsWithExposedFederatedModules(

let federatedModulePath = exposePath
? `${federationConfig.name}/${exposePath}`
: `${federationConfig.name}/@types/${importPath}`;
: `${federationConfig.name}@remote-types/${importPath}`;

federatedModulePath = federatedModulePath.replace(/\/index$/, '')

Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export type RemoteManifestUrls = Record<'registry' | string, string>;
export type ModuleFederationPluginOptions = ConstructorParameters<typeof container.ModuleFederationPlugin>[0];

export type ModuleFederationTypesPluginOptions = {
cloudbedsRemoteManifestsBaseUrl?: string;
cloudbedsRemoteManifestsBaseUrl?: string | 'use-devbox-name';
doNotUseCloudbedsRemoteManifests?: boolean,
remoteManifestUrls?: RemoteManifestUrls,
syncTypesIntervalInSeconds?: number;
}
Expand Down

0 comments on commit d154b38

Please sign in to comment.