refactor: restructure module federation SDK types and plugins#4510
refactor: restructure module federation SDK types and plugins#4510
Conversation
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d41a71044
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request. | ||
| */ | ||
| export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject; | ||
| // <-- BEGIN SCHEMA-GENERATED TYPES --> |
There was a problem hiding this comment.
Restore missing imports in ModuleFederationPlugin types
Replacing the file header with the schema marker removed the previous import type webpack from 'webpack' and import { Stats } from '../stats' lines, but the file still references webpack.Compiler, webpack.Compilation, and Stats in AdditionalDataOptions and related types. Any declaration/type-check pass over this file now fails with unresolved identifiers, which blocks SDK/enhanced builds.
Useful? React with 👍 / 👎.
| /** | ||
| * Tree-shake configuration for shared module. | ||
| */ | ||
| export interface TreeShakingConfig { |
There was a problem hiding this comment.
Remove duplicate TreeShakingConfig declaration
This commit introduces a new TreeShakingConfig declaration in the generated section while the legacy export type TreeShakingConfig = ... still exists later in the same file, so TypeScript sees duplicate identifiers in one module. This makes declaration generation/type-checking fail consistently until one of the declarations is removed or renamed.
Useful? React with 👍 / 👎.
# Conflicts: # .husky/pre-commit # packages/enhanced/project.json
@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 Report15 package(s) changed, 25 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 10.63 MB (-12378 B (-0.1%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
|
@ScriptedAlchemy ahh i fix all ci , can you help review it :D ? |
|
I verified locally and moved the actionable findings into inline review comments so each issue stays attached to the exact diff hunk. Tracked inline items:
|
| */ | ||
| export type Shared = (SharedItem | SharedObject)[] | SharedObject; | ||
|
|
||
| export type IncludeExcludeOptions = unknown | unknown | unknown; |
There was a problem hiding this comment.
IncludeExcludeOptions is currently generated as unknown | unknown | unknown, which erases the schema-defined shape and weakens type safety for shared.include / shared.exclude.
Expected behavior:
- preserve the concrete object shape generated from schema (
{ request?, version?, fallbackVersion? }) - keep parity with the standalone generated type in
packages/sdk/src/types/plugins/ConsumeSharedPlugin.ts
Requested fix:
- correct
packages/enhanced/src/scripts/generate-sdk-types.jsso this union is emitted with concrete members instead ofunknown - add/adjust generator coverage so this regression is caught in future runs
| dev?: boolean | PluginDevOptions; | ||
| dts?: boolean | PluginDtsOptions; | ||
| dataPrefetch?: DataPrefetch; | ||
| virtualRuntimeEntry?: boolean; |
There was a problem hiding this comment.
dataPrefetch appears to have been dropped from the exported SDK option surface even though runtime/plugin usage still exists.
Impact:
- TypeScript consumers using
dataPrefetch: truenow fail type-checking - downstream code is forced into
// @ts-ignoreeven when runtime behavior is still supported
Requested fix:
- restore
dataPrefetchin the public options typings generated for this surface - keep generated declarations aligned with the schema and runtime/plugin consumers
| /** | ||
| * Options for shared modules. | ||
| */ | ||
| export interface SharePluginOptions { |
There was a problem hiding this comment.
The generated declarations now keep SharePluginOptions but dropped the exported SharePlugin class declaration that existed on origin/main.
Impact:
- downstream TypeScript code referencing
sharePlugin.SharePluginbreaks at type level despite runtime class availability packages/managers/src/SharedManager.tsalready had to stop usingtypeof sharePlugin.SharePlugin, indicating declaration-surface regression
Requested fix:
- restore the
SharePluginclass declaration in the generated type surface (or provide an equivalent compatible exported class type) - keep declaration output backward-compatible with existing consumers
Summary: Calibrate Schemas, Sync Docs, Add Schema Change Hook
Background
Calibrated enhanced package schema descriptions to match implementations in packages/enhanced/src/lib, synchronized Chinese/English docs, and added a git hook to auto-generate validation/types when schemas change.
Changes
Generation
Docs Updates
Commands Run
Skipped Checks and Reasons
Acceptance Criteria