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.

Continue publishing preact/compat as standalone node module also?

See original GitHub issue

I’d like to suggest you continue publishing the npm package preact-compat as alternative method of installing/using preact/compat.

This would make it possible to use npm and yarn’s native package.json dependency renaming syntax and skip installing 3rd party aliasing-plugins and/or relying on bundler config tricks.

Like so…

npm install react@npm:preact-compat@^10 react-dom@npm:preact-compat@^10

resulting in these depdendency lines in package.json

	"react": "npm:preact-compat@^10",
	"react-dom": "npm:preact-compat@^10",

The only thing that might make this unfeasible, is if this would result in large amounts of code being imported twice - once from node_modules/react and then again from node_modules/react-dom. I’m not familiar enough with the preact codebase to judge how tight the coupling is between the "react"y and "react-dom"y bits of Preact.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
andrewigginscommented, Nov 29, 2019

Does npm aliases work for compat? At least when they were first introduced, it only aliased the package for yourself, not for any libraries you add (e.g. when your code imported react you would get preact-compat but if you used react-router, it’s react import would still be react, not compat). That’s my understanding of the relevant section in the RFC (see the paragraph about problems this RFC does not address). Has npm changed the behavior of aliases since this RFC was released?

1reaction
caubcommented, Feb 10, 2021

@marvinhagemeister Thanks, I did notice that, no worry. I’m just posting my solution for the record, and comparing with what others are doing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Switching to Preact (from React)
Switching to Preact can be as easy as installing and aliasing preact-compat in for react and react-dom . This lets you continue writing...
Read more >
preact
Extensive React compatibility via a simple preact-compat alias; Everything you need: JSX, VDOM, React DevTools, HMR, SSR.. A highly optimized ...
Read more >
Getting started with PreactJS — A Step By Step Guide
There are very small (and negligible) API difference between React and Preact when writing UI. Having said that, If you like to stay...
Read more >
Build a Health Blog With Video Coaching Using Preact.js ...
Notably, it's only 3.5kb in size and is compatible with the React modules you would find on npm. Being able to write React/React...
Read more >
API - esbuild
It can also be used to import code in node at run time from a package that ... This behavior improves compatibility with...
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