0.0.4 • Published 2 years ago
astro-module-federation v0.0.4
astro-module-federation
This is an Astro integration that adds the @originjs/vite-plugin-federation to your Astro project.
Usage
Pre-requisites
You need to add a server integration to your Astro app and set the output to server.
Installation
Install the integration automatically using the Astro CLI:
pnpm astro add astro-module-federationnpx astro add astro-module-federationyarn astro add astro-module-federationOr install it manually:
- Install the required dependencies
pnpm add astro-module-federation
pnpm add @originjs/vite-plugin-federation -Dnpm install astro-module-federation
npm install @originjs/vite-plugin-federation -Dyarn add astro-module-federation
yarn add @originjs/vite-plugin-federation -D- Add the integration to your astro config
+import astroModuleFederation from "astro-module-federation";
export default defineConfig({
integrations: [
+ astroModuleFederation({ ... }),
],
});Configuration
For the full list of properties refer to the vite-plugin-federation usage section.
Example for Astro host app
Example config with the Node and React adapters
export default defineConfig({
output: "server",
integrations: [react(), moduleFederation({
remotes: {
viteApp: "http://localhost:4173/assets/remoteEntry.js"
},
shared: ['react', 'react-dom']
})],
adapter: node({
mode: "standalone"
})
});Contributing
This package is structured as a monorepo:
playgroundcontains code for testing the packagepackagecontains the actual package
Install dependencies using pnpm:
pnpm i --frozen-lockfileStart the playground:
pnpm playground:devVite Remote App Astro Host App
You can now edit files in package. Please note that making changes to those files may require restarting the playground dev server.
TODO
- Figure out how to handle missing assets and styles.
- Figure out how to use Astro as a remote.
Licensing
MIT Licensed. Made with ❤️ by bartektricks.