diff --git a/services/web/babel.config.json b/services/web/babel.config.json index 912c13b8ad..3bb0eaf44e 100644 --- a/services/web/babel.config.json +++ b/services/web/babel.config.json @@ -11,5 +11,12 @@ ["@babel/react", { "runtime": "automatic" }], "@babel/typescript" ], - "plugins": ["angularjs-annotate", "macros"] + "plugins": ["angularjs-annotate", "macros"], + "overrides": [ + // treat .cjs files (e.g. libraries symlinked into node_modules) as commonjs + { + "test": "../../**/*.cjs", + "sourceType": "script" + } + ] } diff --git a/services/web/webpack.config.js b/services/web/webpack.config.js index 726dccad6a..de1ef2a3b0 100644 --- a/services/web/webpack.config.js +++ b/services/web/webpack.config.js @@ -91,10 +91,11 @@ module.exports = { module: { rules: [ { - // Pass application JS/TS files through babel-loader, compiling to ES5 - test: /\.[jt]sx?$/, - // Only compile application files (npm and vendored dependencies are in - // ES5 already) + // Pass application JS/TS files through babel-loader, + // transpiling to targets defined in browserslist + test: /\.([jt]sx?|[cm]js)$/, + // Only compile application files and specific dependencies + // (other npm and vendored dependencies must be in ES5 already) exclude: [/node_modules\/(?!(react-dnd|chart\.js)\/)/, vendorDir], use: [ {