@@ -2,6 +2,7 @@ import { stripIndents } from '@nx/devkit';
2
2
import {
3
3
checkFilesExist ,
4
4
cleanupProject ,
5
+ killPorts ,
5
6
killProcessAndPorts ,
6
7
newProject ,
7
8
readJson ,
@@ -39,10 +40,10 @@ describe('React Module Federation', () => {
39
40
`generate @nx/react:remote ${ remote3 } --style=css --host=${ shell } --no-interactive`
40
41
) ;
41
42
42
- checkFilesExist ( `apps/${ shell } /module-federation.config.ts ` ) ;
43
- checkFilesExist ( `apps/${ remote1 } /module-federation.config.ts ` ) ;
44
- checkFilesExist ( `apps/${ remote2 } /module-federation.config.ts ` ) ;
45
- checkFilesExist ( `apps/${ remote3 } /module-federation.config.ts ` ) ;
43
+ checkFilesExist ( `apps/${ shell } /module-federation.config.js ` ) ;
44
+ checkFilesExist ( `apps/${ remote1 } /module-federation.config.js ` ) ;
45
+ checkFilesExist ( `apps/${ remote2 } /module-federation.config.js ` ) ;
46
+ checkFilesExist ( `apps/${ remote3 } /module-federation.config.js ` ) ;
46
47
47
48
await expect ( runCLIAsync ( `test ${ shell } ` ) ) . resolves . toMatchObject ( {
48
49
combinedOutput : expect . stringContaining ( 'Test Suites: 1 passed, 1 total' ) ,
@@ -54,15 +55,15 @@ describe('React Module Federation', () => {
54
55
expect ( readPort ( remote3 ) ) . toEqual ( 4203 ) ;
55
56
56
57
updateFile (
57
- `apps/${ shell } /webpack.config.ts ` ,
58
+ `apps/${ shell } /webpack.config.js ` ,
58
59
stripIndents `
59
- import { composePlugins, withNx, ModuleFederationConfig } from '@nx/webpack';
60
- import { withReact } from '@nx/react';
61
- import { withModuleFederation } from '@nx/react/module-federation');
60
+ const { composePlugins, withNx, ModuleFederationConfig } = require( '@nx/webpack') ;
61
+ const { withReact } = require( '@nx/react') ;
62
+ const { withModuleFederation } = require( '@nx/react/module-federation');
62
63
63
64
const baseConfig = require('./module-federation.config');
64
65
65
- const config: ModuleFederationConfig = {
66
+ const config = {
66
67
...baseConfig,
67
68
remotes: [
68
69
'${ remote1 } ',
@@ -106,20 +107,15 @@ describe('React Module Federation', () => {
106
107
});
107
108
`
108
109
) ;
109
- // TODO(caleb): cypress isn't able to find the element and then throws error with an address already in use error.
110
- // https://staging.nx.app/runs/ASAokpXhnE/task/e2e-react:e2e
111
- // if (runCypressTests()) {
112
- // const e2eResults = runCLI(`e2e ${shell}-e2e --no-watch --verbose`);
113
- // expect(e2eResults).toContain('All specs passed!');
114
- // expect(
115
- // await killPorts([
116
- // readPort(shell),
117
- // readPort(remote1),
118
- // readPort(remote2),
119
- // readPort(remote3),
120
- // ])
121
- // ).toBeTruthy();
122
- // }
110
+
111
+ if ( runE2ETests ( ) ) {
112
+ const e2eResults = runCLI ( `e2e ${ shell } -e2e --no-watch --verbose` ) ;
113
+ expect ( e2eResults ) . toContain ( 'All specs passed!' ) ;
114
+ await killPorts ( readPort ( shell ) ) ;
115
+ await killPorts ( readPort ( remote1 ) ) ;
116
+ await killPorts ( readPort ( remote2 ) ) ;
117
+ await killPorts ( readPort ( remote3 ) ) ;
118
+ }
123
119
} , 500_000 ) ;
124
120
125
121
it ( 'should should support generating host and remote apps with the new name and root format' , async ( ) => {
@@ -136,8 +132,8 @@ describe('React Module Federation', () => {
136
132
137
133
// check files are generated without the layout directory ("apps/") and
138
134
// using the project name as the directory when no directory is provided
139
- checkFilesExist ( `${ shell } /module-federation.config.ts ` ) ;
140
- checkFilesExist ( `${ remote } /module-federation.config.ts ` ) ;
135
+ checkFilesExist ( `${ shell } /module-federation.config.js ` ) ;
136
+ checkFilesExist ( `${ remote } /module-federation.config.js ` ) ;
141
137
142
138
// check default generated host is built successfully
143
139
const buildOutput = runCLI ( `run ${ shell } :build:development` ) ;
@@ -304,45 +300,45 @@ describe('React Module Federation', () => {
304
300
305
301
// update host and remote to use library type var
306
302
updateFile (
307
- `${ shell } /module-federation.config.ts ` ,
303
+ `${ shell } /module-federation.config.js ` ,
308
304
stripIndents `
309
- import { ModuleFederationConfig } from '@nx/webpack';
305
+ const { ModuleFederationConfig } = require( '@nx/webpack') ;
310
306
311
- const config: ModuleFederationConfig = {
307
+ const config = {
312
308
name: '${ shell } ',
313
309
library: { type: 'var', name: '${ shell } ' },
314
310
remotes: ['${ remote } '],
315
311
};
316
312
317
- export default config;
313
+ module.exports = config;
318
314
`
319
315
) ;
320
316
321
317
updateFile (
322
- `${ shell } /webpack.config.prod.ts ` ,
323
- `export { default } from './webpack.config';`
318
+ `${ shell } /webpack.config.prod.js ` ,
319
+ `module.exports = require( './webpack.config') ;`
324
320
) ;
325
321
326
322
updateFile (
327
- `${ remote } /module-federation.config.ts ` ,
323
+ `${ remote } /module-federation.config.js ` ,
328
324
stripIndents `
329
- import { ModuleFederationConfig } from '@nx/webpack';
325
+ const { ModuleFederationConfig } = require( '@nx/webpack') ;
330
326
331
- const config: ModuleFederationConfig = {
327
+ const config = {
332
328
name: '${ remote } ',
333
329
library: { type: 'var', name: '${ remote } ' },
334
330
exposes: {
335
331
'./Module': './src/remote-entry.ts',
336
332
},
337
333
};
338
334
339
- export default config;
335
+ module.exports = config;
340
336
`
341
337
) ;
342
338
343
339
updateFile (
344
- `${ remote } /webpack.config.prod.ts ` ,
345
- `export { default } from './webpack.config';`
340
+ `${ remote } /webpack.config.prod.js ` ,
341
+ `module.exports = require( './webpack.config') ;`
346
342
) ;
347
343
348
344
// Update host e2e test to check that the remote works with library type var via navigation
1 commit comments
vercel[bot] commentedon Oct 4, 2023
Successfully deployed to the following URLs:
nx-dev – ./
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app