Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the module extension list in package.json #8123

Closed
srittau opened this issue Mar 13, 2019 · 5 comments
Closed

Extend the module extension list in package.json #8123

srittau opened this issue Mar 13, 2019 · 5 comments

Comments

@srittau
Copy link

srittau commented Mar 13, 2019

🚀 Feature Proposal

Unless I am overlooking something, it's currently only possible to override the module extension list in package.json, not extend it. The documentation actually gives an example how to extend it in jest.config.js.

Motivation

This came up in enzymejs/enzyme#2046. Replacing the default list is problematic, since it can break third-party package and the fix is not easily obvious. In this particular case, enzyme-react-adapter-16's update from version 1.10.0 to 1.11.0 added an import of a package.json file, without the file extension. This is reasonable, since .json is on node's default suffix list, but broke jest for many people.

While it is possible to extend the list in jest.config.js, using a declarative configuration in package.json is probably what most people prefer to do.

This potential problem should also be warned about in the description of the moduleFileExtensions option.

@jeysal
Copy link
Contributor

jeysal commented Mar 13, 2019

We're planning a config rework coming up soon. I personally think the exact thing you're proposing might not become part of it and there's always a limit do what you can do declaratively in a reasonably simple way, but it looks like we should definitely have better warnings in place, so thanks for bringing this up!

@SimenB
Copy link
Member

SimenB commented Mar 14, 2019

You can do import {defaults} from 'jest-config' if you use JS config, which is called out in the docs: https://jestjs.io/docs/en/configuration#defaults

I do think adding some docs calling out that replacing the extensions potentially can break integrations. Wanna send a PR to the docs?

Beyond that, as @jeysal mentions, we wanna rework our config (#7185). If anything, I think it makes sense to move towards more config in js and less in json since it's so inflexible. Adding a new option that just extends without replacing doesn't sound like something we want to do...

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

github-actions bot commented May 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants