-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(module-federation): remote names should follow JS variable naming…
… schema (#28401) <!-- 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 --> We previously had a schema restriction on the characters allowed for remote names. It was to prevent names that violated the JS spec for a variable declaration. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Ensure invalid project names fail error allowing the user to fix it at generation ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28354, #28408 --------- Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
- Loading branch information
Showing
9 changed files
with
331 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
packages/react/src/generators/remote/__snapshots__/remote.rspack.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files 1`] = ` | ||
"const { composePlugins, withNx, withReact } = require('@nx/rspack'); | ||
const { withModuleFederation } = require('@nx/rspack/module-federation'); | ||
const baseConfig = require('./module-federation.config'); | ||
const config = { | ||
...baseConfig, | ||
}; | ||
// Nx plugins for rspack to build config object from Nx options and context. | ||
/** | ||
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support 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 = composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false })); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files 2`] = `"module.exports = require('./rspack.config');"`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files 3`] = ` | ||
"module.exports = { | ||
name: 'test', | ||
exposes: { | ||
'./Module': './src/remote-entry.ts', | ||
}, | ||
}; | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --js=true 1`] = ` | ||
"const { composePlugins, withNx, withReact } = require('@nx/rspack'); | ||
const { withModuleFederation } = require('@nx/rspack/module-federation'); | ||
const baseConfig = require('./module-federation.config'); | ||
const config = { | ||
...baseConfig, | ||
}; | ||
// Nx plugins for rspack to build config object from Nx options and context. | ||
/** | ||
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support 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 = composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false })); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --js=true 2`] = `"module.exports = require('./rspack.config');"`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --js=true 3`] = ` | ||
"module.exports = { | ||
name: 'test', | ||
exposes: { | ||
'./Module': './src/remote-entry.js', | ||
}, | ||
}; | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --typescriptConfiguration=true 1`] = ` | ||
"import { composePlugins, withNx, withReact } from '@nx/rspack'; | ||
import { withModuleFederation } from '@nx/rspack/module-federation'; | ||
import baseConfig from './module-federation.config'; | ||
const config = { | ||
...baseConfig, | ||
}; | ||
// Nx plugins for rspack to build config object from Nx options and context. | ||
/** | ||
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support 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 composePlugins( | ||
withNx(), | ||
withReact(), | ||
withModuleFederation(config, { dts: false }) | ||
); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --typescriptConfiguration=true 2`] = ` | ||
"export default require('./rspack.config'); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should create the remote with the correct config files when --typescriptConfiguration=true 3`] = ` | ||
"import { ModuleFederationConfig } from '@nx/rspack/module-federation'; | ||
const config: ModuleFederationConfig = { | ||
name: 'test', | ||
exposes: { | ||
'./Module': './src/remote-entry.ts', | ||
}, | ||
}; | ||
export default config; | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should generate correct remote with config files when using --ssr 1`] = ` | ||
"const {composePlugins, withNx, withReact} = require('@nx/rspack'); | ||
const {withModuleFederationForSSR} = require('@nx/rspack/module-federation'); | ||
const baseConfig = require("./module-federation.server.config"); | ||
const defaultConfig = { | ||
...baseConfig, | ||
}; | ||
// Nx plugins for rspack to build config object from Nx options and context. | ||
/** | ||
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support 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 = composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false })); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should generate correct remote with config files when using --ssr 2`] = ` | ||
"module.exports = { | ||
name: 'test', | ||
exposes: { | ||
'./Module': './src/remote-entry.ts', | ||
}, | ||
}; | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should generate correct remote with config files when using --ssr and --typescriptConfiguration=true 1`] = ` | ||
"import { composePlugins, withNx, withReact } from '@nx/rspack'; | ||
import { withModuleFederationForSSR } from '@nx/rspack/module-federation'; | ||
import baseConfig from './module-federation.server.config'; | ||
const defaultConfig = { | ||
...baseConfig, | ||
}; | ||
// Nx plugins for rspack to build config object from Nx options and context. | ||
/** | ||
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support 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 composePlugins( | ||
withNx(), | ||
withReact({ ssr: true }), | ||
withModuleFederationForSSR(defaultConfig, { dts: false }) | ||
); | ||
" | ||
`; | ||
|
||
exports[`remote generator bundler=rspack should generate correct remote with config files when using --ssr and --typescriptConfiguration=true 2`] = ` | ||
"import { ModuleFederationConfig } from '@nx/rspack/module-federation'; | ||
const config: ModuleFederationConfig = { | ||
name: 'test', | ||
exposes: { | ||
'./Module': './src/remote-entry.ts', | ||
}, | ||
}; | ||
export default config; | ||
" | ||
`; |
Oops, something went wrong.