Skip to content

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

@dddlr

Description

@dddlr

Discovered while working on #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions