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.

`const` injected in runtime code

See original GitHub issue

Thanks for this super cool project!

In RefreshModule.runtime.js, const are injected in runtime code and will not be transpiled (since it’s a loader injected code).

This is critical in old browser that do not support const in strict mode for example.

Elsewhere in the codebase i’ve seen a supportsConst method that seems to handle this specific case, maybe the code injected by RefreshModule.runtime.jsshould do the same.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
pmmmwhcommented, Jan 21, 2021

We are trying to replace RHL with react-refresh but we need to support old browsers (like Chrome 30-40 f.e) but these const are breaking our code with errors like “SyntaxError: Use of const in strict mode”.

It seems sad to me to not support all the projects that need to take into account old browsers (not only IE) just because of these few line 😞 but if it’s done deliberately, maybe this should be explicitly said in the README / FAQ (?).

I understand the frustration - I’ll look into it, in particular I don’t think we rely on any scoping behaviours from const and let.

0reactions
Donov4ncommented, Jan 21, 2021

Like said, it’s not only for Chrome 30-40, this bug is viewable on iOS 9, which imply supporting (or not) iPad 2, iPhone 4S …

+1 for the fact that React itself supports IE >= 9.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency Injection Code Smell: Injecting runtime data into ...
Injecting runtime data into your application components is a code smell. Runtime data should flow through the method calls of ...
Read more >
How to inject a mix of runtime value and normal dependencies
I'd like to implement something like the following: A orchestration service whose constructor accepts dependency services (can be injected using @inject ...
Read more >
Runtime code injection using DynamicMethod? - Stack Overflow
What I would like to do is inject some debugging code into the Foo delegate, which would be equivalent: FooDelegate Foo = delegate(int...
Read more >
Inject JavaScript Or CSS At Runtime And On Demand
But no worries, here's a trick to solve such requirement by injecting either a script or css in your page on demand and...
Read more >
5 ways to prevent code injection in JavaScript and Node.js
Learn some best practices for keeping your Node.js and JavaScript projects safe from code injection attacks.
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