-
Notifications
You must be signed in to change notification settings - Fork 6
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
Base setup for using react-uswds in the veda-ui #1029
Conversation
✅ Deploy Preview for veda-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
One thing that blocks me from merging this PR is how slow the dev server is. First, are you also experiencing the slow dev server problem @dzole0311 ? Would it be possibly related to warning from the transformer that @sandrahoang686 pointed out? |
I pushed a change that was on my local branch for 979, thus I did not notice the dev server being slow over here. The issue was this line, which imported the whole design I think the point above also means that we don't need to use purgeCSS anymore since we would import packages per component. Sorry for using your draft PR for this @hanbyul-here , but I rebased the new changes there and removed the purgeCSS and it results in a way smaller CSS.
Could we try to get rid of this warning via the new "Optimize USWDS css" issue, together with the uswds notifications while compiling? I tried changing the latter here, but it seems to have no effect. |
Ah, thank you so much for redirecting the configuration @dzole0311 ! (Now I also can see that the verbose warning comes from the instruction with how to turn it off 😓 ) - I misunderstood how uswds design system (or even just scss) works, in a way that we need a whole scss to make use of its full capacities. One last thing I am checking is if any change we are introducing is interrupting the library build ( I should just make it as a part of the build command). I can't seem to make the build work with the new version of Parcel. Sorry to keep dragging the pr, but this seems to be a big enough issue to be a blocker. I am looking at it, but lmk if you have a clue about it. This is the error message I get when I run
|
Hmm, yeah I ran the EDIT: There are only TS errors on |
I looked into the problem more today. I gradually increased the minor version of Parcel and its related dependencies to see when the bug was introduced. The problem appeared from Parcel 2.9.0, when Parcel rewrote its resolvers extensively.https://parceljs.org/blog/v2-9-0/ I dipped around many things, but eventually, Parcel doesn't compile aliases when the target is not a web app. I found a similar issue from the repo: parcel-bundler/parcel#9519 I am kind of blocked here now 🤔 Hopefully I will have more ideas tomorrow. |
Thanks for looking into it @hanbyul-here , I'm throwing some ideas below. One option we could try is to downgrade to Parcel v2.7 and try the A second alternative would be to downgrade to Parcel v2.7 and stop using postcss to fix the invalid CSS from USWDS, and to write a custom Parcel Transformer that patches the css using Parcel v2.7. Something like this: parcel-bundler/lightningcss#39 (comment). The downside is that I can't tell how many invalid selectors we have to fix. |
Thank you @dzole0311 for the suggestion! I think all your suggestions make a lot of sense. I was wondering if there is any way not to lock ourselves to Parcel 2.7, since 2.7 is quite old anyway at this point. Your comment made me think about using Parcel's Resolver API to resolve aliases. I made a PR: #1045 |
**Related Ticket:** (Not a ticket) #1029 ### Context To use the USWDS Design System, we had to update Parcel to 2.12. (Because of invalid CSS selectors that Parcel will complain about. @dzole0311 described the problem very well here: #1029 (comment)) While trying to build the library with Parcel 2.12, I faced the problem of Parcel failing to build the library with an error like `add '$components' as a dependency`. This error made me think that something related to aliases is not working for library build with the new version of Parcel. We are bumping quite a number for Parcel (from 2.7 to 2.12), so I gradually bumped up the minor version of Parcel and its related packages to see where this error was introduced. The problem appeared in Parcel 2.9.0 when Parcel rewrote its resolvers extensively.https://parceljs.org/blog/v2-9-0/ There seem to be other people who are facing alias-related problems with targeting Node: parcel-bundler/parcel#9519 **In short, Parcel 2.12 seems to have a problem building a library with aliases. (Or at least our set up doesn't seem to work for library build)** ### What this PR does Parcel offers the api for custom Resolver : https://parceljs.org/plugin-system/resolver/ From what I understand, I can make my own translation of dependency such as `import x from ...` through Resolver. Using this Resolver api, I added an alias-resolver, which basically just swaps the file name to its full name when the file name includes one of aliases. I also separated Parcel configuration that should be used for library build from the application build. So we can scope down the impact only to library build. Currently, the library build configuration extends the application configuration, and adds alias resolver on top of it. In addition to these changes, the library build command is included in the `stage` command. When the library build fails, the preview build will also fail. ### Things I wish I could figure out better #### Resolver chain? I want alias resolver to resolves only the alias, and leave the other stuffs (absolute path or module name resolution) to Parcel default resolver. For example, let's say a syntax like below was used ``` import Panel from '$components/Panel' ``` I want alias-resolver to translate this into ``` import Panel from '/app/scripts/components/Panel' ``` and leave it up to further translating this syntax into either ``` import Panel from '/app/scripts/components/Panel.tsx' ``` or ``` import Panel from '/app/scripts/components/Panel/index.tsx' ``` (There can be even more variety such as './app/scripts/components/Panel/index.jsx', './app/scripts/components/Panel/index.ts' ...) However, it seems like Resolver has to return the absolute path for the file or null to pass it to the next resolver (https://parceljs.org/plugin-system/resolver/#relevant-api). So I included a logic to tell if imported file is module or file in alias-resolver. #### Update other Parcel-related packages I tried, but I also faced bunch of other problems that I feel like I would need another day to figure out. So here, I only ditched parecel's experimental bundler, which seems to be included in the higher version by default. The context for experimental bundler is in this PR: #306 ### We need to check I only checked the library suceeds at being built. We need to check if the built assets from this branch are the same from the ones of main branch.
I found another problem when I tried to build the UI from ghg-config side. The build fails
I think it is the path problem, and should be fixable. I will update once I make more progress. |
0127d9b
to
6313135
Compare
I think now the build for library, instance, and UI dev environment should all work. phew 💦 I will give an approval, but please test for all the builds before the merge ! |
6313135
to
a6b1ff9
Compare
Tested the following: ✅ veda-ui: serving the app, building the app, building the lib, the uswds design system works as before |
## 🎉 Features * 🦗 ## 🚀 Improvements - Base setup for using react-uswds in the veda-ui #1029 - Consolidate utils/veda-data(-no-faux-module) methods into new dir and remove faux module dependencies for Library build #1030 - Upgrade to Parcel 2.12 and make library build work #1045 - Update E&A Date Picker to react-calendar with USWDS tokens #1048 ## 🐛 Fixes - Sort catalog items alphabetically in the E&A modal and the data catalog #1039
Related Ticket: #1043
Description of Changes
This is a base setup to start using react-uswds inside of the veda-ui
Example usage
To use the
Card
component fromreact-uswds
, we can simply import it and use it as is from react-uswds, with the default styles applied.Notes & Questions About Changes
{Add additonal notes and outstanding questions here related to changes in this pull request}
Validation / Testing
{Update with info on what can be manually validated in the Deploy Preview link for example "Validate style updates to selection modal do NOT affect cards"}