From 27c9873cb8c456687b1c78153d30f2df4e35e2ae Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Wed, 28 Feb 2024 17:53:16 +0000 Subject: [PATCH] refactor(dev-scripts): Simplify resolve.extensions There doesn't appear to be any reason not to include the '.ts' in resolve.extensions even for pure-JS plugins, but it is _necessary_ to include it in TS plugins. Since the default value for resolve.extensions is ['.js', '.json', '.wasm'] set it to ['.ts', '.js', '.json', '.wasm'] which gives priority to TS, then JS, then the other default extensions. Also add a helpful comment explaining the purpose of resolve.fallback. --- plugins/dev-scripts/config/webpack.config.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/dev-scripts/config/webpack.config.js b/plugins/dev-scripts/config/webpack.config.js index c340cbecac..9b11aba46e 100644 --- a/plugins/dev-scripts/config/webpack.config.js +++ b/plugins/dev-scripts/config/webpack.config.js @@ -93,9 +93,10 @@ module.exports = (env) => { clean: true, }, resolve: { - extensions: ['.ts', '.js'].filter( - (ext) => isTypescript || !ext.includes('ts'), - ), + extensions: ['.ts', '.js', '.json', '.wasm'], + // Some deps may require node.js core modules. Tell node.js what + // polyfills to use for them when building for non-node.js targets + // (Or to ignore them if the fallback is false.) fallback: { util: false, },