-
Notifications
You must be signed in to change notification settings - Fork 152
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
Parcel frontend starts from html instead of Vue #1889
base: master
Are you sure you want to change the base?
Conversation
Hi, I was afraid that something like this could happen. Sadly, Parcel is quite buggy in terms of multi-page builds, and I had to jump through a lot of hoops to get it working last year. I thought that reusing the same component in multiple top-level pages should work, but maybe it doesn't. I have a vacation this week, so I won't be able to look at this until ~next week, or maybe even a bit later. Maybe we will be forced eventually to move to a different build system, I have evaluated a few last year, including vite, but sadly most of them are prepared for SPAs, but not very well for the setup that we use for rustc-perf (where we have N top-level pages built separately). Maybe just writing a few-line manual webpack config would be the easiest way to resolve this.. I don't know :) |
@Kobzol No hurry. Have a nice vacation :) |
(Concrete suggestion for parcel-bundler/parcel#6310 (comment)) AFAICT, you don't actually use any dynamic SSR templating, so running Parcel on the templates (together with some posthtml plugin like https://github.com/posthtml/posthtml-extend) should be possible and resolve that error because now the shared CSS bundles can be handled (= included in the HTML) just fine. |
I have tried this before and ran into some issues that I sadly don't remember anymore. I guess that we can try again. |
@mischnic Thanks for the concrete suggestion. I will try it and wish us all the best 🥹. @Kobzol If we change the entry point to Update 1: I think is here |
Yeah, that file basically embeds the HTML templates from disk into the |
graphs
page61aeb07
to
bfe4ee4
Compare
It worked at my local, feel free to try it. What I have done
Q/AQ: Why I move all <div>> <a href="graphs.html">graphs</a>, <a href="compare.html">compare</a>,
<a href="dashboard.html">dashboard</a>, <a href="bootstrap.html">bootstrap</a>,
<a href="status.html">status</a>, <a href="help.html">help</a>.
</div> If we put other templates in the What I am concernedBecause we change the path to import frontend, I believe some code need cleaning up. E.g. // Maybe to clean up I am not sure
#[derive(RustEmbed)]
#[folder = "frontend/dist"]
#[include = "*.js"]
#[include = "*.br"]
#[include = "*.css"]
struct StaticCompiledAssets; Therefore, It takes extra time to clarify when scenarios e.g. (This PR is a breaking change, so scaring...) Update 1: Unit test does not pass CI. It seems that I need to create a mock Update 2: I installed Node.js and built the frontend in the CI pipeline for unit testing. I hope it is allowed. |
72eec35
to
332c8ac
Compare
Thanks for looking into this! I'm a bit busy at the moment, I will try to take a look during the next week, but it's possible that I'll only have time after https://2024.rustnl.org/. |
Hi, sorry for the delay. I think that I start remembering now what were the issues with this approach 😆 It makes go Parcel go crazy. If you check out e.g. the I tried to remove all the toplevel HTML files and keep just one (graphs), but even then it behaves in a weird way, and creates two copies of the ~same JavaScript file: I suppose that this is somehow code splitting happening in practice. I tried to disable code splitting with: "@parcel/bundler-default": {
"minBundles": 999,
"minBundleSize": 9999999,
"maxParallelRequests": 20
}, and it seems to help. With this, there are still two files per page, but it's just a module/nomodule split, and the JS files seem to contain all the requires JavaScript for that page. We could introduce some manual bundles (e.g. for Vue), but for now I'd like to keep all JS per page in a single file, if possible. But sadly, the same thing happens for CSS. When I shared CSS of a component across multiple pages, the graphs page imports a Now, it's possible that this would work better if our HTML pages were actually built using Parcel. Now they are just copied to So, yeah, this kind-of works, but the multiple weird named JS/CSS files are what put me off last time I tried this. Do you want to try to experiment with the PostHTML plugin? |
@Kobzol
I assume you were talking about this, 2024-06-15_21-41-37.mp4I believe the issue comes from both When Parcel bundles CSS, it encounters If I understand correctly, for I am very willing to try But what about multiple JS chunk files? you mean that you find it acceptable even though you don't like it 🤣? |
Yeah, Parcel is combining all shared JavaScript into multiple bundles, I'd like to avoid that, if possible. It looks like the configuration with
Yes, exactly :) |
@Kobzol To sum up, I'm beginning to doubt whether this is the right thing to do. |
I actually added tera relatively recently, and I don't think that we use it for actually passing any data from the backend to the frontend. The only reason I used it was to share some common layout code (e.g. the top menu and the footer) between all HTML pages. Sharing of this can easily be done also with frontend templates, so from this point of view it should be fine and we could even get rid of Tera in that case, I suppose. So if using Parcel HTML layout templates allows us using Vue components across pages, and doesn't produce these weird JS/CSS artifact issues, then I would be fine with it. |
So that we do not need to bundle `layout.html` using parcel ref: * https://parceljs.org/languages/html/#posthtml
@Kobzol I rewrote templates with |
Thank you. I'm currently still finishing my PhD thesis and I don't want to get into the weeds of more complicated stuff at the moment. I will try to take a proper look at this again in (mid-)August. |
Sorry, my PhD took longer to finish than I thought 😬 So, I took another look at this, and I tried to use the If you still want to work on it, could you try to check if you can now use the tab component on the graphs page without issues? |
To clarify, I tried it on |
@Kobzol I wish you are all good with you PhD degree. My master just starts, so I am a little busy now, but I definitely will check it out. |
@Kobzol After my check, they seem really to have resolved the issue. I will slowly address what needs to be done next. |
Hi,
I currently facing a crazy error. When I ran
npm run watch
with commit61aeb07
, I got the error.@parcel/namer-default: Bundle group cannot have more than one entry bundle of the same type
It seems that the root cause is because the shared
site/frontend/src/components/tab.vue
is imported into two places. Has anyone faced any similar issue before? (Interestingly,as-of.vue
worked fine).The discussion I found was here and people suggested to move
parcel
tovite
😅References