Skip to content

Commit 922ed59

Browse files
committed
Fix webpack to babel js-sdk & react-sdk but no other deps
This was happening implicitly in our dev setups and the CI build because of the comment on the last line.
1 parent 119802d commit 922ed59

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

webpack.config.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,23 @@ module.exports = (env, argv) => {
109109
rules: [
110110
{
111111
test: /\.(ts|js)x?$/,
112-
exclude: /node_modules/,
112+
include: (f) => {
113+
// we use the original source files of react-sdk and js-sdk, so we need to
114+
// run them through babel.
115+
if (f.startsWith(path.resolve(__dirname, 'node_modules', 'matrix-js-sdk'))) return true;
116+
if (f.startsWith(path.resolve(__dirname, 'node_modules', 'matrix-react-sdk'))) return true;
117+
// but we can't run all of our dependencies through babel (many of them still
118+
// use module.exports which breaks if babel injects an 'include' for its
119+
// polyfills: probably fixable but babeling all our dependencies is probably
120+
// not necessary anyway).
121+
if (f.startsWith(path.resolve(__dirname, 'node_modules'))) return false;
122+
// anything else gets babeled (our own source files, and also modules that
123+
// are yarn linked from somewhere else because this tests the absolute,
124+
// resolved path, so react-sdk and js-sdk fall under this case in a standard
125+
// dev setup. This will presumably start running any other module through
126+
// babel if yarn linked... caveat emptor.
127+
return true;
128+
},
113129
loader: 'babel-loader',
114130
options: {
115131
cacheDirectory: true

0 commit comments

Comments
 (0)