Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove resourceQuery from dts generation #3629

Merged
merged 14 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-garlics-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

remove query strings from exposed modules to fix tsc resolves
5 changes: 5 additions & 0 deletions .changeset/nine-lies-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/node': patch
---

support undoPath and rootOutputDir for correct remote chunk resolution in node
17 changes: 0 additions & 17 deletions .cursorignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,7 @@
**/tsconfig.*
**/*/stats.json

# First ignore everything
*

# Then allow specific packages and their contents
!packages/webpack-bundler-runtime/
!packages/webpack-bundler-runtime/**/*
!packages/sdk/
!packages/sdk/**/*
!packages/enhanced/
!packages/enhanced/**/*

# Allow package.json files
!package.json
!packages/*/package.json
!**/package.json

# Explicitly ignore specific packages
packages/dts-plugin/
packages/typescript/
packages/native-*
packages/core/
Expand Down
27 changes: 23 additions & 4 deletions packages/dts-plugin/src/plugins/DtsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,26 @@ export class DtsPlugin implements WebpackPluginInstance {
apply(compiler: Compiler) {
const { options } = this;

const normalizedDtsOptions = normalizeDtsOptions(options, compiler.context);
// Create a shallow clone of the options object to avoid mutating the original
const clonedOptions = { ...options };

// Clean up query parameters in exposes paths without mutating original
if (options.exposes && typeof options.exposes === 'object') {
const cleanedExposes: Record<string, any> = {};
Object.entries(options.exposes).forEach(([key, value]) => {
if (typeof value === 'string') {
cleanedExposes[key] = value.split('?')[0];
} else {
cleanedExposes[key] = value;
}
});
clonedOptions.exposes = cleanedExposes;
}

const normalizedDtsOptions = normalizeDtsOptions(
clonedOptions,
compiler.context,
);

if (typeof normalizedDtsOptions !== 'object') {
return;
Expand All @@ -67,22 +86,22 @@ export class DtsPlugin implements WebpackPluginInstance {
// Because the plugin will delete dist/@mf-types.zip while generating types, which will be used in GenerateTypesPlugin
// So it should apply after GenerateTypesPlugin
new DevPlugin(
options,
clonedOptions,
normalizedDtsOptions,
generateTypesPromise,
fetchRemoteTypeUrlsPromise,
).apply(compiler);

// The exposes files may use remote types, so it need to consume types first, otherwise the generate types will fail
new GenerateTypesPlugin(
options,
clonedOptions,
normalizedDtsOptions,
fetchRemoteTypeUrlsPromise,
generateTypesPromiseResolve,
).apply(compiler);

new ConsumeTypesPlugin(
options,
clonedOptions,
normalizedDtsOptions,
fetchRemoteTypeUrlsResolve,
).apply(compiler);
Expand Down
Loading