Skip to content

Conversation

ScriptedAlchemy
Copy link
Member

This PR sets up shared third‑party context dependencies across Next apps 3000-home and 3001-shop.\n\nSummary\n- Add @tanstack/react-query (+devtools) to both apps\n- Configure Module Federation singletons for @tanstack/react-query and @tanstack/query-core in each Next config\n- Wrap both apps with QueryClientProvider using a window-scoped singleton on the client and per-request client on SSR\n- Devtools enabled in non-production\n\nWhy\nEnsures remotes/hosts share one React Query cache and context, preventing duplicate clients and inconsistent cache state across federated pages.\n\nFollow-ups\n- Optionally add a demo page in host+remote using useQuery to visibly confirm shared cache\n- Consider centralizing providers into a small workspace package for future shared contexts (i18n/auth/analytics)\n

ScriptedAlchemy and others added 30 commits August 27, 2025 21:55
…shared modules

- Add opencode.json with alias-resolver agent for fixing webpack alias issues
- Add comprehensive prompt documentation for Module Federation alias resolution
- Add failing test case demonstrating shared module alias bug
- Add AGENTS.md with repository guidelines and commands
- Add alias resolution support for shared modules
- Relax strict instance matching to package identity checks
- Implement version inference from module source
- Add caching for consume shared modules
- Update test expectations for alias sharing
… provide hook

- ConsumeSharedPlugin: simplify factorize flow (no behavior change)

- Rename nodeModulesReconstructedLookup to allowNodeModulesSuffixMatch

- ProvideSharedPlugin: add helpers for layer checks and prefix matches

- Mark alias resolver docs out of scope

BREAKING CHANGE: option renamed to allowNodeModulesSuffixMatch
- Use descriptionFileData to build candidates (pkgName/relative path)

- Match candidates in consume and provide hooks

- Keep behavior/gating for suffix/prefix matching
This reverts commit 667a941.
…dules

- Add Stage 3 in ProvideSharedPlugin to recognize aliased imports when only target is shared
- Add Stage 6 in ConsumeSharedPlugin to resolve aliased requests against shared config
- Add aliasResolver utility for extracting node_modules paths
- Add provide-only config test case and unit test for alias-aware behavior
- Clean up existing alias test assertions
- Update .gitignore to include test mock node_modules
…only

Adds the required node_modules/next/dist/compiled/react/index.js stub
that the alias points to, fixing the failing config case test.
Apply suggested changes
… caching

Move path equality checks to afterResolve for determinism.

Cache target resolutions and track deps to reduce resolver churn.
Align tests with plugin tapping afterResolve to prevent undefined hook errors.
Skip data: resources in afterResolve and createModule.

Preserve virtual module handling by webpack.

Broaden afterResolve candidates for deep-path shares.

Example: next/dist/compiled/react alias.

Avoid converting explicit relative or absolute requests into consumes.

Preserves local nested resolution for deep sharing.

Keep prefix and node_modules suffix matching as before.

Add a changeset for @module-federation/enhanced.
ScriptedAlchemy and others added 11 commits September 22, 2025 15:54
- Gate alias-aware consuming behind experiments.aliasConsumption (opt-in)
- Remove FEDERATION_ALIAS_CONSUMPTION env usage
- Update schemas for MF/Share/Consume plugins
- Forward aliasConsumption only when defined
- Enhanced tests passing locally
- Use webpack/lib/util/semver satisfy(parseRange(...), version)
- Correct include/exclude version checks
- Remove conflict markers and update .gitignore
Replace deprecated property in share-internals client/server.

Cast to moduleFederationPlugin.SharedConfig in internal.ts.

Verified via Nx builds.
- Skip adding layer queries to loader chains (paths containing '!')
- Remove unsupported layer property from user configurations
- Improve layer handling to prevent build errors with pages-map exposes
- Clean up unused noop path methods and commented code
- Remove duplicated webpack external logic from share-internals
- Consolidate client and server share internals configurations
- Remove unused server-specific externals handling
- Update NextFederationPlugin to handle share internals more efficiently
- Re-add react-query singleton configuration to 3000-home, 3001-shop, and 3002-checkout
- Export getShareInternals from internal module
- Update share internals to properly handle react-query singleton
- Fix Next.js app configurations to ensure singleton behavior works correctly
@ScriptedAlchemy
Copy link
Member Author

@codex review and improve

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@ScriptedAlchemy
Copy link
Member Author

@codex review pr again deeply

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

- Only rewrite fallback when a string import was configured
- Preserve remote-only consumes (import: false) in alias fallback
- Add unit test: ConsumeSharedPlugin.alias-fallback-import-false

test(enhanced): use full federation + async boundary for Next pages config cases

- Convert next-pages-layer-unify to ModuleFederationPlugin
- Add suite.js with dynamic import to create async startup boundary
- Adjust consume-with-aliases-generic(-provider) to match full federation flow

chore(enhanced): narrow enhanced:jest to build enhanced + deps only

- Avoids unrelated workspace build failures while running enhanced tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant