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

feat(gatsby-plugin-manifest): Update manifest on navigation #17426

Merged
merged 6 commits into from
Sep 26, 2019

Conversation

namukang
Copy link
Contributor

@namukang namukang commented Sep 5, 2019

Description

With the addition of the localize option in gatsby-plugin-manifest (#13471), multiple manifests can be generated and served depending on the path of the URL. While the correct manifest is served on initial page load, the link to the manifest is never updated even if the user navigates to a page that should include a different manifest.

This PR hooks into onRouteChange in gatsby-browser.js in order to update the manifest as necessary.

Related Issues

Fixes #17255

@namukang namukang requested a review from a team as a code owner September 5, 2019 19:29
@namukang
Copy link
Contributor Author

namukang commented Sep 5, 2019

Hm, not sure why the e2e test is failing since I use the asset prefix when setting the manifest: https://github.com/gatsbyjs/gatsby/pull/17426/files#diff-9d857a76b97041cf4aefbf1950cd3c9fR11

@lannonbr lannonbr changed the title Update manifest on navigation feat(gatsby-plugin-manifest): Update manifest on navigation Sep 7, 2019
@namukang
Copy link
Contributor Author

namukang commented Sep 8, 2019

Hoping I can also get some help regarding this ESLint warning I get when working on the plugin as a local plugin:

Module Warning (from ./node_modules/eslint-loader/index.js):

/Users/dskang/Code/dkthehuman.com/plugins/gatsby-plugin-manifest-multiple/gatsby-browser.js
  1:1  warning  'use strict' is unnecessary inside of modules  strict

Babel adds "use strict" to the top of every file and ESLint (I'm using Gatsby's default config) complains about it. Have you encountered this before when working on plugins as a local plugin?

Update: I filed a separate issue with a test repo to demonstrate the problem: #17489

@wardpeet
Copy link
Contributor

wardpeet commented Sep 24, 2019

I'm pretty confident that this is ready to be shipped.

  • fixed default localized manifest & sw support (gatsby-plugin-offline wasn't caching the correct file)
  • Only add gatsby-browser code when necessary

I think we can iterate on this if the startWith/regex doesn't suffice.

Maybe you have some final comments @moonmeister

wardpeet
wardpeet previously approved these changes Sep 24, 2019
@wardpeet
Copy link
Contributor

@moonmeister, yeah offline plugin has issues with it. I think it's good to just keep the default one manifest.webmanifest and only suffix the ones that are in the localized string.

Thanks for pointing out gatsby-ssr, I forgot about it and looks like I didn't have any issue because of rehydration XD.

The latest offline plugin doesn't prefetch manifest anymore when it's not found so the issue looks like it doesn't exist anymore. I'll bring that feature back as it's a regression.

I updated tests and I think, it's ready to go.

@moonmeister
Copy link
Contributor

What about caching the non-default manifests?

@wardpeet
Copy link
Contributor

They will be cached when navigating. I'll fix the regression of manifest prefetching on first load in gatsby-plugin-offline but it's not a problem of this PR

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Let's ship this. Thanks @dkthehuman & @moonmeister

@wardpeet wardpeet merged commit f88a9e2 into gatsbyjs:master Sep 26, 2019
@namukang namukang deleted the update-manifest-on-nav branch September 26, 2019 19:12
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.

[gatsby-plugin-manifest] Localized manifest not selected on navigation
3 participants