Giter Club home page Giter Club logo

Comments (3)

ArnaudBarre avatar ArnaudBarre commented on June 16, 2024 1

I though about it during the implementation but this is very complex to handle if the objet contains reference to other variables. In the case of constant object like this, this should be possible, I will see what I can do (I need to work on upcoming Vite 4.4, so in a few weeks)

from eslint-plugin-react-refresh.

ArnaudBarre avatar ArnaudBarre commented on June 16, 2024

So I took a look at this and actually this would be very difficult to do because to be safe the object needs to never be updated from inside the module like this:

export const documentProps = {
  // This title and description will override the defaults
  title: 'About SpaceX',
  description: 'Our mission is to explore the galaxy.'
}

documentProps.title = "About NASA"

In that case the importers will still get the reference to the old export which will not received the modifications.

While this is feasible with static analysis, it's complex and this will need to also be done when transforming the React components. The second part is too independant of the plugin and complex if using SWC, so for now I'm on the side of making this pattern incompatible with FastRefresh.

If you have only two properties to export, is it feasible to have two string export? Is this documentProps coming from a framework?

Other idea that can be explored:

  • naming conventions: making exceptions for ALL_UPPERCASES object exports or adding a suffix to the object name
  • using an custom prop as a marker like __refreshStable: true to opt-in into a potential stale export

from eslint-plugin-react-refresh.

schaschko avatar schaschko commented on June 16, 2024

I use it for e.g. exporting meta data per page. In this case it would be feasible, and also possible to refactor the "problem" away.

Regarding the other ideas: if you think about tackling the issue, my feeling would be that it should work "natively".

Thanks for looking into it.

from eslint-plugin-react-refresh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.