module-federation / core

Module Federation is a concept that allows developers to share code and resources across multiple JavaScript applications
https://module-federation.io/
MIT License
1.44k stars 215 forks source link

feat: recursive search for shared version #2681

Open robdonn opened 3 months ago

robdonn commented 3 months ago

Description

Allows @module-federation/enhanced to recursively search for the version of a shared module when it is not defined in it's closest package.json. A common pattern for monorepos is to have dependencies installed in the root package.json.

/monorepo
├── package.json        <---------- "lib1" dependency defined here
├── apps
│   ├── app1
│   │   ├── package.json
│   │   ├── node_modules
│   │   ├── webpack.config.js     <-------- "lib1" added to "shared" configuration here
│   │   └── src
│   │       ├── index.js
│   │       └── ...
│   └── app2
│       ├── package.json
│       ├── node_modules
│   │   ├── webpack.config.js
│       └── src
│           ├── index.js
│           └── ...
└── node_modules

Related Issue

2680

Types of changes

Checklist

changeset-bot[bot] commented 3 months ago

🦋 Changeset detected

Latest commit: e36fd749db46438c4097ab3b54130a6514109157

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages | Name | Type | | ---------------------------------------------- | ----- | | @module-federation/enhanced | Minor | | @module-federation/modern-js | Minor | | @module-federation/nextjs-mf | Patch | | @module-federation/node | Patch | | 3008-runtime-remote | Patch | | host | Patch | | host-v5 | Patch | | host-vue3 | Patch | | remote1 | Patch | | remote2 | Patch | | remote3 | Patch | | remote4 | Patch | | @module-federation/modernjs | Patch | | modernjs-ssr-dynamic-nested-remote | Patch | | modernjs-ssr-dynamic-remote-new-version | Patch | | modernjs-ssr-dynamic-remote | Patch | | modernjs-ssr-host | Patch | | modernjs-ssr-nested-remote | Patch | | modernjs-ssr-remote-new-version | Patch | | modernjs-ssr-remote | Patch | | @module-federation/runtime | Minor | | @module-federation/rspack | Minor | | @module-federation/webpack-bundler-runtime | Minor | | @module-federation/sdk | Minor | | @module-federation/runtime-tools | Minor | | @module-federation/managers | Minor | | @module-federation/manifest | Minor | | @module-federation/dts-plugin | Minor | | @module-federation/third-party-dts-extractor | Minor | | @module-federation/devtools | Minor | | @module-federation/bridge-react | Minor | | @module-federation/bridge-vue3 | Minor | | @module-federation/bridge-shared | Minor | | @module-federation/bridge-react-webpack-plugin | Minor | | @module-federation/retry-plugin | Minor | | @module-federation/esbuild | Patch | | @module-federation/utilities | Patch |

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

netlify[bot] commented 3 months ago

Deploy Preview for module-federation-docs failed. Why did it fail? →

Name Link
Latest commit e36fd749db46438c4097ab3b54130a6514109157
Latest deploy log https://app.netlify.com/sites/module-federation-docs/deploys/66e9c6acc8871e000886cd74
ScriptedAlchemy commented 3 months ago

I will have to see about backporting this to rspack first before i can consider merge, will follow up

robdonn commented 3 months ago

I will have to see about backporting this to rspack first before i can consider merge, will follow up

No problem, let me know if you need any more info/context

ScriptedAlchemy commented 3 months ago

no, it makes sense. Just need to look at the rust end and sync the implementation