-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new plugin configuration (#28)
- Loading branch information
1 parent
35498b3
commit 8dfd32c
Showing
31 changed files
with
6,926 additions
and
3,374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
/lib | ||
dist | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true, | ||
"source.fixAll": true | ||
"source.organizeImports": "explicit", | ||
"source.fixAll": "explicit" | ||
}, | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Rsbuild Project | ||
|
||
## Setup | ||
|
||
Install the dependencies: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
## Get Started | ||
|
||
Start the dev server: | ||
|
||
```bash | ||
pnpm dev | ||
``` | ||
|
||
Build the app for production: | ||
|
||
```bash | ||
pnpm build | ||
``` | ||
|
||
Preview the production build locally: | ||
|
||
```bash | ||
pnpm preview | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "examples-rust", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"dev": "rsbuild dev", | ||
"build": "rsbuild build", | ||
"preview": "rsbuild preview" | ||
}, | ||
"dependencies": { | ||
"@module-federation/enhanced": "0.2.5", | ||
"antd": "^5.16.2", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.22.3", | ||
"vue": "^3.4.29" | ||
}, | ||
"devDependencies": { | ||
"@rsbuild/core": "0.7.10", | ||
"@rsbuild/plugin-react": "0.7.10", | ||
"@types/react": "18.3.3", | ||
"@types/react-dom": "18.3.0", | ||
"typescript": "5.5.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack'; | ||
|
||
export default defineConfig({ | ||
server: { | ||
port: 5176, | ||
open: true, | ||
}, | ||
dev: { | ||
// It is necessary to configure assetPrefix, and in the production environment, you need to configure output.assetPrefix | ||
assetPrefix: 'http://localhost:5176', | ||
}, | ||
tools: { | ||
rspack: (config, { appendPlugins }) => { | ||
config.output!.uniqueName = 'app1'; | ||
appendPlugins([ | ||
new ModuleFederationPlugin({ | ||
name: 'examples_rust', | ||
remotes: { | ||
viteRemote: 'http://localhost:5173/dd/remoteEntry.js', | ||
}, | ||
remoteType: 'module', | ||
exposes: { | ||
'./app': './src/app.tsx', | ||
}, | ||
manifest: { | ||
filePath: 'manifestpath', | ||
}, | ||
shared: [ | ||
'react', | ||
'react-dom', | ||
'vue', | ||
// 'antd' | ||
], | ||
}), | ||
]); | ||
}, | ||
}, | ||
plugins: [ | ||
pluginReact({ | ||
splitChunks: { | ||
react: false, | ||
router: false, | ||
}, | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { applyVueInReact } from 'veaury'; | ||
import App from 'viteRemote/App'; | ||
const AppComponent = App.default; | ||
|
||
export default function Button() { | ||
return ( | ||
<div> | ||
rust host | ||
<hr /> | ||
<AppComponent /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import App from './App'; | ||
|
||
//@ts-ignore | ||
const root = ReactDOM.createRoot(document.getElementById('root')!); | ||
root.render( | ||
<React.StrictMode> | ||
<App basename={'/'} /> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="@rsbuild/core/types" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import('./bootstrap'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"target": "ES2020", | ||
"lib": ["DOM", "ES2020"], | ||
"module": "ESNext", | ||
"jsx": "react-jsx", | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"isolatedModules": true, | ||
"resolveJsonModule": true, | ||
"moduleResolution": "bundler", | ||
"useDefineForClassFields": true | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
pnpm-lock.yaml | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + Vue</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.jsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "examples-vite", | ||
"version": "0.0.3", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --force", | ||
"build": "vite build", | ||
"preview": "vite build && http-server --cors -p 5173 dist" | ||
}, | ||
"dependencies": { | ||
"module-federation-vite": "workspace:*", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.2.0", | ||
"vue": "^3.4.29", | ||
"vue-router": "^4.4.0" | ||
}, | ||
"devDependencies": { | ||
"@swc/core": "~1.6.0", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"@vitejs/plugin-vue": "^5.0.5", | ||
"vite": "^5.3.1", | ||
"vite-plugin-top-level-await": "^1.4.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import R from 'react'; | ||
import RD from 'react-dom'; | ||
import Mfapp01App from 'mfapp01/App'; | ||
import Remote2App from 'remote2/App'; | ||
import Button from 'remote3/button'; | ||
import { ref } from 'vue'; | ||
|
||
console.log('share vue', ref); | ||
console.log('share React', R, RD); | ||
|
||
export default function () { | ||
return ( | ||
<div> | ||
vite react | ||
<Button /> | ||
<Remote2App /> | ||
<Mfapp01App /> | ||
</div> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
//@ts-ignore | ||
const root = ReactDOM.createRoot(document.getElementById('app')); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); |
Oops, something went wrong.