Set context manually in NormalModuleReplacementPlugin to fix relative import paths

johannes/nuke-worker-loader
Johannes Marbach 2023-09-29 22:02:38 +02:00
parent c844d80217
commit 9b8d6e7607
2 changed files with 12 additions and 3 deletions

View File

@ -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}
</div>
</div>
<AuthFooter />
<VectorAuthFooter />
</div>
);
}

View File

@ -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);
}
);
});
}