Skip to content

Commit 4c699d8

Browse files
authored
Merge pull request element-hq#11944 from vector-im/dbkr/fix_build_webpack
Fix webpack to babel js-sdk & react-sdk but no other deps
2 parents 119802d + 922ed59 commit 4c699d8

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)