Skip to content

Commit

Permalink
feat: removed cloudbeds-specific config
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-pribilinskiy committed Feb 19, 2024
1 parent 8fc2ef3 commit 0ccc0cd
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @cloudbeds/mfd-fe-global-owners
* @cloudbeds/mfd-fe-global-owners
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ To enable verbose logging add folowing in webpack config:
| `downloadTypesWhenIdleIntervalInSeconds` | `number`, `-1` | `60` | Synchronize types continusouly - compile types after every compilation, download when idle with a specified delay value in seconds. <br><br> `-1` - disables continuous synchronization (compile and download will happen only on startup). |
| `remoteEntryUrls` | `RemoteEntryUrls` | `{}` | Base URLs for types. These should target compiled bundles that also contain the types. E.g. with `{ mfeApp: 'https://assets.mydomain.com/mfe-app' }` the types will be downloaded from `'https://assets.mydomain.com/mfe-app/@types/index.d.ts'`. More details available in [this section](#templated-remote-urls) |
| `remoteManifestUrls` | `RemoteManifestUrls` | `{}` | URLs to remote manifest files. A manifest contains a URL to a remote entry that is substituted in runtime. <br><br> More details available in [this section](#templated-remote-urls) |
| `cloudbedsRemoteManifestsBaseUrl` | `string` | `'/remotes/dev-ga'` | Base URL for remote `remote-entries.json` manifest file that is specific to Cloudbeds microapps <br><br> _Examples:_ <br> `http://localhost:4480/remotes/dev` (or `/dev-docker`) <br> `https://cb-front.cloudbeds-dev.com/remotes/[env]`. <br><br> `remoteManifestUrls` is ignored when this setting has a value other than `undefined`. |
| `moduleFederationPluginName` | `string` | `ModuleFederationPlugin` | The name of the Module Federation plugin. Change this to `NextFederationPlugin` if you are using this plugin with [@module-federation/nextjs-mf](https://www.npmjs.com/package/@module-federation/nextjs-mf) |


Expand Down Expand Up @@ -187,7 +186,6 @@ There are several ways one can resolve this placeholder:

* `remoteEntryUrls` option
* `remoteManifestUrls` or `remoteManifestUrl` option
* `cloudbedsRemoteManifestsBaseUrl` option (Cloudbeds specific)

The `remoteEntryUrls` option is a simple key-value map of remote names and their bundle's base URL.

Expand Down
9 changes: 0 additions & 9 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,3 @@ export const DEFAULT_DIR_GLOBAL_TYPES = 'src/@types';
export const DEFAULT_DIR_DOWNLOADED_TYPES = 'src/@types/remotes';

export const DEFAULT_DOWNLOAD_TYPES_INTERVAL_IN_SECONDS = 60;

export enum CloudbedsCloudfrontDomain {
Dev = 'https://cb-front.cloudbeds-dev.com',
Stage = 'https://cb-front.cloudbeds-stage.com',
Prod = 'https://front.cloudbeds.com',
}

export const CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME = 'remote-entries.json';
export const CLOUDBEDS_DEPLOYMENT_ENV_WITH_DISABLED_REMOTE_TYPES_DOWNLOAD = 'devbox';
29 changes: 0 additions & 29 deletions src/downloadTypes/getRemoteManifestUrls.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
import {
CloudbedsCloudfrontDomain,
CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME,
} from '../constants';
import { isValidUrl } from '../helpers';
import {
ModuleFederationTypesPluginOptions, RemoteManifestUrls,
} from '../models';

export function getRemoteManifestUrls(options?: ModuleFederationTypesPluginOptions): RemoteManifestUrls | undefined {
if (options?.cloudbedsRemoteManifestsBaseUrl !== undefined) {
let artifactsBaseUrl = '';
let manifestBaseUrl = options.cloudbedsRemoteManifestsBaseUrl;

if (!isValidUrl(manifestBaseUrl)) {
if (['stage', 'stage-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/remotes/stage-ga/{version}`;
} else if (['prod', 'prod-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/remotes/prod-ga/{version}`;
} else {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Dev}/branches`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Dev}/remotes/dev-ga`;
}
}

return {
...(artifactsBaseUrl ? { artifactsBaseUrl } : null),
registry: `${manifestBaseUrl}/${CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME}`,
...options?.remoteManifestUrls,
};
}

if (options?.remoteManifestUrl) {
return {
...options?.remoteManifestUrls,
Expand Down
5 changes: 0 additions & 5 deletions src/models/ModuleFederationTypesPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ export type ModuleFederationTypesPluginOptions = {
remoteEntryUrls?: RemoteEntryUrls,
remoteManifestUrls?: RemoteManifestUrls,
remoteManifestUrl?: string,

cloudbedsRemoteManifestsBaseUrl?: string | ''
| 'dev' | 'dev-ga'
| 'stage' | 'stage-ga'
| 'prod' | 'prod-ga',
}
3 changes: 1 addition & 2 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from 'webpack';

import {
CLOUDBEDS_DEPLOYMENT_ENV_WITH_DISABLED_REMOTE_TYPES_DOWNLOAD,
DEFAULT_DIR_DIST,
DEFAULT_DIR_DOWNLOADED_TYPES,
DEFAULT_DIR_EMITTED_TYPES,
Expand Down Expand Up @@ -42,7 +41,7 @@ export class ModuleFederationTypesPlugin implements WebpackPluginInstance {
const remoteManifestUrls = getRemoteManifestUrls(this.options);
const isCompilationDisabled = !!this.options?.disableTypeCompilation;
const isDownloadDisabled = this.options?.disableDownladingRemoteTypes
?? process.env.DEPLOYMENT_ENV === CLOUDBEDS_DEPLOYMENT_ENV_WITH_DISABLED_REMOTE_TYPES_DOWNLOAD;
?? process.env.DEPLOYMENT_ENV === 'devbox';

// Disable plugin when some URLs are not valid
if (!isEveryUrlValid(Object.values({ ...remoteEntryUrls }))) {
Expand Down

0 comments on commit 0ccc0cd

Please sign in to comment.