fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug#4502
fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug#4502
Conversation
…ourceCategory bug
🦋 Changeset detectedLatest commit: 490b067 The changes in this PR will be included in the next version bump. This PR includes changesets to release 45 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/data-prefetch
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report18 package(s) changed, 23 unchanged. Package dist + public ESM exports
Bundle targets
Total dist (raw): 10.67 MB (-26285 B (-0.2%)) Bundle sizes are generated with rslib (Rspack). Public ESM gzip aggregates explicit package export entry files (wildcard exports are ignored). Web/node bundles synthesize a single entry that imports those public ESM exports, set ENV_TARGET, and enable tree-shaking. Bare imports are externalized to keep sizes consistent with prior reporting, and assets are emitted as resources. |
fix(runtime-core): improve error messages clarity and fix preload resourceCategory bug
Summary
Reviewed and improved error messages across
packages/runtime-coreto make failureseasier to diagnose for both developers and AI agents. Also fixed a silent logic bug
in the preload asset generation path.
Bug Fix
plugins/generate-preload-assets.ts: Assignment operator=was used instead ofstrict equality
===in theresourceCategorybranch check. This caused the conditionto always be truthy and silently overwrite
preloadConfig.resourceCategoryto'sync'for every non-
'all'entry, resulting in incorrect preload asset selection with no errorreported.
Error Message Improvements
utils/load.tsloadEsmEntry): barereject(e)in catch now includes theentry URL and original error message.
loadSystemJsEntry): same as above.loadEntryNode): barethrow enow includes remote nameand entry URL.
error()fromlogger.tsso the[ Federation Runtime ]prefix isapplied consistently.
plugins/snapshot/SnapshotHandler.tshostName: moduleInfo.name(which is actuallythe remote name) and omitted the actual host. Now correctly passes
remoteName,remoteVersion, andhostNameseparately so the error context is unambiguous.assert): replaced the generic"${url} is not a federation manifest"message with one that names the remote andlists exactly which required fields (
metaData,exposes,shared) are missing.shared/index.tsloadShareassertion: message now quotes the package name and host name, and providesan actionable hint about where to declare the shared config.
initRemoteModule: whenerrorLoadRemotehook returnsundefined(no plugin handledthe error), the function now returns early instead of falling into the
finallyblockwith an undefined
remoteEntryExports, which previously caused a silent no-op orpotential
Cannot read properties of undefinedcrash.utils/share.tsformatShare— missingget/liberror: now includes the package name and sourcemodule (
from) so it's clear which share registration is misconfigured.formatShare—eager+treeShakingconflict: now includes the package name andsource module instead of a generic string.
error()fromlogger.tsfor consistent prefix handling.global.tsgetInfoWithoutType: generic'key must be string'replaced with the actual typeand serialised value of the bad argument.
remote/index.tsremoveRemote:logger.log(...)(info-level) changed tologger.error(...)so thefailure surfaces at the correct severity level.
Testing
All changes are confined to error paths (catch blocks, assertions, and branch conditions).
The preload bug fix restores the originally intended
sync-only asset filtering behavior.