blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components
192 stars 13 forks source link

`next-superjson-plugin` is broken with Next 13.4.8 #86

Closed ovflowd closed 1 year ago

ovflowd commented 1 year ago

Verify Next.js canary release

Describe the bug

Once upgrading to Next.js 13.4.8 the build process broke. Vercel did mention that Next.js 13.4.8 had extensive changes on the compiler.

Expected behavior

It should not break.

Reproduction link

https://github.com/nodejs/nodejs.org

Version

0.5.8

Config

Any simple Next App with Next.js 13.4.8

Additional context

(Simply update Next.js to 13.4.8)

kenbankspeng commented 1 year ago

For me, any code that used a ternary broke in the transpilation flow through next-superjson-plugin.

const entries = Object.entries(obj); const firstValue = entries.shift()?.[1];

produced:

const entries = Object.entries(obj); const firstValue = this?.; <----error

limwa commented 1 year ago

@ovflowd @kenbankspeng please check out this comment and let me know if the issue is fixed or still unresolved!

franklsf95 commented 1 year ago

I also got the following stack trace, not sure if it's related:

- info Creating an optimized production build .thread '<unnamed>' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:525:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/home/ubuntu/usourced/usourced-web/src/pages/api/auth/[...nextauth].ts")'

Caused by:
    0: failed to invoke `/home/ubuntu/usourced/usourced-web/node_modules/.pnpm/next-superjson-plugin@0.5.8_next@13.4.8_superjson@1.12.4/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /home/ubuntu/usourced/usourced-web/node_modules/.pnpm/next-superjson-plugin@0.5.8_next@13.4.8_superjson@1.12.4/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1645]:0x13ce2c)
           at <unnamed> (<module>[1636]:0x13cb41)
           at <unnamed> (<module>[1635]:0x13cb08)
           at <unnamed> (<module>[1623]:0x13bb80)
           at <unnamed> (<module>[1622]:0x13bae2)
           at <unnamed> (<module>[1630]:0x13c176)
           at <unnamed> (<module>[1767]:0x14a09f)
           at <unnamed> (<module>[1754]:0x149776)
           at <unnamed> (<module>[777]:0xc6830)
           at <unnamed> (<module>[771]:0xc4d85)
           at <unnamed> (<module>[782]:0xc6b51)
           at <unnamed> (<module>[852]:0xd2e8c)
           at <unnamed> (<module>[873]:0xdddc5)
           at <unnamed> (<module>[852]:0xd4f92)
           at <unnamed> (<module>[873]:0xdddc5)
           at <unnamed> (<module>[605]:0xa0275)
           at <unnamed> (<module>[649]:0xae944)
           at <unnamed> (<module>[654]:0xb1083)
           at <unnamed> (<module>[649]:0xb09e6)
           at <unnamed> (<module>[650]:0xb0cff)
           at <unnamed> (<module>[649]:0xaef48)
           at <unnamed> (<module>[654]:0xb1083)
           at <unnamed> (<module>[857]:0xda615)
           at <unnamed> (<module>[873]:0xde512)
           at <unnamed> (<module>[852]:0xd4f92)
           at <unnamed> (<module>[873]:0xdddc5)
           at <unnamed> (<module>[852]:0xd4f92)
           at <unnamed> (<module>[861]:0xdb124)
           at <unnamed> (<module>[479]:0x72bea)
           at <unnamed> (<module>[462]:0x6bffe)
           at <unnamed> (<module>[101]:0xf38f)
           at <unnamed> (<module>[100]:0xf156)
           at <unnamed> (<module>[745]:0xbb32b)
           at <unnamed> (<module>[1900]:0x156429)', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.263.26/src/plugin.rs:162:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
limwa commented 1 year ago

@franklsf95 it could be related. A preliminar version of the fix is available in #88.

kenbankspeng commented 1 year ago

Issue fixed using procedure in this comment. Thank you.

orionmiz commented 1 year ago

next-superjson-plugin v0.5.9 was just released. Thanks for contribution! @limwa