Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
更新baseUrl api
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangHongEn committed Dec 12, 2023
1 parent c986657 commit a03a2e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/mf-example/app1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@babel/preset-react": "^7.13.13",
"babel-loader": "^8.2.2",
"html-webpack-plugin": "^5.3.1",
"npm-federation": "^1.0.9",
"npm-federation": "^1.0.11",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/mf-example/app1/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as reactRouter from "react-router"
import * as reactRouter from "@remix-run/router"
import React from "react";
import ReactDom from "react-dom";
console.log("react-router", reactRouter)
console.log("remix-router", reactRouter)

const App = () => {
return (
Expand Down
17 changes: 9 additions & 8 deletions packages/mf-example/app1/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,31 @@ module.exports = {
plugins: [
// To learn more about the usage of this plugin, please visit https://webpack.js.org/plugins/module-federation-plugin/
new NpmFederation({
// Inject some code through initial (not required)
initial: `
console.log("Inject code wpmjsInstance", wpmjs)
wpmjs.sleep(new Promise(resolve => {
// fetch("https://xxxxx.json")
const json = {
"@remix-run/router": {
packageVersion: "1.9.0"
},
"mf-app-02": {
packageVersion: "1.0.6"
}
}
setTimeout(() => {
console.log("Asynchronously obtain data and dynamically set the remotes version", json)
wpmjs.addImportMap(json)
resolve()
}, 100)
}))
`,
config: {
baseUrl: "https://cdn.jsdelivr.net/npm"
},
}))`,
baseUrl: "https://cdn.jsdelivr.net/npm",
remotes: {
"@remix-run/router": "@remix-run/router/dist/router.umd.min.js",
"react-router": "react-router@latest/dist/umd/react-router.development.js",
"mf-app-02": "mfapp02@https://cdn.jsdelivr.net/npm/mf-app-02/dist/remoteEntry.js"
"mf-app-02": {
package: "mf-app-02/dist/remoteEntry.js",
global: "mfapp02"
},
},
name: 'mfapp01',
filename: 'remoteEntry.js',
Expand Down

0 comments on commit a03a2e6

Please sign in to comment.