Skip to content

Make streaming functionality optional #172

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

Merged
merged 2 commits into from
Dec 12, 2023
Merged

Make streaming functionality optional #172

merged 2 commits into from
Dec 12, 2023

Conversation

mattt
Copy link
Contributor

@mattt mattt commented Dec 12, 2023

Follow-up to #169

Attempting to import the latest version of this library from a Next.js app produces the following error:

Module not found: Can't resolve 'stream'

The built-in Node.js stream module should be available, but they aren't. This may be an issue about Webpack 5 polyfills, but nobody has time for that — this just needs to come batteries-included.

What this PR does is two things:

  • First, it adds readable-stream as an optional dependency
  • Second, it updates the logic in lib/stream.js to import the Readable type from that library, falling back on the Node.js built-in. All of this is done in a try-catch, so an error won't be thrown unless the client attempts to use unsupported functionality (as opposed to simply doing import Replicate from 'replicate'.

@mattt mattt changed the title Mattt/optional stream Make streaming functionality optional Dec 12, 2023
@mattt mattt merged commit d39cb4a into main Dec 12, 2023
@mattt mattt deleted the mattt/optional-stream branch December 12, 2023 13:39
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

Successfully merging this pull request may close these issues.

1 participant