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

Make it work with preact #50

Open
blittle opened this issue Apr 9, 2020 · 8 comments
Open

Make it work with preact #50

blittle opened this issue Apr 9, 2020 · 8 comments

Comments

@blittle
Copy link
Contributor

blittle commented Apr 9, 2020

It would be great to make kremling work with preact

@joeldenning
Copy link
Contributor

What part of kremling doesn't work, if you use preact-compat and alias react and react-dom inside of the webpack config?

@blittle
Copy link
Contributor Author

blittle commented Apr 15, 2020

Yeah, preact-compat works fine. I was hoping to not use the compatibility layer though.

@joeldenning
Copy link
Contributor

What could kremling do differently to make it work with both? The library has to do import React from 'react' in order for jsx to work.

Potentially we could publish the src directory and remove all references to react from it - attempting to auto-inject the imports during build? Then you could use the published src directory and compile it with a different jsx pragma for preact?? I'm not sure if that would make sense - would gladly take direction from other projects that have done this.

@geoctrl
Copy link
Contributor

geoctrl commented Apr 16, 2020

I've actually been thinking about this lately - the core of kremling could be framework agnostic: on component mount, append css - on component unmount, remove css

seems like we could pull the core of kremling out and make framework-specific implementations (like how you guys did it with single-spa)

might be able to keep it all in the same package and force consumers to choose their framework:

import { Scoped } from 'kremling/react';

@geoctrl
Copy link
Contributor

geoctrl commented Apr 16, 2020

or make several packages:
import { Scoped } from 'kremling-react';
import { Scoped } from 'kremling-preact';

@blittle
Copy link
Contributor Author

blittle commented Apr 16, 2020

This is a case where monorepos are useful :)

Maybe if I get time, I'll put together a mono repo implementation

@geoctrl
Copy link
Contributor

geoctrl commented Apr 19, 2020

started working on a mono repo, and thought it would be fun to implement kremling inside crankjs so I started there 😄

repo: https://github.com/geoctrl/kremling-monorepo

this is just an idea - I'm open to ideas - currently includes 3 packages:

  • core (core kremling things like class helpers and style utilities - excluded from publishing)
  • react (current react implementation)
  • crank (first-pass at getting kremling working - no tests, just the <Scoped /> component)

adding preact should be pretty easy at this point - I can do that next when I get time

@frehner
Copy link

frehner commented Apr 19, 2020

This is a case where monorepos are useful :)

don't hate me, but I agree with this. I feel like libraries are a good case for monorepos.

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

No branches or pull requests

4 participants