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

It looks like rmanifest.json by React HashRouter is not parsed by this tool #1

Open
anton-karlovskiy opened this issue Jul 2, 2020 · 0 comments

Comments

@anton-karlovskiy
Copy link

anton-karlovskiy commented Jul 2, 2020

Hi @lukeed

Could you please have a look at this issue and give us advice? Thank you.

The other day, I integrated quicklink 2.0 with one React project. It was working very well.
They used BrowserRouter at first but turned to using HashRouter for some reason. For example, the reason for using HashRouter is https://stackoverflow.com/questions/27928372/react-router-urls-dont-work-when-refreshing-or-writing-manually/36623117#36623117

But after starting to use HashRouter, quicklink has stopped working. So I debugged this issue from Quicklink source.

hash-router

As you can see on the above screenshot, with HashRouter, the router link renders to an anchor tag with hash in its href attribute.
Looking at the implementation in Quicklink project.

entry pathname-code

The second argument of rmanifest method is entry.pathname, which does not return the hash href value of the link.
So I tried with entry.getAttribute("href") as the second argument of rmanifest method but this time it looked like rmanifest method does not understand the hash URI.

hash param at rmanifest

So I'm afraid quicklink 2.0 is not going with HashRouter.

I found a quick-fix solution to it without touching route-manifest logic for now but I'm not sure if this should be fixed within quicklink logic or that of route-manifest.

  1. Set up the React app's route manifest without # in webpack-route-manifest configuration so that we can get route URLs without # prefixed from the window.__rmanifest.
  • But I'm concerned that developers might come to add # by just referring to the URL from the address bar of the browser.

hack-route-setup

window __rmanifest

  1. Make some change to quicklink (removing # from the detected link's href) in order to match to the URLs from window.__rmanifest setup in step 1.

hack-quicklink

Then we could make quicklink work with HashRouter anyhow. But to be honest, it looks manual and hard-coded.

Could you please review and tell me if this should be fixed within quicklink or route-manifest?
Thank you.

cc @addyosmani @demianrenzulli

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

1 participant