Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Remove next.js as peer dependency #2

Open
transitive-bullshit opened this issue Feb 16, 2021 · 12 comments
Open

Remove next.js as peer dependency #2

transitive-bullshit opened this issue Feb 16, 2021 · 12 comments
Labels
enhancement New feature or request

Comments

@transitive-bullshit
Copy link
Owner

react-static-tweets currently depends on next/image and next/link directly.

We should abstract these out so Next.js isn't required as a peer dependency.

@sugamxp
Copy link

sugamxp commented Feb 18, 2021

There is no such package next/image, it is just a folder inside next package, so, you cannot install it separately. Moreover, you can't use it separately without NextJs because it relies on NextJs server to optimize images on demand. I guess you would need to find another solution if you want image optimization.

@transitive-bullshit
Copy link
Owner Author

transitive-bullshit commented Feb 18, 2021

@sugamxp I'm aware that there's only one peer dep next.

This is just a note to myself that we need to offer a way to not depend on next directly because we currently import next/image and next/link from within react-static-tweets.

I already offer an elegant solution to working around this problem for https://github.com/NotionX/react-notion-x where the consumer of the library provides their own override for an Image and Link component instead of them being baked into the package itself. This is how I'm planning on removing next as a hard dependency from react-static-tweets while still allowing for them to be used by anyone who is using Next.js.

@slorber
Copy link

slorber commented Mar 3, 2021

+1, decoupling from Next would be appreciated. Had to copy this project's source to be able to use.

Also decoupling from useSWR would be better. Personally I don't want to use it and can fetch the tweets on my own ahead of time.

There is also the problems of reading a NextJS env variable (process.env.NEXT_THING => process is undefined unless you add some webpack tweaks).

You should rather:

  • create a monorepo with multiple packages
  • have a core package that just render a tweet, allowing to customize img/link rendering with a provider (many
  • create a next specific integration package that uses the provider to inject Next Img, eventually add useSWR?

@HynekS
Copy link
Contributor

HynekS commented Mar 8, 2021

I would also vouch for removing at least next/image dependency. While I am a big fan of Vercel, I wasn't able to make next/image work with SSG (via next export). If I understand the issues (↓), it is not currently supported for SSG, unless a custom loader is used(?).

vercel/next.js#18356
https://github.com/vercel/next.js/discussions/19372

(It is probably possible to use SSG on the late version of next-on-netlify though: netlify/next-on-netlify@ba22d52, but I haven't test it yet.)

@transitive-bullshit
Copy link
Owner Author

transitive-bullshit commented Mar 8, 2021

@slorber yep it's already a monorepo w/ multiple packages 😉 We just need to have the core next.js parts be opt-in via a Provider as you've suggested — as I've done for several of my other projects like https://github.com/NotionX/react-notion-x

Definitely lots that can be improved && very open to PRs 😄

@louisbarclay
Copy link

Is this the reason why I hit an error when trying to deploy via Vercel?

image

@louisbarclay
Copy link

More context around this:

  • I am developing a Next.js app (v10.0.5)
  • When installing react-static-tweets I get an error, that the package relies on Next.js 0.1.0
  • Only way to install is --force
  • Then I get the above error when trying to deploy to Vercel

@transitive-bullshit
Copy link
Owner Author

@louisbarclay did you add date-fns as a dependency to your next.js app? That's what this error is saying.

@louisbarclay
Copy link

@transitive-bullshit No - I didn't. Do I need to?

@transitive-bullshit
Copy link
Owner Author

@louisbarclay yes.

@MartinCura
Copy link

This would be great! We currently have a giant page of tweets and our fast-and-rough way of just embedding tweets slows it a lot.

Though i'd love to migrate the website to Next.js, we use Gatsby, so being able to use these pkgs would be great.

Is there a list of the specific changes that should be done to this project to make it Next.js-agnostic?

(Otherwise i'll have to try to extract the styled tweet component for our website. Thanks in any case!)

@BasixKOR
Copy link

BasixKOR commented Feb 7, 2022

Since the PR title isn't very clear on this: The PR above makes this package decoupled from Next.js. #38

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants