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

Export defaults from node-resolve plugin #299

Closed
KubaJastrz opened this issue Apr 9, 2020 · 4 comments · Fixed by #301
Closed

Export defaults from node-resolve plugin #299

KubaJastrz opened this issue Apr 9, 2020 · 4 comments · Fixed by #301

Comments

@KubaJastrz
Copy link

  • Rollup Plugin Name: node-resolve
  • Rollup Plugin Version: 7.1.1

Feature Use Case

I want to be able to add .ts and .tsx extensions when using TypeScript but I have to manually repeat default values which adds up unnecessary manual work. If the defaults were exported, I could reuse them easily.

This would function similarly to const { defaults } = require('jest-config').

I can create a PR if you want.

Feature Proposal

Add export keyword to

const defaults = {

@shellscape
Copy link
Collaborator

Thanks for the issue. Please expand on your use case further, I don't quite understand what you're trying to do. More code would definitely help.

@KubaJastrz
Copy link
Author

KubaJastrz commented Apr 10, 2020

Sorry if I wasn't clear enough. For node-resolve plugin to see TypeScript files, it needs to be configured to allow .ts and .tsx extensions. If I just set extensions: ['.ts', '.tsx'] it obviously won't work because it will override default extensions.

I could copy and paste defaults and add my custom extensions but I feel like this could be improved if those defaults were exported for me to reuse them.

You can see the example here: https://github.com/kentcdodds/kcd-scripts/pull/131/files#diff-a1cfe028f2f056e2d30db017481d4ad0R146-R150

@shellscape
Copy link
Collaborator

Thanks for explaining the use case further. Would it be more useful to expose defaults, or do a deep merge on the defaults and options?

@KubaJastrz
Copy link
Author

KubaJastrz commented Apr 10, 2020

I think that exposing defaults is simpler in terms of implementation and gives more control to the user.
Edit: It would also mean no breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants