Skip to content

Commit 5ea7aea

Browse files
fix(dts-plugin): lazy emit subsequent type generations (#3345)
Co-authored-by: 2heal1 <[email protected]>
1 parent 61625d4 commit 5ea7aea

File tree

13 files changed

+1233
-73
lines changed

13 files changed

+1233
-73
lines changed

.changeset/twelve-dingos-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/dts-plugin': patch
3+
---
4+
5+
Lazy emit DTS files on hmr rebuilds, do not block compiler pipeline

.cursorignore

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
./tmp
33
./scripts
44
./.git
5-
./packages/storybook-addon
6-
./packages/core
7-
./packages/utilities
8-
./packages/typescript
9-
./packages/native-*
10-
./apps
5+
packages/storybook-addon
6+
packages/core
7+
packages/utilities
8+
packages/typescript
9+
packages/native-*
10+
apps
1111
**/configCases
12+
**/dist
1213
apps/**
1314
*.snap
15+
*.js
16+

apps/manifest-demo/3010-rspack-provider/rspack.config.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = composePlugins(
4242
transform: {
4343
react: {
4444
runtime: 'automatic',
45+
refresh: true,
4546
},
4647
},
4748
},
@@ -60,6 +61,18 @@ module.exports = composePlugins(
6061
// publicPath must be specific url
6162
config.output.publicPath = 'http://localhost:3010/';
6263

64+
const rspackPlugin = config.plugins.find((plugin) => {
65+
return plugin.name === 'HtmlRspackPlugin';
66+
});
67+
68+
if (rspackPlugin && rspackPlugin._args && rspackPlugin._args[0]) {
69+
rspackPlugin._args[0].excludeChunks = ['rspack_provider'];
70+
} else {
71+
console.warn(
72+
'HtmlRspackPlugin not found or has unexpected structure. Skipping excludeChunks configuration.',
73+
);
74+
}
75+
6376
config.plugins.push(
6477
new ModuleFederationPlugin({
6578
name: 'rspack_provider',
@@ -70,10 +83,10 @@ module.exports = composePlugins(
7083
shared: {
7184
lodash: {},
7285
antd: {},
73-
'react/': {
74-
singleton: true,
75-
requiredVersion: '^18.3.1',
76-
},
86+
// 'react/': {
87+
// singleton: true,
88+
// requiredVersion: '^18.3.1',
89+
// },
7790
react: {
7891
singleton: true,
7992
requiredVersion: '^18.3.1',

apps/react-ts-host/webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module.exports = composePlugins(
1212
withNx(),
1313
withReact(),
1414
async (config, context) => {
15+
config.devServer = config.devServer || {};
16+
config.devServer.host = '127.0.0.1';
1517
// prevent cyclic updates
1618
config.watchOptions = {
1719
ignored: ['**/node_modules/**', '**/@mf-types/**'],

apps/react-ts-nested-remote/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ module.exports = composePlugins(
1111
withNx(),
1212
withReact(),
1313
async (config, context) => {
14+
if (!config.devServer) {
15+
config.devServer = {};
16+
}
17+
config.devServer.host = '127.0.0.1';
1418
config.output.publicPath = 'http://localhost:3005/';
1519
// prevent cyclic updates
1620
config.watchOptions = {

apps/react-ts-remote/rspack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ module.exports = composePlugins(
8888
client: {
8989
overlay: false,
9090
},
91+
host: '127.0.0.1',
9192
port: 3004,
9293
devMiddleware: {
9394
writeToDisk: true,

apps/react-ts-remote/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ module.exports = composePlugins(
1212
withNx(),
1313
withReact(),
1414
async (config, context) => {
15+
if (!config.devServer) {
16+
config.devServer = {};
17+
}
18+
config.devServer.host = '127.0.0.1';
1519
const baseConfig = {
1620
name: 'react_ts_remote',
1721
filename: 'remoteEntry.js',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"prepare": "husky install",
5050
"changeset": "changeset",
5151
"build:packages": "npx nx affected -t build --parallel=10 --exclude='*,!tag:type:pkg'",
52-
"changegen": "./changeset-gen.js --path ./packages/enhanced --staged &&./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged",
52+
"changegen": "./changeset-gen.js --path ./packages/enhanced --staged && ./changeset-gen.js --path ./packages/node --staged && ./changeset-gen.js --path ./packages/runtime --staged && ./changeset-gen.js --path ./packages/data-prefetch --staged && ./changeset-gen.js --path ./packages/nextjs-mf --staged && ./changeset-gen.js --path ./packages/dts-plugin --staged",
5353
"commitgen:staged": "./commit-gen.js --path ./packages --staged",
5454
"commitgen:main": "./commit-gen.js --path ./packages",
5555
"changeset:status": "changeset status"

0 commit comments

Comments
 (0)