Skip to content

Commit

Permalink
fix: module federation layout
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong committed Sep 23, 2020
1 parent 9b9475f commit 12aa7f2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
30 changes: 20 additions & 10 deletions bin/webpack/baseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const getBaseConfig = async () => {

module: {
rules: [
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
},
{
test: /\.js[x]?$/,
use: [
Expand Down Expand Up @@ -82,7 +88,7 @@ const getBaseConfig = async () => {
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')()],
postcssOptions: { plugins: [require('autoprefixer')()] },
},
},
],
Expand All @@ -103,7 +109,7 @@ const getBaseConfig = async () => {
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')()],
postcssOptions: { plugins: [require('autoprefixer')()] },
},
},
'sass-loader',
Expand All @@ -122,7 +128,7 @@ const getBaseConfig = async () => {
{
loader: 'postcss-loader',
options: {
plugins: [require('autoprefixer')()],
postcssOptions: { plugins: [require('autoprefixer')()] },
},
},
'sass-loader',
Expand Down Expand Up @@ -168,10 +174,15 @@ const getBaseConfig = async () => {
// 注册服务
new ModuleFederationPlugin({
name: APP_CONFIG.syscode,
library: { type: 'var', name: APP_CONFIG.syscode },
library:
APP_CONFIG.syscode === 'layout' ? undefined : { type: 'var', name: APP_CONFIG.syscode },
remotes: {
layout: `layout@/${APP_CONFIG.target}system/layout/remoteEntry.js`,
},
filename: 'remoteEntry.js',
exposes: {
Routes: './src/routes',
'./bootstrap': './src/bootstrap',
},
shared: {
...deps,
Expand Down Expand Up @@ -209,14 +220,14 @@ const getBaseConfig = async () => {
resolveLoader: {
modules: [
'node_modules',
resolveAutosPath('node_modules'),
resolveProjectPath('node_modules'),
resolveAutosPath('node_modules'),
],
},
cache: {
type: 'filesystem',
buildDependencies: { config: [__filename] },
},
// cache: {
// type: 'filesystem',
// buildDependencies: { config: [__filename] },
// },
}

/**
Expand Down Expand Up @@ -265,7 +276,6 @@ const getBaseConfig = async () => {
typescript: {
context: resolveProjectPath(),
configFile: resolveProjectPath('tsconfig.json'),
typescriptPath: resolveProjectPath('node_modules/typescript'),
},
}),
],
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"optimize-css-assets-webpack-plugin": "^5.0.4",
"ora": "^5.1.0",
"portfinder": "^1.0.28",
"postcss": "^8.0.5",
"postcss": "^8.0.6",
"postcss-loader": "^4.0.2",
"react-dev-utils": "^10.2.1",
"react-error-overlay": "^6.0.7",
Expand All @@ -85,7 +85,7 @@
"thread-loader": "^3.0.0",
"ts-loader": "^8.0.3",
"url-loader": "^4.1.0",
"webpack": "^5.0.0-beta.30",
"webpack": "^5.0.0-rc.0",
"webpack-bundle-analyzer": "^3.8.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
Expand All @@ -107,7 +107,8 @@
"husky": "^4.2.5",
"lint-staged": "^10.2.13",
"np": "^6.2.4",
"prettier": "^2.1.1"
"prettier": "^2.1.1",
"typescript": "^4.0.3"
},
"config": {
"commitizen": {
Expand Down
77 changes: 41 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2874,14 +2874,6 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0:
dependencies:
once "^1.4.0"

[email protected]:
version "5.0.0-beta.10"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.10.tgz#3907c034f8e59446dfa5a89a1fd73db29aa0f246"
integrity sha512-vEyxvHv3f8xl7i7QmTQ6BqKY32acSPQ4dTZo8WRMtcqTDYH9YyXnDxqXsQqBLvdRHUiwl9nVivESiM1RcrxbKQ==
dependencies:
graceful-fs "^4.2.0"
tapable "^2.0.0-beta.10"

enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.1:
version "4.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.3.0.tgz#3b806f3bfafc1ec7de69551ef93cca46c1704126"
Expand All @@ -2891,6 +2883,14 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.1:
memory-fs "^0.5.0"
tapable "^1.0.0"

enhanced-resolve@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0.tgz#4737e6ebd4f2fd13fe23f4cec9d02146afc2c527"
integrity sha512-6F037vvK16tgLlRgUx6ZEZISMysNvnnk09SILFrx3bNa1UsSLpIXFzWOmtiDxf1ISPAG6/wHBI61PEkeuTLVNA==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.0.0"

enquirer@^2.3.5:
version "2.3.5"
resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.5.tgz#3ab2b838df0a9d8ab9e7dff235b0e8712ef92381"
Expand Down Expand Up @@ -7431,10 +7431,10 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.32, postcss@^7.0.5
source-map "^0.6.1"
supports-color "^6.1.0"

postcss@^8.0.5:
version "8.0.5"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.0.5.tgz#8210e2363f85c35a88a188ce7a0828e93b1088d4"
integrity sha512-3rDm6KR0jHstte3aL3ugrCyFA1UXY90SWNwRZ2WTmRf/QpOqM35mm0FrRR+HHZQ5fY9+nXFat1nl2ekYJf0P4w==
postcss@^8.0.6:
version "8.0.6"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.0.6.tgz#1507160d7df320c77f8f4819cf52491f4748b672"
integrity sha512-P4lvqkhoiba/w0JE1t432xlQyeJnnf1elrviZOX0GybserV79IN4skB2nQg+NoOmkq30MNqVv9ggdqVmYjaolA==
dependencies:
colorette "^1.2.1"
line-column "^1.0.2"
Expand Down Expand Up @@ -8896,10 +8896,10 @@ tapable@^1.0.0, tapable@^1.1.3:
resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==

tapable@^2.0.0-beta.10, tapable@^2.0.0-beta.11:
version "2.0.0-beta.11"
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0-beta.11.tgz#5a6bd5e0353fad4da9e94942206bb596639e8cf7"
integrity sha512-cAhRzCvMdyJsxmdrSXG8/SUlJG4WJUxD/csuYAybUFjKVt74Y6pTyZ/I1ZK+enmCkWZN0JWxh14G69temaGSiA==
tapable@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0.tgz#a49c3d6a8a2bb606e7db372b82904c970d537a08"
integrity sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg==

tar-stream@^1.5.2:
version "1.6.2"
Expand Down Expand Up @@ -9279,6 +9279,11 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==

uglify-js@^3.1.4:
version "3.9.3"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.9.3.tgz#4a285d1658b8a2ebaef9e51366b3a0f7acd79ec2"
Expand Down Expand Up @@ -9518,10 +9523,10 @@ ware@^1.2.0:
dependencies:
wrap-fn "^0.1.0"

[email protected]-beta.15:
version "2.0.0-beta.15"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.15.tgz#0e69c8e5d680c7b4c181db3f70e500ca84cef794"
integrity sha512-zyhhC7vEajo5fZEUxlhVpC1uLAOs088zy8RwzcMp8YucTBirNCNmTFQWVeoKxKNNqEfYUBQdVzW3wfItcc/eUQ==
watchpack@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0.tgz#b12248f32f0fd4799b7be0802ad1f6573a45955c"
integrity sha512-xSdCxxYZWNk3VK13bZRYhsQpfa8Vg63zXG+3pyU8ouqSLRCv4IGXIp9Kr226q6GBkGRlZrST2wwKtjfKz2m7Cg==
dependencies:
glob-to-regexp "^0.4.1"
graceful-fs "^4.1.2"
Expand Down Expand Up @@ -9642,14 +9647,6 @@ webpack-merge@^5.1.4:
clone-deep "^4.0.1"
wildcard "^2.0.0"

[email protected]:
version "2.0.0-beta.10"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.0.0-beta.10.tgz#f603355c5518141976601bfd620a3a5a01ac7b5d"
integrity sha512-HxeYa9Q6nMk3MtSbi5mKUUV+gOxYlGQwujKbeK0JQ+SmLSMgC4cQkZ+xpsWvsUtTvskDwpKvuVLpE9eW7vn0IQ==
dependencies:
source-list-map "^2.0.1"
source-map "^0.6.1"

webpack-sources@^1.1.0, webpack-sources@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
Expand All @@ -9658,10 +9655,18 @@ webpack-sources@^1.1.0, webpack-sources@^1.4.3:
source-list-map "^2.0.0"
source-map "~0.6.1"

webpack@^5.0.0-beta.30:
version "5.0.0-beta.30"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.0.0-beta.30.tgz#11cf2d4ed1ec78eb836da2a7be7809e5e074e3eb"
integrity sha512-pOAAo71m6icygRrOPn/lQM4Ky8MN+9dDBwEU9Get285VBbmuZE6AFqizEEV692mYgUit/0+7vnjsnUr8xX2puA==
webpack-sources@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-2.0.0.tgz#602d4bc7ff2e630ceb753a09ef49f260fa4ae7f0"
integrity sha512-CpCkDjEKa5vYVRDFDRABBkBomz+82lz9bpXViN1LBc8L/WDXvSyELKcBvBnTeDEiRfMJCGAFG9+04406PLSsIA==
dependencies:
source-list-map "^2.0.1"
source-map "^0.6.1"

webpack@^5.0.0-rc.0:
version "5.0.0-rc.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.0.0-rc.0.tgz#166f6d9cd65912ff021695d82256b2f1e6e858ee"
integrity sha512-tHUFu4vaZxJuyKYf8FKkDZmxnf0txy6twNewxUlviFo+GYjFoGW3szD71cOw0NtJBiyGAQ9zLGVzfb2pXBSKVA==
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.45"
Expand All @@ -9671,7 +9676,7 @@ webpack@^5.0.0-beta.30:
"@webassemblyjs/wasm-parser" "1.9.0"
acorn "^7.4.0"
chrome-trace-event "^1.0.2"
enhanced-resolve "5.0.0-beta.10"
enhanced-resolve "^5.0.0"
eslint-scope "^5.1.0"
events "^3.2.0"
glob-to-regexp "^0.4.1"
Expand All @@ -9682,10 +9687,10 @@ webpack@^5.0.0-beta.30:
neo-async "^2.6.2"
pkg-dir "^4.2.0"
schema-utils "^2.7.0"
tapable "^2.0.0-beta.11"
tapable "^2.0.0"
terser-webpack-plugin "^4.1.0"
watchpack "2.0.0-beta.15"
webpack-sources "2.0.0-beta.10"
watchpack "^2.0.0"
webpack-sources "^2.0.0"

[email protected]:
version "0.6.5"
Expand Down

0 comments on commit 12aa7f2

Please sign in to comment.