next-video icon indicating copy to clipboard operation
next-video copied to clipboard

turbopack support

Open wladpaiva opened this issue 1 year ago • 12 comments

By default, when using turbopack dev it throws an error

@apps/www:dev: [next]  ⨯ ModuleBuildError: ./apps/@www/videos/payments.mp4
@apps/www:dev: [next] Unknown module type
@apps/www:dev: [next] This module doesn't have an associated type. Use a known file extension, or register a loader for it.
@apps/www:dev: [next] 
@apps/www:dev: [next] Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders

wladpaiva avatar Jun 14 '24 16:06 wladpaiva

+1

ryanleecode avatar Jun 17 '24 19:06 ryanleecode

Thanks for reporting!

yes, for now turbopack doesn't support inline webpack loaders which next-video uses for the video type.

we might need to export this as a separate package to make this to work. not sure if we'll get to this before Turbopack reaches parity.

luwes avatar Jun 27 '24 21:06 luwes

I did some digging again and the blocker is Turbopack requires support for importing binaries (raw) files (mp4's). https://github.com/vercel/next.js/discussions/72147

luwes avatar Nov 01 '24 19:11 luwes

Tried this today and managed to get a few steps in but it's still complaining about them when I view one of the pages

    experimental: {
        turbo: {
            resolveExtensions: ['.mdx', '.tsx', '.ts', '.jsx', '.js', '.mjs', '.json', '.mp4'],
            rules: {
                './videos/*.mp4': {
                    loaders: ['next-video/webpack/video-raw-loader.js'],
                    as: '*.json',
                },
                './videos/*.mp4.json': {
                    loaders: ['next-video/webpack/video-json-loader.js'],
                    as: '*.json',
                },
            },
        },
    },

Extension seems to be wrong:

Failed to compile

./videos/coblocks-ai.mp4.json.json
Code generation for chunk item errored
An error occurred while generating the chunk item [project]/videos/coblocks-ai.mp4.json.json (json)

Caused by:
- failed to convert rope into string
- invalid utf-8 sequence of 1 bytes from index 35

kevinschaich avatar Nov 11 '24 01:11 kevinschaich

yes, thanks for digging in! Turbopack is trying to convert the imported file to a string I believe which is not we want. it should stay raw (binary)

luwes avatar Nov 11 '24 15:11 luwes

As of between about a month ago and yesterday, Turbopack's latest version is causing issues with mux

TypeError: (0 , __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f40$mux$2f$mux$2d$node$2f$_shims$2f$registry$2e$mjs__$5b$app$2d$rsc$5d$__$28$ecmascript$29$__.getDefaultAgent) is not a function
    at async AdminLessonHome (rsc://React/Server/C:%5CUsers%5Clazen%5CWebstormProjects%5Cclevoro-2%5C.next%5Cserver%5Cchunks%5Cssr%5C%5Broot%20of%20the%20server%5D__1d871d31._.js?0:94:26)
    at resolveErrorDev (http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_38d265cf._.js:3290:48)
    at processFullStringRow (http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_38d265cf._.js:3506:23)
    at processFullBinaryRow (http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_38d265cf._.js:3494:9)
    at progress (http://localhost:3000/_next/static/chunks/node_modules_next_dist_compiled_38d265cf._.js:3640:102)
    at InnerLayoutRouter (http://localhost:3000/_next/static/chunks/node_modules_next_dist_1a6ee436._.js:351:55)
    at OuterLayoutRouter (http://localhost:3000/_next/static/chunks/node_modules_next_dist_1a6ee436._.js:498:73)

tylerlazenby avatar Mar 06 '25 18:03 tylerlazenby

@luwes Could you please elaborate on this?

we might need to export this as a separate package to make this to work.

and maybe provide a simple example would be highly appreciated 🙏

okerx avatar Mar 15 '25 07:03 okerx

@okerx my old comment is not correct. the fix in next-video will require this change in Next.js in Turbopack https://github.com/vercel/next.js/pull/75056

luwes avatar Mar 18 '25 19:03 luwes

Working with turbopack is blocking us from integrating next-video with mux. Any workarounds? Without turbo pack our local development nearly crawls to a halt.

pkpio avatar Apr 05 '25 21:04 pkpio

Working with turbopack is blocking us from integrating next-video with mux. Any workarounds? Without turbo pack our local development nearly crawls to a halt.

The issue here is that turbopack is unable to work with something within the core of mux. But I have removed turbopack from my build so that I can keep going. Sorry to not have more to give.

tylerlazenby avatar Apr 07 '25 16:04 tylerlazenby

I removed next-video instead as turbo pack is not really optional for us

pkpio avatar Apr 17 '25 11:04 pkpio

Turbopack has a fix for this staged: https://github.com/vercel/next.js/pull/75056#issuecomment-2808874442

davekiss avatar Apr 17 '25 13:04 davekiss

I am facing the same issue. What's the solution for this ?

Image

rajatwaghare avatar May 20 '25 04:05 rajatwaghare

This blocked by the Next.js v15.4.0 release. When it's released we can fix this issue.

luwes avatar May 20 '25 15:05 luwes

Next 15.4 is released. Eagerly waiting instructions on how to fix. Thanks.

sidd2pir avatar Jul 15 '25 22:07 sidd2pir

any news on this fix? Thanks!

martinmorenoc avatar Jul 29 '25 15:07 martinmorenoc

I'm willing to take this on. Please let me know if you have any guidance @luwes

suneel-pi avatar Aug 04 '25 17:08 suneel-pi

Thanks for the interest y'all! I've put up a PR that half works. The issue now is that changes to the .json files are not detected and causing a reload by Turbopack. If you could help investigate that would be great!

This is a related issue https://github.com/vercel/next.js/issues/81926 but it says it's fixed? 🤷‍♂️

luwes avatar Aug 07 '25 12:08 luwes

Thank you @luwes! As https://github.com/vercel/next.js/issues/81926 recommends, I'll try the latest canary. Too bad this might not hit till 15.4.7 :(

suneel-pi avatar Aug 07 '25 18:08 suneel-pi

any updates here?

Nazaire avatar Aug 23 '25 20:08 Nazaire