From 932c221548003b5e4dceee5d5ace6b27b549a0ae Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 20 Jan 2020 18:09:48 -0700 Subject: [PATCH] Fix webpack config (by stealing Dave's config) Without doing something like this it's hard to use `yarn link`ed resources. --- webpack.config.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 95087f7df6..ae92e8154f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,6 +21,12 @@ module.exports = (env, argv) => { development['devtool'] = 'eval-source-map'; } + // Resolve the directories for the react-sdk and js-sdk for later use. We resolve these early so we + // don't have to call them over and over. We also resolve to the package.json instead of the src + // directory so we don't have to rely on a index.js or similar file existing. + const reactSdkSrcDir = path.resolve(path.join(require.resolve("matrix-react-sdk/package.json"), '..', 'src')); + const jsSdkSrcDir = path.resolve(path.join(require.resolve("matrix-js-sdk/package.json"), '..', 'src')); + return { ...development, @@ -117,8 +123,8 @@ module.exports = (env, argv) => { // run them through babel. Because the path tested is the resolved, absolute // path, these could be anywhere thanks to yarn link. We must also not // include node modules inside these modules, so we add 'src'. - if (f.includes(path.join('matrix-js-sdk', 'src'))) return true; - if (f.includes(path.join('matrix-react-sdk', 'src'))) return true; + if (f.startsWith(reactSdkSrcDir)) return true; + if (f.startsWith(jsSdkSrcDir)) return true; // but we can't run all of our dependencies through babel (many of them still // use module.exports which breaks if babel injects an 'include' for its