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

Upgrade @svgr/webpack to 4.1.0 #5816

Merged
merged 6 commits into from
Jan 12, 2019
Merged

Upgrade @svgr/webpack to 4.1.0 #5816

merged 6 commits into from
Jan 12, 2019

Conversation

alaycock
Copy link
Contributor

@alaycock alaycock commented Nov 15, 2018

I ran into an issue when upgrading to create-react-app 2 because @svgr/core@2.4.1 (a dependency of @svgr/webpack) had prettier as a dependency, which led to two different version of prettier being installed, which ended up causing linting issues when the two different versions of prettier ran (through yarn eslint vs yarn prettier). More details of my issue can be found here: prettier/eslint-plugin-prettier#110

As of @svgr/core@4.0.0, prettier and svgo are no longer dependencies, and using it will prevent them from being installed, which would hopefully prevent prettier version conflicts in the future.

Neither prettier and svgo were being used in create-react-app anyway, so having them removed just removes a bit of node_modules bloat without cutting functionality.

To test, run create react app, and try out importing a SVG as a component with import { ReactComponent as Logo } from "./logo.svg";, and it should continue to work.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@iansu
Copy link
Contributor

iansu commented Nov 15, 2018

This was on my todo list so thanks for taking care if it!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@alaycock
Copy link
Contributor Author

I fixed the failing tests on Travis, but not sure why appveyor is failing, looks like it's timing out. I added the babel packages to resolve the failing tests, but if there's a more appropriate way to add to the project, I'm all ears.

@iansu
Copy link
Contributor

iansu commented Nov 16, 2018

Appveyor had been broken for a while so don't worry about that.

I'm more concerned about the fact that we have to add all of these babel dependencies. It's also weird that they seem to only be required in ejected projects. @neoziro do you have any idea why this might be?

@gregberge
Copy link

@iansu I don’t know why they are required, probably babel sub dependencies. But I think it is lighter than before.

@gregberge
Copy link

(SVGO is included in @svgr/webpack and I think it should be part of cra). It could reduce the bundle size.

@gregberge
Copy link

In your PR, for now it is included.

@alaycock
Copy link
Contributor Author

That looks like a mistake on my part, I misunderstood how svgo was being included. Currently it appears to be intentionally left out, do you have a reason for excluding it @iansu?

I updated the PR to remove prettier and svgo to feature-match with the existing implementation.

Also trying to see if I can get away without a couple extra dependencies, since CI seems to be acting differently than my machine.

@alaycock
Copy link
Contributor Author

alaycock commented Nov 19, 2018

Looks like SVGO was disabled intentionally., so I will leave it disabled unless there is a good reason to change it.

Removing prettier and SVGO seems to have required another dependency for the kitchensink-eject tests to pass. Still not sure why that is the case or how to resolve that, so any additional help would be appreciated.

@alaycock
Copy link
Contributor Author

alaycock commented Nov 24, 2018

I think I should be good to go now. My issue seems to have been resolved by merging in master which brought in "@babel/preset-env": "7.1.6", which seems to have resolved the conflict between versions being used by @svgr/webpack and this project.

@gregberge
Copy link

@alaycock OK good, please let me fix this one and release before fixing the version.

@alaycock
Copy link
Contributor Author

@neoziro I don't think that's necessary after all. Updating the version of preset-env seems to have resolved my problem. Thanks for being accommodating though.

@gregberge
Copy link

I think it is, the way plugin are imported could create conflict. If the user install babel + create-react-app or if he ejects. I prefer to have it fixed. The fix will be published in 5 minutes.

@gregberge
Copy link

@alaycock I think making config static and using createConfigItem could improve perf too! https://github.com/smooth-code/svgr/pull/240/files

@gregberge
Copy link

@alaycock published as v4.0.4

@alaycock alaycock changed the title Upgrade @svgr/webpack to 4.0.3 Upgrade @svgr/webpack to 4.0.4 Nov 24, 2018
@iansu
Copy link
Contributor

iansu commented Nov 24, 2018

I think we can remove -prettier from the webpack loader strings since it's no longer included. At least that's my understanding. We still want to leave SVGO out. Also there are some new tests in babel-plugin-named-asset-import that you'll have to update.

@alaycock
Copy link
Contributor Author

You're right @iansu, I made that change. It looks like svgo could be disabled with -svgo, or by preventing it from loading it as a plugin with plugins[]='@svgr/plugin-jsx'. The docs don't indicate anything about enabling/disabling plugins, so I went with -svgo because that's what was used previously. Not sure what the preferred method would be though. The performance impact of loading the plugin, but not using it, is probably insignificant.

@gregberge
Copy link

@alaycock I think -svgo is fine, avoid the loading of the plugin is not significant in term of perf. It is easier to stick with ˋ-svgo` and probably more future proof.

I published a v4.1.0, the only change that impacts you is an upgrade of unified / rehype. It is marked as minor because of the new parcel plugin.

@alaycock alaycock changed the title Upgrade @svgr/webpack to 4.0.4 Upgrade @svgr/webpack to 4.1.0 Nov 25, 2018
@kopax
Copy link

kopax commented Nov 29, 2018

Hi, any update on this? I am experiencing an issue with the old version of @svgr/webpack, does anybody have a temporary workaround to offer? Thanks.

@alaycock
Copy link
Contributor Author

@kopax I think this is good to go unless there's any more feedback.

@kopax
Copy link

kopax commented Nov 29, 2018

Ok. Maybe they should merge this and release a new CRA version for testing. Do you know how I can test this easely? Maybe we can replace react-script by a fork dist version on npm?

@stale
Copy link

stale bot commented Dec 30, 2018

This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 30, 2018
@alaycock
Copy link
Contributor Author

@iansu, is there anything I should be doing to get this ready to merge? It sounds like some other PRs are waiting on this one.

@stale stale bot removed the stale label Dec 30, 2018
@Timer Timer added this to the 2.1.4 milestone Jan 10, 2019
@iansu iansu closed this Jan 10, 2019
@iansu iansu reopened this Jan 10, 2019
@iansu
Copy link
Contributor

iansu commented Jan 10, 2019

These build failures seem unrelated. We're currently trying to fix them: #6165. Once that's done we should be good to merge this.

@ianschmitz
Copy link
Contributor

#6165 is in and we're all green. Let's do this!

@Timer Timer closed this Jan 11, 2019
@Timer Timer reopened this Jan 11, 2019
@iansu iansu merged commit 8174eed into facebook:master Jan 12, 2019
@iansu
Copy link
Contributor

iansu commented Jan 12, 2019

Thanks!

@lock lock bot locked and limited conversation to collaborators Jan 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants