At the moment the defaults for the extensions option are inconsistent.
If resolver is not set in @compiled/webpack-loader or @compiled/parcel-transformer, then extensions will be passed to the default resolver, enhanced-resolver.
This is also passed to @compiled/babel-plugin under the hood.
This can be a slight problem when extensions is not defined, and thus extensions falls back to its default value.
enhanced-resolver uses ['js', 'json', 'node'] as its default value, while @compiled/babel-plugin uses ['.js', '.jsx', '.ts', '.tsx'] as its default value.
This inconsistency is probably not intended and might catch people out.
We should perhaps use the same defaults for both enhanced-resolve and @compiled/babel-plugin - in other words, if extensions is not defined by the user, we should pass['.js', '.jsx', '.ts', '.tsx']to bothenhanced-resolveand@compiled/babel-plugin`.
In addition, we should update the website documentation for these three packages once we fix this.
Discovered while working on https://github.com/atlassian-labs/compiled/pull/1689
At the moment the defaults for the
extensions
option are inconsistent.resolver
is not set in@compiled/webpack-loader
or@compiled/parcel-transformer
, thenextensions
will be passed to the default resolver,enhanced-resolver
.@compiled/babel-plugin
under the hood.This can be a slight problem when
extensions
is not defined, and thusextensions
falls back to its default value.enhanced-resolver
uses['js', 'json', 'node']
as its default value, while@compiled/babel-plugin
uses['.js', '.jsx', '.ts', '.tsx']
as its default value.This inconsistency is probably not intended and might catch people out.
We should perhaps use the same defaults for both
enhanced-resolve
and@compiled/babel-plugin
- in other words, ifextensions
is not defined by the user, we should pass
['.js', '.jsx', '.ts', '.tsx']to both
enhanced-resolveand
@compiled/babel-plugin`.In addition, we should update the website documentation for these three packages once we fix this.