-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(module-federation): collect secondary entry points from exports #26878 #27999
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit ab2052e. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 4 targets
Sent with 💌 from NxCloud. |
4baffff
to
1f8c66b
Compare
packages/webpack/src/utils/module-federation/secondary-entry-points.ts
Outdated
Show resolved
Hide resolved
1f8c66b
to
ab2052e
Compare
@Coly010 Thank you for addressing this! I was able to drastically simplify my config. |
}[] | ||
): void { | ||
for (const [relativeEntryPoint, exportOptions] of Object.entries(exports)) { | ||
if (exportOptions?.['default']?.search(/\.(js|mjs|cjs)$/)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Coly010 This causes the following error in some cases because for whatever reason search is not a function and it does not handle that gracefully.
NX exportOptions?.default?.search is not a function
Can we update this to the following to have a bit more safety around this and prevent that error?
if (exportOptions?.['default']?.search(/\.(js|mjs|cjs)$/)) { | |
if (exportOptions?.['default']?.search?.(/\.(js|mjs|cjs)$/)) { |
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
Some packages that use
exports
in the package.json may point to a directory such asesm/<entrypoint>
.They would still be imported such as
mypackage/secondary-point
.This needs to be shared still for Module Federation.
However, our current logic for finding secondary entry points for packages looks at the sub dirs of the package and tries to match it with the exports fiels.
Therefore if
mypackage/secondary-point
was set up such thatthen it would never be found correctly, causing share problems.
Expected Behavior
exports of secondary entrypoints should be shared correctly
Related Issue(s)
Fixes #26878