Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with superjson@2 #145

Open
mongolyy opened this issue Oct 19, 2023 · 2 comments · May be fixed by #146
Open

Doesn't work with superjson@2 #145

mongolyy opened this issue Oct 19, 2023 · 2 comments · May be fixed by #146

Comments

@mongolyy
Copy link

When I upgraded superjson to version 2.0.0 and ran the next build command, I got the following error:

info  - Collecting page data ...Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\mongolyy\repos\next-app\node_modules\superjson\dist\index.js from C:\Users\mongolyy\repos\next-app\node_modules\babel-plugin-superjson-next\dist\tools.js not supported.
Instead change the require of index.js in C:\Users\mongolyy\repos\next-app\node_modules\babel-plugin-superjson-next\dist\tools.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\Users\mongolyy\repos\next-app\node_modules\babel-plugin-superjson-next\dist\tools.js:64:19)
    at Object.<anonymous> (C:\Users\mongolyy\repos\next-app\node_modules\babel-plugin-superjson-next\tools.js:1:18)
    at 1421 (C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:701:18)
    at __webpack_require__ (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:25:42)
    at C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:66:91
    at __webpack_require__.a (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:89:13)
    at 8285 (C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:60:21)
    at __webpack_require__ (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:25:42)
    at C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:18:83
    at __webpack_require__.a (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:89:13)
    at 4411 (C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:11:21)
    at __webpack_require__ (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:25:42)
    at __webpack_exec__ (C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:914:39)
    at C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:915:85
    at __webpack_require__.X (C:\Users\mongolyy\repos\next-app\.next\server\webpack-runtime.js:177:21)
    at C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:915:47
    at Object.<anonymous> (C:\Users\mongolyy\repos\next-app\.next\server\pages\cart.js:918:3)
    at requirePage (C:\Users\mongolyy\repos\next-app\node_modules\next\dist\server\require.js:156:12)
    at C:\Users\mongolyy\repos\next-app\node_modules\next\dist\server\load-components.js:68:84
    at async loadComponentsImpl (C:\Users\mongolyy\repos\next-app\node_modules\next\dist\server\load-components.js:68:26)
    at async C:\Users\mongolyy\repos\next-app\node_modules\next\dist\build\utils.js:1002:32
    at async Span.traceAsyncFn (C:\Users\mongolyy\repos\next-app\node_modules\next\dist\trace\trace.js:103:20) {
  code: 'ERR_REQUIRE_ESM'
}

I think this is due to superjson becoming ES Module in 2.0.0.

Environement

  • Next.js version: 13.3.4
  • superjson version: 2.0.0
  • babel-plugin-superjson-next version: 0.4.4
@Skn0tt Skn0tt linked a pull request Oct 20, 2023 that will close this issue
@baba43
Copy link

baba43 commented Apr 19, 2024

Any solutions?

@Skn0tt
Copy link
Member

Skn0tt commented Apr 19, 2024

This might be related to settings in your tsconfig.json or the type field in your package.json. When you put import SuperJSON from "superjson" into one of your source files, does it fail with the same error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants