muxinc / upchunk

Uploads Chunks! Takes big files, splits them up, then uploads each one with care (and PUT requests).
MIT License
329 stars 46 forks source link

Getting a type error during build time of a Next.js project #98

Closed fahim-arif closed 1 year ago

fahim-arif commented 1 year ago

I am trying to use Mux upload functionality and followed similar approach with Next.js Mux exmaple (https://github.com/vercel/next.js/tree/canary/examples/with-mux-video). Everything works fine on my local machine but when I try to build the project, I get a build error from node_modules/@mux/upchunk/dist/upchunk.d.ts:1:15 file.

Fyi, I am using node version: v18.12.1 and Next.js version 12

Screenshot 2023-01-14 at 9 07 43 PM
dylanjha commented 1 year ago

Thanks @fahim-arif for the report. We'll see what's going on here.

Just for a quick check, can you make sure you're on the latest version of UpChunk and also check the typescript version?

cjpillsbury commented 1 year ago

Hey @fahim-arif it looks like a typescript compatibility issue. The error is reffering to syntax we're using that was introduced in TS v4.5 (https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names)

A couple of things you could try:

  1. If this is a new project, try using the latest version of next.js (next@13.1.2) From your screenshot, it looks like you're on the previous major version, which I believe has a somewhat out of date version of typescript. The latest should include typescript@4.9.4 on a fresh use of create next app (e.g. yarn create next-app).
  2. Since this is effectively a typescript version issue and not a next.js issue, you could also simply try upgrading the version of typescript you're using to the latest version (or anything >= 4.5 should work).

With all of that said, I still am considering this an issue and planning a quick fix/release, since we can easily re-write the error-producing code in a way that would be compatible with versions as old as 3.8 (see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export). Appreciate the feedback!

cjpillsbury commented 1 year ago

@fahim-arif just a quick update: I cut a patch release of @mux/upchunk@3.0.1 this morning, which should also fix your issue, but let us know if you try it out and you're still seeing the problem.

fahim-arif commented 1 year ago

I upgraded to the latest version of @mux/upchunk@3.0.1 and the issue I had before is now fixed! Thanks you @cjpillsbury @dylanjha and everyone who helped fixing this issue in a such a short amount time.