Skip to content

Commit

Permalink
refactor(dev-scripts): Simplify resolve.extensions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cpcallen committed Feb 29, 2024
1 parent 2ab1194 commit 27c9873
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugins/dev-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 27c9873

Please sign in to comment.