Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-50818 Fix module loading issues caused by shared modules #1826

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,17 @@ if (TARGET_IS_PRODUCT) {
const sharedObject = {};

for (const packageName of packageNames) {
// Set both versions to false so that the version of this module provided by the web app will be used
sharedObject[packageName] = {
requiredVersion: false,

// Ensure only one copy of this package is ever loaded
singleton: true,

// Set this to false to prevent Webpack from packaging any "fallback" version of this package so that
// only the version provided by the web app will be used
import: false,

// Set these to false so that any version provided by the web app will be accepted
requiredVersion: false,
version: false,
};
}
Expand All @@ -141,8 +148,8 @@ if (TARGET_IS_PRODUCT) {
},
shared: [
'@mattermost/client',
'@types/luxon',
'@types/react-bootstrap',

'luxon',

makeSingletonSharedModules([
'react',
Expand All @@ -163,17 +170,6 @@ if (TARGET_IS_PRODUCT) {
path: path.join(__dirname, '/dist'),
chunkFilename: '[name].[contenthash].js',
};
config.externals = {
react: 'React',
'react-dom': 'ReactDOM',
redux: 'Redux',
luxon: 'Luxon',
'react-redux': 'ReactRedux',
'prop-types': 'PropTypes',
'react-bootstrap': 'ReactBootstrap',
'react-router-dom': 'ReactRouterDom',
'react-intl': 'ReactIntl',
};
} else {
config.resolve.alias['react-intl'] = path.resolve(__dirname, '../../webapp/node_modules/react-intl/');

Expand Down