Skip to content

Commit 84aa2c6

Browse files
authored
chore: add warn message for publicPath and getPublicPath (#108)
1 parent 19bb05d commit 84aa2c6

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/plugins/pluginMFManifest.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const Manifest = (): Plugin[] => {
6363
types: { path: '', name: '' },
6464
globalName: name,
6565
pluginVersion: '0.2.5',
66-
publicPath,
6766
},
6867
})
6968
);
@@ -322,7 +321,6 @@ const Manifest = (): Plugin[] => {
322321
},
323322
globalName: name,
324323
pluginVersion: '0.2.5',
325-
publicPath,
326324
},
327325
shared,
328326
remotes,

src/utils/logUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const warn = (message: string) =>
2+
message.split('\n').forEach((msg) => console.warn('\x1b[33m%s\x1b[0m', msg));

src/utils/normalizeModuleFederationOptions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export type RemoteEntryType =
2222
| string;
2323

2424
import * as path from 'pathe';
25+
import { warn } from './logUtils';
2526

2627
interface ExposesItem {
2728
import: string;
@@ -243,7 +244,8 @@ export type ModuleFederationOptions = {
243244
>
244245
| undefined;
245246
runtimePlugins?: string[];
246-
getPublicPath?: any;
247+
publicPath?: string;
248+
getPublicPath?: string;
247249
implementation?: any;
248250
manifest?: ManifestOptions | boolean;
249251
dev?: boolean | PluginDevOptions;
@@ -262,7 +264,6 @@ export interface NormalizedModuleFederationOptions {
262264
shareScope: string;
263265
shared: NormalizedShared;
264266
runtimePlugins: string[];
265-
getPublicPath: any;
266267
implementation: any;
267268
manifest: ManifestOptions | boolean;
268269
dev?: boolean | PluginDevOptions;
@@ -321,6 +322,11 @@ export function getNormalizeShareItem(key: string) {
321322
export function normalizeModuleFederationOptions(
322323
options: ModuleFederationOptions
323324
): NormalizedModuleFederationOptions {
325+
if (options.getPublicPath || options.publicPath) {
326+
warn(
327+
`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`
328+
);
329+
}
324330
return (config = {
325331
exposes: normalizeExposes(options.exposes),
326332
filename: options.filename || 'remoteEntry-[hash]',
@@ -332,7 +338,6 @@ export function normalizeModuleFederationOptions(
332338
shareScope: options.shareScope || 'default',
333339
shared: normalizeShared(options.shared),
334340
runtimePlugins: options.runtimePlugins || [],
335-
getPublicPath: options.getPublicPath,
336341
implementation: options.implementation,
337342
manifest: normalizeManifest(options.manifest),
338343
dev: options.dev,

0 commit comments

Comments
 (0)