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

Install us-form-system peerDependencies as devDependencies #4

Merged
merged 3 commits into from
Jun 19, 2018

Conversation

annekainicUSDS
Copy link
Contributor

This PR does 2 things:

  1. Update version of us-forms-system
  2. Install us-forms-system's peerDependencies as devDependencies here.

Copy link
Contributor

@dmethvin-gov dmethvin-gov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with the react and formation reps moved to dependencies, and without the uswds dependency, and it seemed to build/run fine. here.

package.json Outdated
@@ -15,20 +15,23 @@
"license": "ISC",
"homepage": "",
"devDependencies": {
"@department-of-veterans-affairs/formation": "^0.8.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a dependency? It's referenced in

import ProgressButton from '@department-of-veterans-affairs/formation/ProgressButton';
so it's needed at runtime, thus a dependency and not devDependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmethvin-gov I think react can remain a devDependency? In vets-website we install it as a devDependency, as does create-react-app. I believe this is because we're using webpack to create a static bundle as part of the build step, but I'm not 100% positive. Still trying to understand this better.

package.json Outdated
"babel-cli": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.11",
"react": "^15.6.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with these two, I think they're dependencies.

"style-loader": "^0.21.0",
"svg-url-loader": "^2.3.2",
"url-loader": "^1.0.1",
"uswds": "^1.6.6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see uswds referenced at all in the starter app so I don't think it needs to be here. It gets pulled in indirectly via us-form-system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I'm not able to run the app without having uswds installed locally; styles.css from us-forms-system references images that come from the node module for uswds. If I run npm start locally on this app I get errors. I already have a separate ticket to look into the best way to import uswds images (usds/us-forms-system#66), but for now I think we still need to install uswds as a devDependency. If you have suggestions for the images problem please feel free to comment in that other ticket!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing any image errors when I pull the current HEAD, remove node_modules, move the two react dependencies, npm install, and npm start. I do see that it's unable to find the fonts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to pull this branch in order to see the issue, not HEAD.

@dmethvin-gov
Copy link
Contributor

OK, gotcha. Let me look at that, the app definitely shouldn't be the middleman here but I'm not sure how to avoid it at the moment. I'll comment over on that ticket.

@annekainicUSDS
Copy link
Contributor Author

@dmethvin-gov do you mind taking another look at this? I reinstalled uswds because for me I was getting build errors without it when I tried to run npm start (see commit b36f85d here). I also added a comment in regards to react being a devDependency or not; I'm still a little confused on this myself so happy to have a discussion about that!

@dmethvin-gov
Copy link
Contributor

When I pull this in and rebuild I don't get any errors, which is good. The USWDS dependency still seems strange to me.

The way I've always understood dependencies is that if a project needs something, directly, at runtime (for example React) then it should be in dependencies. If it's only needed during project build (for example Babel) it should be in devDependencies. If you're writing something that could be considered a "plugin" for another package, where you assume the parent (including) app will pull in the package, then it's peerDependencies.

So if USWDS is a peer dependency in us-forms-system it would seem like we should use uswds directly in the app itself. Perhaps the starter is a degenerative case since we're using the forms library in a skeletal form. Or maybe it's a sign we need to refactor some of these parts; in a real app it's likely that the developer would want to modify the default USWDS styles which means they'd either need to have a modified USWDS package or they would need to override the USWDS styles and fonts in some additional CSS.

In any case let's land this for now and I'll continue to get to know how this works.

@annekainicUSDS
Copy link
Contributor Author

@dmethvin-gov I think you're totally right. Ideally, we wouldn't need USWDS installed if we're not calling it directly from within this app. I think it has to do with how I've imported the css and images, which I know we have separate tickets for to refactor. So I will merge this now and hopefully we will improve this through the other tickets.

@annekainicUSDS annekainicUSDS merged commit f295722 into master Jun 19, 2018
@annekainicUSDS annekainicUSDS deleted the update-version-of-us-forms-system-2 branch June 19, 2018 17:39
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 this pull request may close these issues.

3 participants