11import { describe , it , expect , vi } from 'vitest' ;
2- import { createSSRMFConfig , patchSSRRspackConfig , SSR_DIR } from './ssr' ; // Assuming SSR_DIR is exported or mockable
2+ import { resolve } from 'import-meta-resolve' ;
3+ import { createSSRMFConfig , patchSSRRspackConfig , SSR_DIR } from './ssr' ;
34import type { Rspack } from '@rsbuild/core' ;
45import type { moduleFederationPlugin } from '@module-federation/sdk' ;
56
@@ -15,7 +16,7 @@ describe('createSSRMFConfig', () => {
1516 expect ( ssrMFConfig . dts ) . toBe ( false ) ;
1617 expect ( ssrMFConfig . dev ) . toBe ( false ) ;
1718 expect ( ssrMFConfig . runtimePlugins ) . toEqual ( [
18- require . resolve ( '@module-federation/node/runtimePlugin' ) ,
19+ resolve ( '@module-federation/node/runtimePlugin' , import . meta . url ) ,
1920 ] ) ;
2021 } ) ;
2122
@@ -37,11 +38,12 @@ describe('createSSRMFConfig', () => {
3738 process . env . NODE_ENV = 'development' ;
3839 const ssrMFConfig = createSSRMFConfig ( baseMFConfig ) ;
3940 expect ( ssrMFConfig . runtimePlugins ) . toContain (
40- require . resolve ( '@module-federation/node/runtimePlugin' ) ,
41+ resolve ( '@module-federation/node/runtimePlugin' , import . meta . url ) ,
4142 ) ;
4243 expect ( ssrMFConfig . runtimePlugins ) . toContain (
43- require . resolve (
44+ resolve (
4445 '@module-federation/node/record-dynamic-remote-entry-hash-plugin' ,
46+ import . meta. url ,
4547 ) ,
4648 ) ;
4749 process . env . NODE_ENV = originalNodeEnv ; // Restore original NODE_ENV
@@ -52,7 +54,7 @@ describe('createSSRMFConfig', () => {
5254 process . env . NODE_ENV = 'production' ;
5355 const ssrMFConfig = createSSRMFConfig ( baseMFConfig ) ;
5456 expect ( ssrMFConfig . runtimePlugins ) . toEqual ( [
55- require . resolve ( '@module-federation/node/runtimePlugin' ) ,
57+ resolve ( '@module-federation/node/runtimePlugin' , import . meta . url ) ,
5658 ] ) ;
5759 process . env . NODE_ENV = originalNodeEnv ; // Restore original NODE_ENV
5860 } ) ;
@@ -65,7 +67,7 @@ describe('createSSRMFConfig', () => {
6567 } ;
6668 const ssrMFConfig = createSSRMFConfig ( mfConfigWithoutRuntimePlugins ) ;
6769 expect ( ssrMFConfig . runtimePlugins ) . toEqual ( [
68- require . resolve ( '@module-federation/node/runtimePlugin' ) ,
70+ resolve ( '@module-federation/node/runtimePlugin' , import . meta . url ) ,
6971 ] ) ;
7072 } ) ;
7173} ) ;
0 commit comments