blitz-js / next-superjson-plugin

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

Doesn't work with superjson@2 #91

Closed EvHaus closed 5 months ago

EvHaus commented 9 months ago

Verify Next.js canary release

Describe the bug

Looks like next-superjson-plugin isn't compatible with the latest superjson@2 release. When doing a Next build it fails with:

unhandledRejection Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/node_modules/.pnpm/superjson@2.0.0/node_modules/superjson/dist/index.js from /vercel/path0/node_modules/.pnpm/next-superjson-plugin@0.5.9_next@13.5.4+superjson@2.0.0/node_modules/next-superjson-plugin/dist/tools.js not supported.
--
07:56:33.555 | Instead change the require of index.js in /vercel/path0/node_modules/.pnpm/next-superjson-plugin@0.5.9_next@13.5.4+superjson@2.0.0/node_modules/next-superjson-plugin/dist/tools.js to a dynamic import() which is available in all CommonJS modules.
07:56:33.555 | at mod.require (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/require-hook.js:64:28)
07:56:33.555 | at Object.<anonymous> (/vercel/path0/node_modules/.pnpm/next-superjson-plugin@0.5.9_next@13.5.4+superjson@2.0.0/node_modules/next-superjson-plugin/dist/tools.js:65:19)
07:56:33.556 | at mod.require (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/require-hook.js:64:28)
07:56:33.556 | at 6842 (/vercel/path0/.next/server/pages/_app.js:1:513)
07:56:33.557 | at __webpack_require__ (/vercel/path0/.next/server/webpack-runtime.js:1:161)
07:56:33.557 | at /vercel/path0/.next/server/chunks/1628.js:1:207
07:56:33.557 | at __webpack_require__.a (/vercel/path0/.next/server/webpack-runtime.js:1:1018)
07:56:33.557 | at 11628 (/vercel/path0/.next/server/chunks/1628.js:1:84)
07:56:33.557 | at __webpack_require__ (/vercel/path0/.next/server/webpack-runtime.js:1:161)
07:56:33.558 | at __webpack_exec__ (/vercel/path0/.next/server/pages/_app.js:1:1247)
07:56:33.558 | at /vercel/path0/.next/server/pages/_app.js:1:1285
07:56:33.558 | at __webpack_require__.X (/vercel/path0/.next/server/webpack-runtime.js:1:2739)
07:56:33.558 | at /vercel/path0/.next/server/pages/_app.js:1:1260
07:56:33.559 | at Object.<anonymous> (/vercel/path0/.next/server/pages/_app.js:1:1328)
07:56:33.559 | at mod.require (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/require-hook.js:64:28)
07:56:33.559 | at requirePage (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/require.js:109:84)
07:56:33.559 | at /vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/load-components.js:56:65
07:56:33.560 | at async Promise.all (index 1)
07:56:33.560 | at async loadComponentsImpl (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/server/load-components.js:54:33)
07:56:33.560 | at async Object.getDefinedNamedExports (/vercel/path0/node_modules/.pnpm/next@13.5.4_react-dom@18.2.0+react@18.2.0/node_modules/next/dist/build/utils.js:1199:24) {
07:56:33.560 | type: 'Error',
07:56:33.561 | code: 'ERR_REQUIRE_ESM'
07:56:33.561 | }

Expected behavior

No error during build

Reproduction link

No response

Version

next-superjson-plugin@0.5.9 & superjson@2

Config

No response

Additional context

No response

lipis commented 8 months ago

Yes please!!

s0h311 commented 8 months ago

Since it's taking so long... I've published a fork on npm. It seems to work: https://www.npmjs.com/package/next-superjson2

ZehuaZhang commented 7 months ago

Since it's taking so long... I've published a fork on npm. It seems to work: https://www.npmjs.com/package/next-superjson2

Your package is not working in next build,

Failed to compile
Module not found: Can't resolve 'next-superjson-plugin/tools'
s0h311 commented 7 months ago

Since it's taking so long... I've published a fork on npm. It seems to work: https://www.npmjs.com/package/next-superjson2

Your package is not working in next build,

Failed to compile
Module not found: Can't resolve 'next-superjson-plugin/tools'

Hi @ZehuaZhang, try adding next-superjson2 to your next.config.ts

ZehuaZhang commented 7 months ago

Since it's taking so long... I've published a fork on npm. It seems to work: https://www.npmjs.com/package/next-superjson2

Your package is not working in next build,

Failed to compile
Module not found: Can't resolve 'next-superjson-plugin/tools'

Hi @ZehuaZhang, try adding next-superjson2 to your next.config.ts

Thanks @s0h311 I did change next-superjson-plugin to next-superjson2 unfortunately, it's not working. My next version is the latest @14.0.3, not sure if that's related

thomasHnrt commented 7 months ago

Hi @ZehuaZhang,

You can add that to your package.json :

{
    "dependencies": {
        "next-superjson2": "^0.6.1",
        "next-superjson-plugin": "./node_modules/next-superjson2",
    }
}

Then, you can run npm install.

With this, next build works for me.

lipis commented 7 months ago

What about the maintainers.. is there a timeline on when it will be available officially? No rush.. just want to know :)

s0h311 commented 5 months ago

@orionmiz I will remove the fork published on npm. Could you please release?