atlassian-labs / compiled

A familiar and performant compile time CSS-in-JS library for React.
https://compiledcssinjs.com
Apache License 2.0
1.98k stars 68 forks source link

Apply single default for `extensions` across `@compiled/babel-plugin`, `@compiled/webpack-loader` and `@compiled/parcel-transformer` #1692

Open dddlr opened 1 month ago

dddlr commented 1 month ago

Discovered while working on https://github.com/atlassian-labs/compiled/pull/1689

At the moment the defaults for the extensions option are inconsistent.

  1. If resolver is not set in @compiled/webpack-loader or @compiled/parcel-transformer, then extensions will be passed to the default resolver, enhanced-resolver.
  2. 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.