3
3
import { withNx , NxWebpackExecutionContext , composePluginsSync } from '@nx/webpack' ;
4
4
import { withReact } from '@nx/react' ;
5
5
import { merge } from 'webpack-merge' ;
6
- import { Configuration , container , ProgressPlugin } from 'webpack' ;
6
+ import { Configuration , ProgressPlugin } from 'webpack' ;
7
7
import { join , resolve } from 'path' ;
8
- import { DynamicRemotePlugin } from '@openshift/dynamic-plugin-sdk-webpack' ;
9
-
10
- const { ModuleFederationPlugin } = container ;
8
+ import { ModuleFederationPlugin } from '@module-federation/enhanced' ;
9
+ import { DynamicRemotePluginEnhanced } from '@scalprum/build-tools/src/index' ;
11
10
12
11
const sharedModules = {
13
12
react : {
@@ -28,18 +27,12 @@ const sharedModules = {
28
27
} ,
29
28
} ;
30
29
31
- const TestAppFederation = new ModuleFederationPlugin ( {
32
- name : 'testApp ' ,
33
- filename : 'testApp .js' ,
30
+ const ShellConfig = new ModuleFederationPlugin ( {
31
+ name : 'shell ' ,
32
+ filename : 'shell.[contenthash] .js' ,
34
33
library : {
35
- type : 'var' ,
36
- name : 'testApp' ,
37
- } ,
38
- exposes : {
39
- './ModuleOne' : resolve ( __dirname , './src/modules/moduleOne.tsx' ) ,
40
- './ModuleTwo' : resolve ( __dirname , './src/modules/moduleTwo.tsx' ) ,
41
- './ModuleThree' : resolve ( __dirname , './src/modules/moduleThree.tsx' ) ,
42
- './ErrorModule' : resolve ( __dirname , './src/modules/errorModule.tsx' ) ,
34
+ type : 'global' ,
35
+ name : 'shell' ,
43
36
} ,
44
37
shared : [
45
38
{
@@ -63,7 +56,7 @@ const TestPreLoadFederation = new ModuleFederationPlugin({
63
56
name : 'preLoad' ,
64
57
filename : 'preLoad.js' ,
65
58
library : {
66
- type : 'var ' ,
59
+ type : 'global ' ,
67
60
name : 'preLoad' ,
68
61
} ,
69
62
exposes : {
@@ -77,7 +70,7 @@ const TestModuleFederation = new ModuleFederationPlugin({
77
70
name : 'testModule' ,
78
71
filename : 'testModule.js' ,
79
72
library : {
80
- type : 'var ' ,
73
+ type : 'global ' ,
81
74
name : 'testModule' ,
82
75
} ,
83
76
exposes : {
@@ -87,13 +80,10 @@ const TestModuleFederation = new ModuleFederationPlugin({
87
80
shared : [ sharedModules ] ,
88
81
} ) ;
89
82
90
- const TestSDKPLugin = new DynamicRemotePlugin ( {
83
+ const TestSDKPLugin = new DynamicRemotePluginEnhanced ( {
91
84
extensions : [ ] ,
92
85
sharedModules,
93
86
entryScriptFilename : 'sdk-plugin.[contenthash].js' ,
94
- moduleFederationSettings : {
95
- libraryType : 'global' ,
96
- } ,
97
87
pluginMetadata : {
98
88
name : 'sdk-plugin' ,
99
89
version : '1.0.0' ,
@@ -104,7 +94,7 @@ const TestSDKPLugin = new DynamicRemotePlugin({
104
94
} ) ;
105
95
106
96
const withModuleFederation = ( config : Configuration , { context } : NxWebpackExecutionContext ) : Configuration => {
107
- const plugins : Configuration [ 'plugins' ] = [ new ProgressPlugin ( ) , TestSDKPLugin , TestAppFederation , TestModuleFederation , TestPreLoadFederation ] ;
97
+ const plugins : Configuration [ 'plugins' ] = [ new ProgressPlugin ( ) , ShellConfig ] ;
108
98
const newConfig = merge ( config , {
109
99
experiments : {
110
100
outputModule : true ,
0 commit comments