Skip to content

Commit

Permalink
fix(module-federation): turn dts off by default #27198 (#27403)
Browse files Browse the repository at this point in the history
- fix(angular): turn mf dts off by default #27198
- fix(react): turn mf dts off by default
- fix(react): add migration to turn module federation dts off by default
- fix(angular): add migration to turn module federation dts off by
default

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
Nx already provides Typing support for Module Federation projects. The
`@module-federation/enhanced` package has typing support turned on by
default but it can be problematic.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Turn off `@module-federation/enhanced` own dts plugin providing typing
support in favour of Nx's own typing support

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27198
  • Loading branch information
Coly010 authored Aug 14, 2024
1 parent d39624c commit 225a8e0
Show file tree
Hide file tree
Showing 29 changed files with 1,125 additions and 49 deletions.
6 changes: 6 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@
},
"description": "Update the @angular/cli package version to ~18.1.0.",
"factory": "./src/migrations/update-19-5-0/update-angular-cli"
},
"update-19-6-0": {
"cli": "nx",
"version": "19.6.0-beta.4",
"description": "Ensure Module Federation DTS is turned off by default.",
"factory": "./src/migrations/update-19-6-0/turn-off-dts-by-default"
}
},
"packageJsonUpdates": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,12 @@ exports[`Host App Generator --ssr should generate the correct files 6`] = `
exports[`Host App Generator --ssr should generate the correct files 7`] = `
"const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -438,7 +443,12 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
exports[`Host App Generator --ssr should generate the correct files for standalone 6`] = `
"const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -653,7 +663,12 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
"import { withModuleFederationForSSR } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -883,7 +898,12 @@ exports[`Host App Generator --ssr should generate the correct files when --types
"import { withModuleFederationForSSR } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -948,45 +968,78 @@ exports[`Host App Generator --ssr should generate the correct files when --types
exports[`Host App Generator should generate a host app with a remote 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`Host App Generator should generate a host app with a remote 2`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`Host App Generator should generate a host app with a remote when --typesscript=true 1`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
exports[`Host App Generator should generate a host app with a remote when --typesscript=true 2`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
exports[`Host App Generator should generate a host app with no remotes 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`Host App Generator should generate a host app with no remotes when --typescript=true 1`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config)
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederationForSSR(config, { dts: false });
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { withModuleFederationForSSR } from '@nx/angular/module-federation';
import config from './module-federation.config';

export default withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederationForSSR(config, { dts: false });
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ exports[`MF Remote App Generator --ssr should generate the correct files 6`] = `
exports[`MF Remote App Generator --ssr should generate the correct files 7`] = `
"const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -443,7 +449,12 @@ exports[`MF Remote App Generator --ssr should generate the correct files when --
"import { withModuleFederationForSSR } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederationForSSR(config, { dts: false });
"
`;
Expand Down Expand Up @@ -525,45 +536,78 @@ exports[`MF Remote App Generator --ssr should generate the correct files when --
exports[`MF Remote App Generator should generate a remote mf app with a host 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`MF Remote App Generator should generate a remote mf app with a host 2`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`MF Remote App Generator should generate a remote mf app with a host when --typescriptConfiguration=true 1`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
exports[`MF Remote App Generator should generate a remote mf app with a host when --typescriptConfiguration=true 2`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
exports[`MF Remote App Generator should generate a remote mf app with no host 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;
exports[`MF Remote App Generator should generate a remote mf app with no host when --typescriptConfiguration=true 1`] = `
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { withModuleFederationForSSR } from '@nx/angular/module-federation';
import config from './module-federation.config';

export default withModuleFederationForSSR(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederationForSSR(config, { dts: false });
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const { withModuleFederationForSSR } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederationForSSR(config)

/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederationForSSR(config, { dts: false })
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ export const appRoutes: Route[] = [
exports[`Init MF should create webpack and mf configs correctly 1`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;

Expand All @@ -224,7 +230,13 @@ exports[`Init MF should create webpack and mf configs correctly 2`] = `
exports[`Init MF should create webpack and mf configs correctly 3`] = `
"const { withModuleFederation } = require('@nx/angular/module-federation');
const config = require('./module-federation.config');
module.exports = withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
module.exports = withModuleFederation(config, { dts: false });
"
`;

Expand All @@ -242,7 +254,12 @@ exports[`Init MF should create webpack and mf configs correctly when --typescrip
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;

Expand Down Expand Up @@ -274,7 +291,12 @@ exports[`Init MF should create webpack and mf configs correctly when --typescrip
"import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';
export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
"
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';

export default withModuleFederation(config);
/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation(config, { dts: false });
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { withModuleFederation } from '@nx/angular/module-federation';
import config from './module-federation.config';

/**
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
* The DTS Plugin can be enabled by setting dts: true
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
*/
export default withModuleFederation({
...config,
/*
Expand All @@ -13,4 +18,4 @@ export default withModuleFederation({
* ['app2', 'https://app2.example.com'],
* ]
*/
});
}, { dts: false });
Loading

0 comments on commit 225a8e0

Please sign in to comment.