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

webpacker react -- prop-types, @babel/preset-react listed as dependencies? #1610

Closed
timhwang21 opened this issue Jul 12, 2018 · 4 comments
Closed

Comments

@timhwang21
Copy link
Contributor

timhwang21 commented Jul 12, 2018

Here.

I was wondering, is there something about Webpacker that means these are needed as dependencies? Or is this an oversight? Thanks!

@danielpowell4
Copy link

danielpowell4 commented Aug 14, 2018

I'm confident that these were included on purpose.

the babel preset is needed so that the jsx can be parsed during precompilation

prop-types is very standard, good practice, and enforced by most all react minded linters like eslint-plugin-react

@timhwang21
Copy link
Contributor Author

timhwang21 commented Aug 15, 2018

I know what they do, just wondering why they are dependencies and not devDependencies.

Also if you're using flow or Typescript you won't be using prop-types. Seems odd to enforce this as a dependency.

@danielpowell4
Copy link

Ah I misunderstood the question

I'm certainly not the authority, but think the idea was that they are both fairly safe, standard defaults.

In terms of babel, I believe that including the plugin as dependency vs devDependency was probably done so that precompilation runs in a Rails.env == 'production' environment without issue.

In terms of prop-types the bundle size reduction would be minimal. If you are adding in typescript, you are already changing these defaults so running yarn remove is a super easy change to make.

However, it seems like the thinking has evolved preference towards using it as a devDependency only and then using something like babel-plugin-transform-react-remove-prop-types to remove the import statements.

This thread is pretty straightforward discussion: facebook/create-react-app#209 which eventually leads to facebook/create-react-app#3818 and prop-types being stripped in production as a default in create-react-app

@guillaumebriday
Copy link
Member

Is this still an issue?

Closing for now but feel free to reopen if needed

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

No branches or pull requests

3 participants