Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Consider defaulting jsc target to the current Node version's supported level #74

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Generators and async/await have been fully supported in Node for years, but the default SWC options are still set to transpile them to using regenerator-runtime. Since @swc/jest is specifically for usage in Jest, if there isn't a jsc.target specified in .swcrc or the Jest config, can it default to whatever level is supported by the runtime Node version?

Reasoning: it's a little extra work for projects that don't yet have a SWC configuration to specify a jsc target. https://swc.rs/docs/usage/jest indicates your Jest configuration only needs to include:

module.exports = {
  transform: {
    "^.+\\.(t|j)sx?$": ["@swc/jest"],
  },
};

...but in actuality, if this is your first swc setup, you need something more like:

module.exports = {
    transform: {
        "^.+\\.(t|j)s$": [
            "@swc/jest",
            {
                jsc: {
                    target: "es2021",
                },
            },
        ],
    },
};

...which is a pain point for new SWC users and a bit of noisy configuration.

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