File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed
examples/vite-vite/vite-remote Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change
1
+ export default function ( ) {
2
+ console . log ( 12313123 ) ;
3
+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { App2 } from './App2';
7
7
import { EmotionDemo } from './EmotionDemo' ;
8
8
import { MuiDemo } from './MuiDemo' ;
9
9
import StyledDemo from './StyledDemo' ;
10
+ import "./customShare" ;
10
11
11
12
const root = ReactDOM . createRoot ( document . getElementById ( 'app' ) ) ;
12
13
root . render (
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export default defineConfig({
30
30
filename : 'remoteEntry-[hash].js' ,
31
31
manifest : true ,
32
32
shared : {
33
+ './src/customShare' : { } ,
33
34
vue : { } ,
34
35
'react/' : { } ,
35
36
react : {
Original file line number Diff line number Diff line change 1
1
import { SharedConfig , ShareStrategy } from '@module-federation/runtime/types' ;
2
+ import { isAbsolute } from "pathe" ;
2
3
3
4
export type RemoteEntryType =
4
5
| 'var'
@@ -132,9 +133,13 @@ function normalizeShareItem(
132
133
) : ShareItem {
133
134
let version : string | undefined ;
134
135
try {
135
- version = require ( path . join ( removePathFromNpmPackage ( key ) , 'package.json' ) ) . version ;
136
+ if ( isAbsolute ( key ) || key . startsWith ( "./" ) ) {
137
+ version = "1.0.0"
138
+ } else {
139
+ version = require ( path . join ( removePathFromNpmPackage ( key ) , 'package.json' ) ) . version ;
140
+ }
136
141
} catch ( e ) {
137
- console . log ( e ) ;
142
+ console . log ( e )
138
143
}
139
144
if ( typeof shareItem === 'string' ) {
140
145
return {
@@ -313,6 +318,14 @@ export function getNormalizeModuleFederationOptions() {
313
318
314
319
export function getNormalizeShareItem ( key : string ) {
315
320
const options = getNormalizeModuleFederationOptions ( ) ;
321
+ if ( isAbsolute ( key ) || key . startsWith ( "./" ) ) {
322
+ const shareItem = Object . keys ( options . shared ) . filter ( shareKey => {
323
+ if ( shareKey . startsWith ( key ) ) {
324
+ return
325
+ }
326
+ } ) ?. [ 0 ]
327
+ if ( shareItem ) return shareItem
328
+ }
316
329
const shareItem =
317
330
options . shared [ removePathFromNpmPackage ( key ) ] ||
318
331
options . shared [ removePathFromNpmPackage ( key ) + '/' ] ;
You can’t perform that action at this time.
0 commit comments