From 9b8d6e760752cb752d2c3a1371b4d11bceee2e16 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 29 Sep 2023 22:02:38 +0200 Subject: [PATCH] Set context manually in NormalModuleReplacementPlugin to fix relative import paths --- src/components/views/auth/VectorAuthPage.tsx | 5 +++-- webpack.config.js | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/views/auth/VectorAuthPage.tsx b/src/components/views/auth/VectorAuthPage.tsx index 00c91d6af9..e04dfcefd7 100644 --- a/src/components/views/auth/VectorAuthPage.tsx +++ b/src/components/views/auth/VectorAuthPage.tsx @@ -16,7 +16,8 @@ limitations under the License. import * as React from "react"; import SdkConfig from "matrix-react-sdk/src/SdkConfig"; -import AuthFooter from "matrix-react-sdk/src/components/views/auth/AuthFooter"; + +import VectorAuthFooter from "./VectorAuthFooter"; export default class VectorAuthPage extends React.PureComponent { private static welcomeBackgroundUrl?: string; @@ -76,7 +77,7 @@ export default class VectorAuthPage extends React.PureComponent { {this.props.children} - + ); } diff --git a/webpack.config.js b/webpack.config.js index 6971540013..d906dc869d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -80,7 +80,15 @@ function parseOverridesToReplacements(overrides) { // because the input is effectively defined by the person running the build, we don't // need to do anything special to protect against regex overrunning, etc. new RegExp(oldPath.replace(/\//g, "[\\/\\\\]").replace(/\./g, "\\.")), - path.resolve(__dirname, newPath), + function (resource) { + resource.request = path.resolve(__dirname, newPath); + resource.createData.resource = path.resolve(__dirname, newPath); + // Starting with Webpack 5 we also need to set the context as otherwise replacing + // files in e.g. matrix-react-sdk with files from element-web will try to resolve + // them within matrix-react-sdk (https://github.com/webpack/webpack/issues/17716) + resource.context = path.dirname(resource.request) + resource.createData.context = path.dirname(resource.createData.resource); + } ); }); }