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

react-refresh: add options to override $RefreshReg$ and $RefreshSig$ for better System.js integration #17237

Closed
vasiliicuhar opened this issue Oct 31, 2019 · 1 comment · Fixed by #17340

Comments

@vasiliicuhar
Copy link
Contributor

vasiliicuhar commented Oct 31, 2019

Do you want to request a feature or report a bug?
Feature

Right now babel plugin emits globals: #16604

window.$RefreshReg$ = () => {};
window.$RefreshSig$ = () => type => type;

It would be nice to have them configurable. That would allow to use import.meta in environments like SystemJS and have simpler implementation:

import runtime from 'react-refresh/runtime'
runtime.injectIntoGlobalHook(window)

System.constructor.prototype.createContext = function (url) {
  return {
    url,
    $RefreshSig$: runtime.createSignatureFunctionForTransform,
    $RefreshReg$: (type, id) => {
      id = url + ' ' + id
      runtime.register(type, id)
    }
  };
};

If you don't mind I could create PR with changes to react-refresh/babel next week.

environment:

{
    "systemjs": "^6.1.4",
    "react": "^16.11.0",
    "react-dom": "^16.11.0",
    "react-refresh": "^0.6.0"
 }
@gaearon
Copy link
Collaborator

gaearon commented Nov 5, 2019

Happy to take a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants