Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's take another shot at #712...
How to use it
Defaults
If no
endpoint
is specified, will use@mux/mux-node
to create a direct upload with the following configuration:How to configure
Accepts all the same params as Mux Uploader, as well as
uploadCreateParams
will be deep-merged with the default options described aboveHow it gets bundled
lemme point out some interesting flags, here:
--platform=node
: in order to avoid bundling dependencies likecrypto
, esbuild requires this of us. Luckily, Server Components run on the server, so, this is correct--external:server-only
: the contents of this package is literally justthrow new Error('This is a server component and can't be imported in a client component')
(paraphrased). If we were to bundle it, our bundle would immediately throw an error. I suspect that, in practice, server-component-compliant bundlers will know to ignore this import. Even so, shouldserver-only
be marked as a peer dependency? 🤔--external:./index
: In order for server component bundlers to leave the server stuff on the server and the client stuff on the client, we have to ship the server bundle and the client bundle separately. By markingindex
as external, we're telling esbuild "don't include the client bundle in the server bundle". Instead, consumer bundlers will see this indist/rsc.mjs
and resolvedist/index.mjs
(ordist/rsc.cjs.js
anddist/index.cjs.js
respectively).TODO items:
--external:server-only
and--external:./index
? This seems to work in our test Next app, so that's a good sign...@mux/mux-uploader-react/rsc
giving me a red squiggle in the nextjs example? why can't typescript find it? or is that just something in my environment?Other passing thoughts
I don't re-export the types, so right now if you want those, you'll have to
import type { ... } from '@mux/mux-uploader-react'
. TypeScript should pick up on that; I'm not worried