gatsby: [gatsby-transformer-javascript-frontmatter] Frontmatter export breaks HMR

Preliminary Checks

Description

Hot module reload (HMR) doesn’t work, using gatsby-transformer-javascript-frontmatter plugin when javascript or typescript files export frontmatter.

This issue has been around since at least Gatsby 3, and continues in Gatsby 4.

Reproduction Link

https://github.com/yallllc/repro-js-frontmatter-hmr

Steps to Reproduce

  1. Install gatsby-transformer-javascript-frontmatter plugin
  2. Export frontmatter from a page
  3. Make a visual change – style or a jsx – and see if the page updates on save

Expected Result

Page updates

Actual Result

Page doesn’t update.

If the frontmatter export is commented out, HMR will start working again.

Environment

System:
    OS: Linux 5.4 Ubuntu 22.04 LTS 22.04 (Jammy Jellyfish)
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  npmPackages:
    gatsby: ^4.15.0 => 4.15.1 
    gatsby-transformer-javascript-frontmatter: ^4.15.0 => 4.15.0

Config Flags

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 24 (5 by maintainers)

Most upvoted comments

It’s a limitation of Fast Refresh, you can also learn more here: https://github.com/facebook/react/issues/16604#issuecomment-528663101

I’m out this week, I can look at it more next week.

Hi @EyaChebbi sorry for the long delay. I actually will have some time I can put into this at the start of April.