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.

Allow React support to be optional

See original GitHub issue

It would be nice if React support was optional, such that if you didn’t want to use it, the dependencies aren’t downloaded. Currently, the entire React library is imported whether or not you want to use it, which might not be ideal for something like a pure API.

It could be done by allowing React to be added in manually by importing something like react.ts (which would be next to main.ts) and using its exports, or by allowing React to be imported by the consumer and then provided to the API (this would allow users to select a specific version of React as well, or maybe even be able to use Preact).

I’m not sure on the best way to implement it, but if this is something worth looking into, I’d be happy to try and write up a PR!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
luviescommented, Jun 14, 2020

I’m going to open an issue for middleware since it seems a bit out of scope for this issue (and I wanted to suggest a possible API for it)

0reactions
sholladaycommented, Jun 25, 2020

Having thought about this for a few days, here’s what I’ve decided:

  1. React support will remain built-in. It’s a selling point and I personally use it a lot. Deno renders JSX out-of-the-box, and most backend projects will need a view engine of some sort, so we might as well leverage it.
  2. The user ought to have some control over the React version used by the framework, somewhat akin to Node’s peerDependencies. For that, I will accept a PR that adds a react server option, which can be used to override the built-in version that ships with the framework. However, I would encourage users to use an import map instead, so that only one React is ever downloaded. PR welcome for documenting how to do that.

I’m happy to revisit this approach in the future. In particular, if Deno’s tooling around peer dependencies improves, that may open up new opportunities for us.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling optional chaining in a create-react-app
In this post, we'll learn how to enable optional chaining in an application created using create-react-app. This is probably not something that should...
Read more >
How to enable optional chaining with Create React App and ...
Create-React-App uses babel to transpile the TypeScript so it isn't using your npm installed version of TypeScript.
Read more >
Optional chaining with React - DEV Community ‍ ‍
The main advantage of using optional chaining is a smaller and cleaner code which makes it easier to comprehend once people get used...
Read more >
Optional chaining with React and TypeScript | Building SPAs
Optional chaining is a cracking new JavaScript feature that we can use today in React and TypeScript apps. What is this feature, and...
Read more >
Start Using Optional Chaining and Nullish Coalescing in React
The optional chaining operator ( ?. ) enables you to read the value of a property located deep within a chain of connected...
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