Share each individual lib import webpack config

The module sharing in Webpack works on a per import basis and therefore
doesn't trigger when the value in the config is @clusterio/lib while the
module imported is @clusterio/lib/config.  This in turn caused a copy of
lib to be bundled with each plugin.  Fix by making sure each lib import
is shared and specified in the configs.
This commit is contained in:
Hornwitser committed 2021-03-07 15:12:23 +01:00
1 parent fe9cef5e1e
commit b814d8a400
5 files changed
+16 -5

No files matched your search

+8 -1
View File
@@ -19,7 +19,14 @@ module.exports = (env = {}) => merge(common(env), {
new webpack.container.ModuleFederationPlugin({
name: "master",
shared: {
"@clusterio/lib": { singleton: true },
"@clusterio/lib/config": { singleton: true },
"@clusterio/lib/errors": { singleton: true },
"@clusterio/lib/helpers": { singleton: true },
"@clusterio/lib/link": { singleton: true },
"@clusterio/lib/logging": { singleton: true },
"@clusterio/lib/plugin": { singleton: true },
"@clusterio/lib/schema": { singleton: true },
"@clusterio/lib/users": { singleton: true },
"@clusterio/web_ui": { singleton: true },
"ajv": {},
"antd": { singleton: true },
+2 -1
View File
@@ -22,7 +22,8 @@ module.exports = (env = {}) => merge(common(env), {
"./package.json": "./package.json",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/lib/config": { import: false },
"@clusterio/lib/link": { import: false },
"@clusterio/web_ui": { import: false },
"ajv": { import: false },
},
+2 -1
View File
@@ -22,7 +22,8 @@ module.exports = (env = {}) => merge(common(env), {
"./package.json": "./package.json",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/lib/config": { import: false },
"@clusterio/lib/link": { import: false },
"@clusterio/web_ui": { import: false },
"ajv": { import: false },
},
@@ -22,7 +22,8 @@ module.exports = (env = {}) => merge(common(env), {
"./package.json": "./package.json",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/lib/config": { import: false },
"@clusterio/lib/link": { import: false },
"@clusterio/web_ui": { import: false },
"ajv": { import: false },
},
+2 -1
View File
@@ -22,7 +22,8 @@ module.exports = (env = {}) => merge(common(env), {
"./package.json": "./package.json",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/lib/config": { import: false },
"@clusterio/lib/link": { import: false },
"@clusterio/web_ui": { import: false },
"ajv": { import: false },
"antd": { import: false },