fix(rstest): resolve node runtime plugin from package#4573
fix(rstest): resolve node runtime plugin from package#4573ScriptedAlchemy merged 8 commits intorstest-pluginfrom
Conversation
🦋 Changeset detectedLatest commit: 810a35a The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 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 |
packages/rstest/src/index.ts
Outdated
| const NODE_RUNTIME_PLUGIN = '@module-federation/node/runtimePlugin'; | ||
| const require = createRequire(import.meta.url); | ||
| const NODE_RUNTIME_PLUGIN = | ||
| require.resolve('@module-federation/node/runtimePlugin'); |
There was a problem hiding this comment.
dont need require.resolve for it. canjust pass the string as the path cant we?
| return typeof runtimePlugin === 'string' ? runtimePlugin : runtimePlugin[0]; | ||
| }; | ||
|
|
||
| const normalizeRuntimePlugin = ( |
There was a problem hiding this comment.
no need for normalization
|
|
||
| const existingRuntimePlugins = toArray(merged.runtimePlugins); | ||
| if (!existingRuntimePlugins.includes(NODE_RUNTIME_PLUGIN)) { | ||
| const existingRuntimePlugins = toArray(merged.runtimePlugins).map( |
There was a problem hiding this comment.
assume there wont be existing runtime plugin, maybe just warning if there is since we shoul dbe managing it internally only and user neever need to
@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/rstest
@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: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1c52313b1
ℹ️ 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
- 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 address that feedback".
packages/rstest/src/index.ts
Outdated
| const NODE_RUNTIME_PLUGIN = | ||
| require.resolve('@module-federation/node/runtimePlugin'); |
There was a problem hiding this comment.
Guard runtime plugin resolution against missing dist artifacts
Resolve @module-federation/node/runtimePlugin lazily or with a fallback instead of at module load time. This eager require.resolve(...) throws MODULE_NOT_FOUND in clean workspace checkouts where @module-federation/node hasn’t been built yet (its export points at dist/src/runtimePlugin.js), so importing @module-federation/rstest fails before federation() runs—even for browser-target usage that doesn’t need the Node runtime plugin.
Useful? React with 👍 / 👎.
Description
Resolve the Node runtime plugin from
@module-federation/rstestitself so node-based rstest configs do not require consuming apps to install@module-federation/nodedirectly. This also removes the demo server global process state, combines the branch changesets into one, adds English and Chinese docs pages for rstest, and ignores generateddist-nodeoutput.Related Issue
N/A
Types of changes
Checklist
Validation run:
pnpm --filter @module-federation/rstest testpnpm --filter @module-federation/rstest buildpnpm exec prettier --checkon touched filespnpm run ci:local --only=e2e-rstestNotes:
@module-federation/node/runtimePluginfailure is fixed.e2e-rsteststill fails in the browser lane because@rstest/coreis0.8.5while@rstest/browseris0.8.1, which is pre-existing and outside this branch scope.