-
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.
feat(module-federation): move withModuleFederation for rspack to new …
…package
- Loading branch information
Showing
22 changed files
with
239 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './src/with-module-federation/rspack/with-module-federation'; | ||
export * from './src/with-module-federation/rspack/with-module-federation-ssr'; |
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
2 changes: 1 addition & 1 deletion
2
...src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...ct/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...react/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...ages/react/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__
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
2 changes: 1 addition & 1 deletion
2
packages/react/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...es/react/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...c/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__
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
2 changes: 1 addition & 1 deletion
2
.../src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__
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
2 changes: 1 addition & 1 deletion
2
...es/react/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__
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
2 changes: 1 addition & 1 deletion
2
packages/react/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
export * from './src/utils/module-federation/public-api'; | ||
/** | ||
* @deprecated Use `@nx/module-federation/rspack` instead. This will be removed in Nx v22. | ||
*/ | ||
export { | ||
withModuleFederation, | ||
withModuleFederationForSSR, | ||
} from '@nx/module-federation/rspack'; |
138 changes: 138 additions & 0 deletions
138
packages/rspack/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.spec.ts
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,138 @@ | ||
import { type Tree } from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
import migrateWithMfImport from './migrate-with-mf-import-to-new-package'; | ||
|
||
describe('migrate-with-mf-import-to-new-package', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
tree.write( | ||
'apps/shell/project.json', | ||
JSON.stringify({ | ||
name: 'shell', | ||
root: 'apps/shell', | ||
sourceRoot: 'apps/shell/src', | ||
projectType: 'application', | ||
targets: { | ||
serve: { | ||
executor: '@nx/rspack:module-federation-dev-server', | ||
options: {}, | ||
}, | ||
}, | ||
}) | ||
); | ||
}); | ||
|
||
it('should migrate the import correctly for withMf', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/rspack.config.ts', | ||
`import { withModuleFederation } from '@nx/rspack/module-federation';` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/rspack.config.ts', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"import { withModuleFederation } from '@nx/module-federation/rspack'; | ||
" | ||
`); | ||
}); | ||
|
||
it('should migrate the require correctly for withMf', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/rspack.config.js', | ||
`const { withModuleFederation } = require('@nx/rspack/module-federation');` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/rspack.config.js', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"const { withModuleFederation } = require('@nx/module-federation/rspack'); | ||
" | ||
`); | ||
}); | ||
|
||
it('should migrate the import correctly for withMfSSR', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/webpack.config.ts', | ||
`import { withModuleFederationForSSR } from '@nx/rspack/module-federation';` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/webpack.config.ts', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"import { withModuleFederationForSSR } from '@nx/module-federation/rspack'; | ||
" | ||
`); | ||
}); | ||
|
||
it('should migrate the require correctly for withMfSSR', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/rspack.config.js', | ||
`const { withModuleFederationForSSR } = require('@nx/rspack/module-federation');` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/rspack.config.js', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"const { withModuleFederationForSSR } = require('@nx/module-federation/rspack'); | ||
" | ||
`); | ||
}); | ||
|
||
describe('idempotent', () => { | ||
it('should migrate the import correctly for withMf even when run twice', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/webpack.config.ts', | ||
`import { withModuleFederation } from '@nx/rspack/module-federation';` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/webpack.config.ts', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"import { withModuleFederation } from '@nx/module-federation/rspack'; | ||
" | ||
`); | ||
}); | ||
|
||
it('should migrate the require correctly for withMfSSR even when run twice', async () => { | ||
// ARRANGE | ||
tree.write( | ||
'apps/shell/rspack.config.js', | ||
`const { withModuleFederationForSSR } = require('@nx/rspack/module-federation');` | ||
); | ||
|
||
// ACT | ||
await migrateWithMfImport(tree); | ||
await migrateWithMfImport(tree); | ||
|
||
// ASSERT | ||
expect(tree.read('apps/shell/rspack.config.js', 'utf-8')) | ||
.toMatchInlineSnapshot(` | ||
"const { withModuleFederationForSSR } = require('@nx/module-federation/rspack'); | ||
" | ||
`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.