Skip to content

Commit

Permalink
chore: add warn message for publicPath and getPublicPath (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa authored Oct 3, 2024
1 parent 19bb05d commit 84aa2c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/plugins/pluginMFManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const Manifest = (): Plugin[] => {
types: { path: '', name: '' },
globalName: name,
pluginVersion: '0.2.5',
publicPath,
},
})
);
Expand Down Expand Up @@ -322,7 +321,6 @@ const Manifest = (): Plugin[] => {
},
globalName: name,
pluginVersion: '0.2.5',
publicPath,
},
shared,
remotes,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/logUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const warn = (message: string) =>
message.split('\n').forEach((msg) => console.warn('\x1b[33m%s\x1b[0m', msg));
11 changes: 8 additions & 3 deletions src/utils/normalizeModuleFederationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type RemoteEntryType =
| string;

import * as path from 'pathe';
import { warn } from './logUtils';

interface ExposesItem {
import: string;
Expand Down Expand Up @@ -243,7 +244,8 @@ export type ModuleFederationOptions = {
>
| undefined;
runtimePlugins?: string[];
getPublicPath?: any;
publicPath?: string;
getPublicPath?: string;
implementation?: any;
manifest?: ManifestOptions | boolean;
dev?: boolean | PluginDevOptions;
Expand All @@ -262,7 +264,6 @@ export interface NormalizedModuleFederationOptions {
shareScope: string;
shared: NormalizedShared;
runtimePlugins: string[];
getPublicPath: any;
implementation: any;
manifest: ManifestOptions | boolean;
dev?: boolean | PluginDevOptions;
Expand Down Expand Up @@ -321,6 +322,11 @@ export function getNormalizeShareItem(key: string) {
export function normalizeModuleFederationOptions(
options: ModuleFederationOptions
): NormalizedModuleFederationOptions {
if (options.getPublicPath || options.publicPath) {
warn(
`We are ignoring the getPublicPath and publicPath options because they are natively supported by Vite\nwith the "experimental.renderBuiltUrl" configuration https://vitejs.dev/guide/build#advanced-base-options`
);
}
return (config = {
exposes: normalizeExposes(options.exposes),
filename: options.filename || 'remoteEntry-[hash]',
Expand All @@ -332,7 +338,6 @@ export function normalizeModuleFederationOptions(
shareScope: options.shareScope || 'default',
shared: normalizeShared(options.shared),
runtimePlugins: options.runtimePlugins || [],
getPublicPath: options.getPublicPath,
implementation: options.implementation,
manifest: normalizeManifest(options.manifest),
dev: options.dev,
Expand Down

0 comments on commit 84aa2c6

Please sign in to comment.