question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to integrate this into non-browser environments?

See original GitHub issue

I tried integrating this for my custom React renderer which uses a JS environment more similar to Node (e.g. uses global rather than window). After I aliased global as window, it got stumped by the lack of an addEventListener API:

file: node_modules/@pmmmwh/react-refresh-webpack-plugin/src/runtime/errorEventHandlers.js:85:10: JS ERROR TypeError: global.addEventListener is not a function. (In 'global.addEventListener(eventType, eventHandler)', 'global.addEventListener' is undefined)

What are the browser dependencies, and can anything be done to decouple it from the browser?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:32 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
pmmmwhcommented, Jun 13, 2020

It just seems that React components aren’t applying those HMR updates.

@shirakaba I think I’ve found the culprit.

react-refresh depends on developer tools integration, which needs to be manually injected via injectIntoDevTools from react-reconciler. react-nativescript doesn’t do that yet, so all the scheduleReactRefresh calls from the plugin essentially become no-ops.

You’ll have to somehow add this code snippet somewhere (presumably within the start function?):

const { version } = require('./package.json');

reactReconcilerInst.injectIntoDevTools({
  bundleType: __DEV__ ? 1 : 0,
  rendererPackageName: 'react-nativescript',
  version,
});
2reactions
pmmmwhcommented, Jun 15, 2020

Is there more to be tweaked?

Yes.

  • ErrorOverlayEntry don’t have to export the functions, but have to wire them up to the actual error handlers.
  • For runtime errors it would probably be something like this.
  • For compile errors I’m not sure if it’s do-able, especially when NativeScript uses the Node.js IPC API to signal compile status. A workaround is to subscribe to the done event with a custom plugin.
  • For clearCompileError, you will first need to get compile errors wired up then run it whenever a change is detected.
  • No, you don’t need to add an Error Boundary.

It will be quite a bit of work because of the complexity of the build system especially when APIs are unavailable in the actual NS runtime 😢

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Up an Integrated Development Environment (IDE)
IDE Tool #1: Code Editor (and Compiler). A whole bunch of online tutorials allow you to just code in the browser, which is...
Read more >
How does Javascript work in a non-browser environment?
If you look inside, here browser requests the data over http and web servers deliver it. There can be other methods of requesting...
Read more >
Integration URL for easy cross-browser testing - BrowserStack
Create URLs, with testing options as parameters, to instantly start a browser on BrowserStack Live. You can integrate these URLs into your application, ......
Read more >
Developing with GitHub Codespaces - Visual Studio Code
You can work with these environments from Visual Studio Code or in a browser-based editor. GitHub Codespaces extension. Environments. An environment is the...
Read more >
Deploy and publish Office Add-ins - Microsoft Learn
Sideloading, As part of your development process, to test your add-in running on Windows, iPad, Mac, or in a browser. (Not for production...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found