-
-
Notifications
You must be signed in to change notification settings - Fork 310
feat(enhanced): add request to consume share #3307
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
feat(enhanced): add request to consume share #3307
Conversation
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
} else if (config.layer) { | ||
return `(${config.layer})${request}`; | ||
} else { | ||
return request; |
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.
used for when there is no layer etc,
// module request prefix | ||
prefixed.set(request, config); | ||
const key = createCompositeKey(resolveRequest, config); |
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.
with the request param, i can now support prefix shared etc without a problem
🦋 Changeset detectedLatest commit: 92cebbb The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 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 |
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.
Summary
The pull request introduces several enhancements to the "ConsumeSharedPlugin" and related functionality in the "enhanced" package. The key changes are:
- Added an optional "request" property to the "ConsumesConfig" interface and the "ConsumeOptions" type. This allows specifying the actual request to use for importing the shared module, rather than relying on the property name/key. This provides more flexibility in how the shared module is imported and consumed.
- Introduced a new helper function "createLookupKey" to generate a composite key for looking up "unresolvedConsumes" based on the request and the issuer layer. This improvement helps in handling layer-specific requests in the "ConsumeSharedPlugin".
- Simplified the logic for finding a matching "ConsumeOptions" and creating the "ConsumeSharedModule" accordingly.
- Added a new function "resolveMatchedConfigs" that resolves shared module configurations based on their request type (relative, absolute, or module request) and updates the "resolveContext" object with the resolved and unresolved configurations, as well as the "contextDependencies" and "missingDependencies".
- Updated the validation schema for the "ConsumeSharedPlugin" object to include the new "request" property.
- Added new test cases for the "layers-consume-loader" feature, covering additional scenarios related to layer inheritance and shared dependencies.
These changes aim to enhance the flexibility and functionality of the "ConsumeSharedPlugin" and the overall shared module handling in the "enhanced" package.
File Summaries
File | Summary |
---|---|
packages/enhanced/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts | The code changes introduce a new optional property request to the ConsumesConfig interface. This property allows specifying the actual request to use for importing the shared module, rather than relying on the property name/key. This provides more flexibility in how the shared module is imported and consumed. |
packages/enhanced/src/lib/sharing/ConsumeSharedModule.ts | The code changes introduce a new optional property request to the ConsumeOptions type. This property allows specifying the actual request to use for importing the module, instead of using the property name/key as the default. This enhancement provides more flexibility in configuring the import process for shared modules. |
packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts | The code changes introduce a new helper function createLookupKey to generate a composite key for looking up unresolvedConsumes based on the request and the issuer layer. The main purpose of this change is to improve the handling of layer-specific requests in the ConsumeSharedPlugin . Additionally, the code simplifies the logic for finding a matching ConsumeOptions and creates the ConsumeSharedModule accordingly. |
packages/enhanced/src/lib/sharing/resolveMatchedConfigs.ts | The code changes introduce a new function resolveMatchedConfigs that takes a compilation object and a list of shared module configurations, and resolves the configurations based on their request type (relative, absolute, or module request). The function creates a composite key for each configuration based on the request and optional layer information, and then uses the Webpack resolver to resolve the configurations. The resolved configurations are stored in a resolved map, while the unresolved configurations are stored in an unresolved map. The function also updates the contextDependencies and missingDependencies properties of the resolveContext object. |
packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts | The changes introduce a new property 'request' to the validation schema for the 'ConsumeSharedPlugin' object. This addition ensures that the schema correctly validates the presence of the 'request' property, which is likely a new feature or requirement for the 'ConsumeSharedPlugin' functionality. |
packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.ts | The code changes introduce a new property called "request" to the "ConsumeSharedPlugin" schema. This property allows for specifying the actual request to use for importing a module, which can be different from the property name or key. This addition provides more flexibility in how shared modules are consumed, enabling developers to customize the import process as needed. |
packages/enhanced/test/configCases/sharing/layers-consume-loader/src/index.js | The code changes introduce new test cases for the "layers-consume-loader" feature. The primary modifications include adding two new test files, "lib-two.test.js" and "prefixed-share.test.js", which likely cover additional scenarios related to layer inheritance and shared dependencies. |
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.
Incremental Review
Comments posted: 14
Configuration
Squadron Mode: essential
Commits Reviewed
9884030e46a90a3d8bf215ddb2fc8e2b639d2995...76b53caf9615c2682aa124028181cc1ecc621aaa
Files Reviewed
- packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts
- packages/enhanced/src/lib/sharing/resolveMatchedConfigs.ts
- packages/enhanced/test/configCases/sharing/layers-consume-loader/src/index.js
- packages/enhanced/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts
- packages/enhanced/src/lib/sharing/ConsumeSharedModule.ts
- packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts
- packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .changeset/brown-badgers-fetch.md
- packages/enhanced/test/ConfigTestCases.template.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/loaders/multi-pkg-layer-loader.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/lib2/index.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/multi-pkg/thing1.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/multi-pkg/thing2.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/different-layers.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/lib-two.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/prefixed-share.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/unlayered-share.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/webpack.config.js
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.
Incremental Review
Comments posted: 12
Configuration
Squadron Mode: essential
Commits Reviewed
04b8ffdd26412715669fa17f9413b0d5b7275d23...92cebbb662d45d79af268a8bdf1c4a981f270ee3
Files Reviewed
- packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts
- packages/enhanced/src/lib/sharing/resolveMatchedConfigs.ts
- packages/enhanced/test/configCases/sharing/layers-consume-loader/src/index.js
- packages/enhanced/src/declarations/plugins/sharing/ConsumeSharedPlugin.d.ts
- packages/enhanced/src/lib/sharing/ConsumeSharedModule.ts
- packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.check.ts
- packages/enhanced/src/schemas/sharing/ConsumeSharedPlugin.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .changeset/brown-badgers-fetch.md
- packages/enhanced/test/ConfigTestCases.template.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/loaders/multi-pkg-layer-loader.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/lib2/index.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/multi-pkg/thing1.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/node_modules/multi-pkg/thing2.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/different-layers.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/lib-two.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/prefixed-share.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/tests/unlayered-share.test.js
- packages/enhanced/test/configCases/sharing/layers-consume-loader/webpack.config.js
Description
This pull request includes several changes to enhance the functionality of the
ConsumeSharedModule
andConsumeSharedPlugin
in thepackages/enhanced
library. The changes include adding new properties and methods to handle module layers and issuer layers, updating dependencies, and improving the resolution of shared modules.Enhancements to
ConsumeSharedModule
andConsumeSharedPlugin
:request
,layer
, andissuerLayer
to theConsumeOptions
type to support more granular control over module sharing. [1] [2] [3]ConsumeSharedModule
class to use the newlayer
property during initialization and in theidentifier
andreadableIdentifier
methods. [1] [2] [3]ConsumeSharedPlugin
class to include the new properties in the consume options and to use a helper functioncreateLookupKey
for creating composite keys with issuer layers. [1] [2] [3] [4] [5] [6] [7] [8]Dependency updates:
webpack-cli
as a new dependency inpackage.json
.enhanced:jest
for running Jest tests with experimental VM modules.Improvements to shared module resolution:
resolveMatchedConfigs
function to handle the newrequest
,layer
, andissuerLayer
properties, and to use regular expressions for matching relative and absolute paths. [1] [2] [3] [4] [5]Related Issue
Types of changes
Checklist