Code Monkey home page Code Monkey logo

next-superjson-plugin's Introduction

Next SuperJSON Plugin

πŸ”Œ SuperJSON Plugin for Next.js (SWC)

/pages (Pages Directory)

export default function Page({ date }) {
  return <div>Today is {date.toDateString()}</div>;
}

// You can also use getInitialProps, getStaticProps
export const getServerSideProps = () => {
  return {
    props: {
      date: new Date(),
    },
  };
};
  • Allows pre-rendering functions to return props including Non-JSON Values(Date, Map, Set..)

/app (App Directory)

// Use "data-superjson" attribute to pass non-serializable props to client components
// No needs to change the propsType of Client Component (It's type-safe!)

export default function ServerComponent() {
  const date = new Date();
  return <ClientComponent date={date} data-superjson />;
}

Usage

Install packages first:

npm install superjson next-superjson-plugin
# or Yarn
yarn add superjson next-superjson-plugin

Add the plugin into next.config.js

// next.config.js
module.exports = {
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

Options

You can use the excluded option to exclude specific properties from serialization.

['next-superjson-plugin', { excluded: ["someProp"] }],

How it works

sequenceDiagram
    participant Next.js
    participant SWC Plugin
    participant SuperJSON
    Next.js->>SWC Plugin: Request Transform
    SWC Plugin->>SWC Plugin: Transform Pages/Components <br> To Use SuperJSON
    SWC Plugin->>Next.js: Take Modules
    Next.js-->SuperJSON: Connected
    Next.js->>SuperJSON: Serialize Props <br> (Date, BigInt, Set, Map..)
    Note over SWC Plugin: getInitialProps <br> getServerSideProps <br> getStaticProps <br> Server Components
    SuperJSON->>Next.js: Deserialize Props
    Note over SWC Plugin: Pages <br> Client Components

Loading

Bug Report

⚠️ Keep in mind: SWC Plugin is still an experimental feature for Next.js

Plugin always ensures compatibility with Next.js Canary version only.

Leave an Issue

Special Thanks

  • kdy1 (Main creator of swc project)

next-superjson-plugin's People

Contributors

aleehedl avatar boredland avatar limwa avatar orionmiz avatar tonyfromundefined avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

next-superjson-plugin's Issues

Upgade is needed for Next 14.2.3 compatibility

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

failed to run Wasm plugin transform. Please ensure the version of swc_core used by the plugin is compatible with the host runtime. See https://swc.rs/docs/plugin/selecting-swc-corefor compatibility information. If you are an author of the plugin, please update swc_core to the compatible version.

Expected behavior

It shouldn't error out

Reproduction link

No response

Version

0.6.1

Config

No response

Additional context

No response

Nextjs Plugin Error

Hello! I've just tried to install the Nextjs SWC Experimental Plugin but am getting a bunch of Failed to create plugin instance errors.

What I did:

yarn add superjson next-superjson-plugin

In my next.config.js:

const moduleExports = {
  reactStrictMode: true,
  swcMinify: true,
  output: "standalone",
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
  sentry: {
    hideSourceMaps: true,
  },
};

const sentryWebpackPluginOptions = {
  silent: true,
};

module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions);

Errors I am receiving:

warn  - You have enabled experimental feature (swcPlugins) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/sentry.client.config.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', ', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs222::22214:
14note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '
<unnamed>thread '' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/next-dev.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })<unnamed>', ' panicked at '/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rsfailed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/router.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] }):', 222/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs::14222
:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/pages/_app.jsx")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/pages/_error.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/sentry.server.config.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/pages/_app.jsx")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/pages/_error.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/pages/_document.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
error - ./sentry.client.config.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/sentry.client.config.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })
wait  - compiling...
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/router.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/node_modules/next/dist/client/next-dev.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/sentry.client.config.js")'

Caused by:
    0: Failed to create plugin instance
    1: Error while importing "env"."__set_transform_plugin_core_pkg_diagnostics": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [] })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14
thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/isabellee/Code/innacircle/pages/_error.js")'

Any help appreciated! Thanks!

Rust error

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I get this output

gymrat/apps/next on ξ‚  main ❯ RUST_BACKTRACE=1 pnpm run dev

> [email protected] dev /Users/jokull/Code/gymrat/apps/next
> next dev --port 3800

ready - started server on 0.0.0.0:3800, url: http://localhost:3800
info  - Loaded env from /Users/jokull/Code/gymrat/apps/next/.env
warn  - You have enabled experimental features (appDir, allowMiddlewareResponseBody, swcPlugins) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info  - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback

thread 'thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
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("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1eccthread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/next-dev.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs6299db9ec823/swc-0.232.84/src/plugin.rs::228228::1414

stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/app-next-dev.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
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("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_app.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
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("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_error.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
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("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_app.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_error.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/lib.rs:43:48
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("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_document.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.84/src/plugin.rs:228:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error - ../../node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/app-next-dev.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/app-next-dev.js")'

Caused by:
    0: failed to invoke `/Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /Users/jokull/Code/gymrat/node_modules/.pnpm/[email protected]_f6u5o4wezvqlz2l4c6obuika34/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
    2: unreachable

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: _napi_register_module_v1
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>

Stack backtrace:
   0: _wasmer_vm_raise_trap
   1: _wasmer_vm_raise_trap
   2: <unknown>
   3: <unknown>
   4: <unknown>
^C⏎     

Expected behavior

N/A

Reproduction link

No response

Version

0.5.0

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    appDir: true,
    // runtime: "experimental-edge",
    transpilePackages: ["api"],
    allowMiddlewareResponseBody: true,
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

module.exports = nextConfig;

Additional context

PNPM monorepo. If something doesn't jump out as obvious I will help recreate in a small repo.

Issue with `next-superjson-plugin`

Here is my full stacktrace

$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/matteogauthier/dev/pollo/.env.local
warn  - You have enabled experimental feature (swcPlugins) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

thread 'thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
265:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'thread '<unnamed><unnamed>' panicked at '<unnamed>failed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1499]:0x1253cb)
           at <unnamed> (<module>[1492]:0x125123)
           at <unnamed> (<module>[1491]:0x1250a0)
           at <unnamed> (<module>[1477]:0x124301)
           at <unnamed> (<module>[1476]:0x124240)
           at <unnamed> (<module>[1486]:0x1249f0)
           at <unnamed> (<module>[1581]:0x12aff7)
           at <unnamed> (<module>[1628]:0x131d81)
           at <unnamed> (<module>[705]:0xc3c91)
           at <unnamed> (<module>[175]:0x2e345)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: unreachable', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rs:216:14' panicked at '
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/next-dev.js")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1499]:0x1253cb)
           at <unnamed> (<module>[1492]:0x125123)
           at <unnamed> (<module>[1491]:0x1250a0)
           at <unnamed> (<module>[1477]:0x124301)
           at <unnamed> (<module>[1476]:0x124240)
           at <unnamed> (<module>[1486]:0x1249f0)
           at <unnamed> (<module>[1581]:0x12aff7)
           at <unnamed> (<module>[1628]:0x131d81)
           at <unnamed> (<module>[705]:0xc3c91)
           at <unnamed> (<module>[175]:0x2e345)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: unreachable' panicked at '', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rsfailed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1499]:0x1253cb)
           at <unnamed> (<module>[1492]:0x125123)
           at <unnamed> (<module>[1491]:0x1250a0)
           at <unnamed> (<module>[1477]:0x124301)
           at <unnamed> (<module>[1476]:0x124240)
           at <unnamed> (<module>[1486]:0x1249f0)
           at <unnamed> (<module>[1581]:0x12aff7)
           at <unnamed> (<module>[1628]:0x131d81)
           at <unnamed> (<module>[440]:0x845e6)
           at <unnamed> (<module>[440]:0x829fb)
           at <unnamed> (<module>[219]:0x466ad)
           at <unnamed> (<module>[175]:0x2eef9)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: unreachable:', 216/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rs::14216
:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/pages/_app.tsx")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[440]:0x8294a)
           at <unnamed> (<module>[219]:0x466ad)
           at <unnamed> (<module>[175]:0x2eef9)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rs:216:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/pages/_error.js")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[1539]:0x129034)
           at <unnamed> (<module>[518]:0x965de)
           at <unnamed> (<module>[175]:0x2e257)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rs:216:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/matteogauthier/dev/pollo/pages/_app.tsx")'

Caused by:
    0: failed to invoke `/Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /Users/matteogauthier/dev/pollo/node_modules/.pnpm/[email protected]_qlg2dhhwigzfxh5xuu3lcszjwi/node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[282]:0x4edf8)
           at <unnamed> (<module>[175]:0x2e295)
           at <unnamed> (<module>[728]:0xc603e)
           at <unnamed> (<module>[727]:0xc5dbb)
           at <unnamed> (<module>[575]:0xa3561)
           at <unnamed> (<module>[1692]:0x136a40)
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.226.26/src/plugin.rs:216:14
error Command failed with signal "SIGSEGV".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

And my next info

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 17.4.0
      npm: 8.3.1
      Yarn: 1.22.17
      pnpm: 7.5.1
    Relevant packages:
      next: 12.3.1
      eslint-config-next: 13.0.0
      react: 18.2.0
      react-dom: 18.2.0

_app.tsx not getting parsed data

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'm using getServerSideProps to fetch some data and return it in props and in the _app.tsx file I want to use that data.
The problem is, I have a few bigint properties in the data but in the _app.tsx file bigint are still strings.
I checked on the page itself and the data are parsed as expected bigint are bigint.

Expected behavior

parsed the data.

Reproduction link

No response

Version

0.4.9

Config

experimental: {
      swcPlugins: [
        [
          "next-superjson-plugin",
          {
            excluded: [],
          },
        ],
      ],
    },

Additional context

next: v12.3.2-canary.43

Rerendering everything if used with NextJs 13

When using the experimental app dir in NextJS 13, this module causes everything to rerender every few seconds.

How to replicate:

  • Install the module:
    npm install superjson next-superjson-plugin
  • Start the development server:
    npm run dev

Additionally, the issue persists after running npm remove superjson next-superjson-plugin and removing the settings from next.config.js.

failed to invoke as js transform plugin. RuntimeError: unreachable

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

Installed latest next and next-superson-plugin. But when I try and start the dev server get the following error

β¨― ./src/middleware.ts
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/path/src/middleware.ts")'

Caused by:
    0: failed to invoke `/path/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /path/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: failed to run Wasm plugin transform. Please ensure the version of `swc_core` used by the plugin is compatible with the host runtime. See https://swc.rs/docs/plugin/selecting-swc-core for compatibility information. If you are an author of the plugin, please update `swc_core` to the compatible version.
    2: RuntimeError: unreachable

I'm not sure why this is happening on my middleware.ts file

Expected behavior

Expect the application to start without any issues

Reproduction link

No response

Version

0.6.3

Config

No response

Additional context

No response

Dev/Build thread panic error introduced with v0.6.2

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

Upgrading from 0.6.1 to 0.6.2 introduced this bug that prevent execution both during next dev and next build:

thread '' panicked at C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\rkyv-0.7.42\src\impls\core\mod.rs:267:17:
assertion failed: !result.is_null()

Expected behavior

Dev and Build running without error

Reproduction link

No response

Version

0.6.2

Config

const nextConfig = {
  output: 'standalone',
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]]
  }
}

Additional context

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
Binaries:
  Node: 20.11.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: standalone

Unsupported React Server Components (Next 13 exprimental appDir)

This may or may not be a bug (because it's an experimental next feature, that we're talking about) but I wanted to bring this up anyway:

Warning: Only plain objects can be passed to Client Components from Server Components. Date objects are not supported.

is what you get with experimental appDir support when trying to pass data from a server component to a client component. Apparently that part of data transfer is not covered (yet). Here is the my next.config.js for curious readers:

module.exports = {
  experimental: {
    appDir: true,
    swcPlugins: [
      [
        'next-superjson-plugin',
        {
          excluded: []
        }
      ]
    ]
  }
};

getServerSideProps issue `Cannot use 'in' operator to search for 'props' in undefined`

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I have an issue with Sentry + Superjson + next-superjson-plugin

    "next-superjson-plugin": "^0.6.3",
    "@sentry/nextjs": "7.106.1",

β¨― TypeError: Cannot use 'in' operator to search for 'props' in undefined
    at withSuperJSON (file:///Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next-superjson-plugin/dist/tools.js:8:23)
    at async /Users/xxxxxxxx/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sentry/nextjs/cjs/common/utils/wrapperUtils.js:38:14
    at async /Users/xxxxxxxx/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sentry/nextjs/cjs/common/utils/wrapperUtils.js:113:24
    at async Object.apply (/Users/xxxxxxxx/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@sentry/nextjs/cjs/common/wrapGetServerSidePropsWithSentry.js:45:33)
    at async e3 (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/pages.runtime.dev.js:25:124)
    at async doRender (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1411:30)
    at async cacheEntry.responseCache.get.routeKind (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1585:28)
    at async DevServer.renderToResponseWithComponentsImpl (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1493:28)
    at async DevServer.renderPageComponent (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1908:24)
    at async DevServer.renderToResponseImpl (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:1946:32)
    at async DevServer.pipeImpl (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:910:25)
    at async NextNodeServer.handleCatchallRenderRequest (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js:272:17)
    at async DevServer.handleRequestImpl (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/base-server.js:806:17)
    at async /Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/dev/next-dev-server.js:339:20
    at async Span.traceAsyncFn (/Users/xxxxxxxx/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/trace/trace.js:151:20) {
  page: '/admin/lessons/clsosaa960002o192nre5wkza'
}

Expected behavior

No crash

Reproduction link

No response

Version

0.6.3

Config

import { withSentryConfig } from "@sentry/nextjs"
/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 * for Docker builds.
 */
await import("./src/env.mjs")

/** @type {import("next").NextConfig} */
const config = {
  reactStrictMode: true,
  async headers() {
    return [
      {
        // @todo Refine this for better security
        source: "/api/:path*",
        headers: [
          { key: "Access-Control-Allow-Credentials", value: "true" },
          { key: "Access-Control-Allow-Origin", value: `*` },
          { key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
          {
            key: "Access-Control-Allow-Headers",
            value:
              "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
          },
        ],
      },
    ]
  },
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
  experimental: {
    swcPlugins: [
      [
        "next-superjson-plugin",
        {
          excluded: [],
        },
      ],
    ],
  },
}

export default withSentryConfig(
  config,
  {
    // For all available options, see:
    // https://github.com/getsentry/sentry-webpack-plugin#options

    // Suppresses source map uploading logs during build
    silent: true,
    org: "xxxxx",
    project: "xxxxx",
  },
  {
    // For all available options, see:
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

    // Upload a larger set of source maps for prettier stack traces (increases build time)
    widenClientFileUpload: true,

    // Transpiles SDK to be compatible with IE11 (increases bundle size)
    transpileClientSDK: true,


    // Hides source maps from generated client bundles
    hideSourceMaps: true,

    // Automatically tree-shake Sentry logger statements to reduce bundle size
    disableLogger: true,

    // Enables automatic instrumentation of Vercel Cron Monitors.
    // See the following for more information:
    // https://docs.sentry.io/product/crons/
    // https://vercel.com/docs/cron-jobs
    automaticVercelMonitors: true,
  }
)

Additional context

The problematic gSSP method :

export const getServerSideProps = async (context: GetServerSidePropsContext<{ id: string }>) => {
  const data = await db.course.findUnique({ where: { id: context.params?.id } })
  if (data) return data

  return {
    notFound: true,
  }
}

Doesn't work with superjson@2

Verify Next.js canary release

  • I verified that the issue exists in the latest 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/[email protected]/node_modules/superjson/dist/index.js from /vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/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/[email protected][email protected][email protected]/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/[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:64:28)
07:56:33.555 | at Object.<anonymous> (/vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next-superjson-plugin/dist/tools.js:65:19)
07:56:33.556 | at mod.require (/vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/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/[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:64:28)
07:56:33.559 | at requirePage (/vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/server/require.js:109:84)
07:56:33.559 | at /vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/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/[email protected][email protected][email protected]/node_modules/next/dist/server/load-components.js:54:33)
07:56:33.560 | at async Object.getDefinedNamedExports (/vercel/path0/node_modules/.pnpm/[email protected][email protected][email protected]/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

[email protected] & superjson@2

Config

No response

Additional context

No response

Failed to build after installing next-superjson-plugin

Describe the bug

Hi Guys,

First of all thanks for this plugin. It will be really useful. But after installing the plugin and configure i couldn't launch the project with yarn dev. See below the output from yarn dev

warn - You have enabled experimental feature (swcPlugins) in next.config.js.
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

thread 'thread 'thread '' panicked at '' panicked at 'failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm' panicked at 'failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node-plugin\next_superjson.wasmgin\next_superjson.wasm
Caused by:invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_mod 0: Failed to create plugin instanceon.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjsonCaused by:
1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })
0: Failed to create plugin instance', 0: Failed to create plugin instanceC:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188
1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] }) 1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] }):t', hread '', 212C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rsC:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs:' panicked at '::21214212failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_n14t\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm
:
:
note: run with RUST_BACKTRACE=1 environment variable to display a backtraceCaused by:
0: Failed to create plugin instance
1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })14',
C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs:212:14
thread '' panicked at 'failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm

Caused by:
0: Failed to create plugin instance
1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })', C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs:212:14
thread 'thread '' panicked at '' panicked at 'failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasmfailed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm

Caused by:Caused by:
0: Failed to create plugin instance 0: Failed to create plugin instancethread '
' panicked at '', 1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasmC:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs
:Caused by:C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs
212 0: Failed to create plugin instance::
14212 1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })
:', 14C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.188.0\src\plugin.rs
:212:14
error - ./node_modules/next/dist/client/dev/amp-dev.js
Error: failed to process failed to invoke plugin: failed to invoke C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm as js transform plugin at C:\Users\Hugens\Desktop\Ongoing_project\next\allodoc_next\node_modules\next-superjson-plugin\next_superjson.wasm

Caused by:
0: Failed to create plugin instance
1: Error while importing "env"."__get_transform_plugin_config": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })

Expected behavior

yarn dev should launch the project properly.

Reproduction link

No response

Version

0.2.0

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  // swcMinify: true,
  experimental: {
    swcPlugins: [
      [
        'next-superjson-plugin',
        {
          excluded: [],
        },
      ],
    ],
  },
}

module.exports = nextConfig

Additional context

No response

Pluging won't work anymore with next 13.3.1 (tested with up to canary 18)

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /app/.env.development
warn  - You have enabled experimental feature (swcPlugins) in next.config.js.
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/app/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /app/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[883]:0xe1575)
           at <unnamed> (<module>[905]:0xe6e76)
           at <unnamed> (<module>[907]:0xe8272)
           at <unnamed> (<module>[370]:0x5938e)
           at <unnamed> (<module>[442]:0x6c2b6)
           at <unnamed> (<module>[659]:0xa7b7b)
           at <unnamed> (<module>[686]:0xb3136)
           at <unnamed> (<module>[633]:0x9a0ed)
           at <unnamed> (<module>[52]:0x709c)
           at <unnamed> (<module>[51]:0x6e13)
           at <unnamed> (<module>[763]:0xbc183)
           at <unnamed> (<module>[1876]:0x1657de)
    2: heap_get_oob

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: _ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_4_FUNES2_
  12: worker
             at /home/iojs/build/ws/out/../deps/uv/src/threadpool.c:122:5
  13: start_thread
  14: clone', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.23/src/plugin.rs:219:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.37/src/impls/core/mod.rs:265:67
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("/app/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /app/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1683]:0x154169)
           at <unnamed> (<module>[1676]:0x153ec1)
           at <unnamed> (<module>[1675]:0x153e3e)
           at <unnamed> (<module>[1661]:0x15309f)
           at <unnamed> (<module>[1660]:0x152fde)
           at <unnamed> (<module>[1670]:0x15378e)
           at <unnamed> (<module>[1765]:0x159d95)
           at <unnamed> (<module>[1812]:0x160b1f)
           at <unnamed> (<module>[933]:0xf820b)
           at <unnamed> (<module>[934]:0xf837e)
           at <unnamed> (<module>[933]:0xf7c62)
           at <unnamed> (<module>[661]:0xa9181)
           at <unnamed> (<module>[659]:0xa7ac0)
           at <unnamed> (<module>[686]:0xb3136)
           at <unnamed> (<module>[633]:0x9a0ed)
           at <unnamed> (<module>[52]:0x709c)
           at <unnamed> (<module>[51]:0x6e13)
           at <unnamed> (<module>[763]:0xbc183)
           at <unnamed> (<module>[1876]:0x1657de)
    2: unreachable

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: _ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_4_FUNES2_
  12: worker
             at /home/iojs/build/ws/out/../deps/uv/src/threadpool.c:122:5
  13: start_thread
  14: clone', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.23/src/plugin.rs:219:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/app/src/pages/_app.page.tsx")'

Caused by:
    0: failed to invoke `/app/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /app/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[905]:0xe6d63)
           at <unnamed> (<module>[907]:0xe8272)
           at <unnamed> (<module>[905]:0xe7449)
           at <unnamed> (<module>[371]:0x5aac1)
           at <unnamed> (<module>[442]:0x6c34e)
           at <unnamed> (<module>[659]:0xa7b7b)
           at <unnamed> (<module>[686]:0xb3136)
           at <unnamed> (<module>[633]:0x9a0ed)
           at <unnamed> (<module>[52]:0x709c)
           at <unnamed> (<module>[51]:0x6e13)
           at <unnamed> (<module>[763]:0xbc183)
           at <unnamed> (<module>[1876]:0x1657de)
    2: heap_get_oob

Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: _ZZN4node14ThreadPoolWork12ScheduleWorkEvENUlP9uv_work_sE_4_FUNES2_
  12: worker
             at /home/iojs/build/ws/out/../deps/uv/src/threadpool.c:122:5
  13: start_thread
  14: clone', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.260.23/src/plugin.rs:219:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:224:9
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected behavior

to work as usual

Reproduction link

No response

Version

0.5.6

Config

experimental: {
      swcPlugins: [
        ["next-superjson-plugin", {}],
    },

Additional context

Looks like related to vercel/next.js#48521 and/or vercel/next.js#48098 and probably swc-project/swc#7170

dev error

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'll use superjson to solve problem vercel/next.js#13209 first.

use babel superjson that's working, bug swc plugin has error.

Expected behavior

next dev no error.

Reproduction link

No response

Version

0.4.9

Config

next.config.js

/** @type {import('next').NextConfig} */

module.exports = {
  experimental: {
    swcPlugins: [
      [
        "next-superjson-plugin",
        {
          excluded: [],
        },
      ],
    ],
  },
};

Additional context

package.json

"dependencies": {
    "@next-auth/prisma-adapter": "^1.0.5",
    "@prisma/client": "^4.6.0",
    "next": "12.2.6",
    "next-auth": "^4.16.4",
    "next-superjson-plugin": "^0.4.9",
    "prisma": "^4.6.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-markdown": "8.0.0",
    "superjson": "^1.11.0"
  },
  "devDependencies": {
    "@types/node": "18.11.9",
    "@types/react": "18.0.25",
    "ts-node": "^10.9.1",
    "typescript": "4.8.4"
  },

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2019",
    "lib": [
      "DOM",
      "DOM.Iterable",
      "ESNext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "ESNext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "baseUrl": ".",
    "paths": {
      "~/lib/*": [
        "lib/*"
      ],
      "~/components/*": [
        "components/*"
      ]
    }
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ]
}
```

Next 13 support

From what I can tell, this doesn't currently work with Next 13.

I suspect this is because it is presently only active on the pages directory.

Any chance of this being updated to support the Next 13 app directory as well?

Cannot start the app

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

CleanShot 2023-03-15 at 01 48 07

Expected behavior

I'd like to run the app

Reproduction link

repository
codesandbox link

Version

13.2.5-canary.3

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    appDir: true,
    swcPlugins: [["next-superjson-plugin", { debug: true }]],
  },
};

module.exports = nextConfig;

Additional context

No response

Plugin broke with Next 13.4.3

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

After upgrading from Next 13.4.2 to 13.4.3 the plugin is now failing for me with:

- error ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/client/dev/amp-dev.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/home/myproject/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/home/myproject/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next-superjson-plugin/dist/next_superjson.wasm` as js transform plugin at /home/myproject/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next-superjson-plugin/dist/next_superjson.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1589]:0x13100d)
           at <unnamed> (<module>[1580]:0x130d22)
           at <unnamed> (<module>[1579]:0x130ce9)
           at <unnamed> (<module>[1567]:0x12fd99)
           at <unnamed> (<module>[1566]:0x12fcc3)
           at <unnamed> (<module>[1574]:0x130357)
           at <unnamed> (<module>[1711]:0x13e280)
           at <unnamed> (<module>[1745]:0x144465)
           at <unnamed> (<module>[225]:0x2fac7)
           at <unnamed> (<module>[272]:0x46122)
           at <unnamed> (<module>[308]:0x52781)
           at <unnamed> (<module>[249]:0x381ae)
           at <unnamed> (<module>[96]:0xedd1)
           at <unnamed> (<module>[95]:0xeb96)
           at <unnamed> (<module>[765]:0xc0858)
           at <unnamed> (<module>[1846]:0x14a663)

Expected behavior

App should still run with next dev

Reproduction link

No response

Version

0.5.7

Config

// @ts-check

/**
 * @type {import('next').NextConfig}
 **/
module.exports = {
	experimental: {
		esmExternals: true,
		swcPlugins: [
			['next-superjson-plugin', {}],
		],
	},
	pageExtensions: ['page.tsx', 'page.ts'],
	reactStrictMode: true,
};

Additional context

No response

Support of non-default object types

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

Non-default object types aren't picked up and you get the following error:

  • error node_modules/.pnpm/[email protected]/node_modules/superjson/dist/transformer.js (184:0) @ Object.eval [as untransform]
  • error Error: Trying to deserialize unknown custom value
    at Array.forEach ()
    null

I followed the suggested custom recipe format and inject it near the root of my app:

import SuperJSON from 'superjson'

export function registerCustomTypes() {
  // Register Decimal as a custom type
  // Ref: https://github.com/blitz-js/superjson/pull/159/files
  SuperJSON.registerCustom<Decimal, string>(
    {
      isApplicable: (v): v is Decimal => Decimal.isDecimal(v),
      serialize: (v) => v.toJSON(),
      deserialize: (v) => new Decimal(v),
    },
    'Decimal',
  )
}

Expected behavior

The next-superjson-plugin should function the same as superjson when called directly.

Reproduction link

No response

Version

^0.5.7

Config

export default {
  reactStrictMode: true,
  swcMinify: true,
  images: {
    domains: [],
  },
  experimental: {
    appDir: true,
    serverComponentsExternalPackages: ['@prisma/client'],
    swcPlugins: [['next-superjson-plugin', {}]],
  },
}

Additional context

I was able to follow the example from Superjson on adding custom types and can use superjson directly to serialize and then parse it back to the original object, but when using data-superjson it doesn't work and I get the error above.

Plugin breaks Sentry

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

When using next-supersjon-plugin alongside @sentry/nextjs with auto server instrumentation β€” which is now part of the default Sentry configuration for Next.js β€”, the app doesn't build anymore when running yarn build:

info  - Collecting page data .Error: You can not use getInitialProps with getServerSideProps. Please remove getInitialProps.
    at /Users/igassmann/Repositories/IGassmann/error-page-autoinstrumentation/node_modules/next/dist/build/utils.js:872:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (/Users/igassmann/Repositories/IGassmann/error-page-autoinstrumentation/node_modules/next/dist/trace/trace.js:79:20)

> Build error occurred
Error: Failed to collect page data for /_error
    at /Users/igassmann/Repositories/IGassmann/error-page-autoinstrumentation/node_modules/next/dist/build/utils.js:916:15
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  type: 'Error'
}
error Command failed with exit code 1.

Expected behavior

next-supersjon-plugin shouldn't break the build.

Reproduction link

https://github.com/IGassmann/error-page-autoinstrumentation

Version

0.4.2

Config

// This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

const { withSentryConfig } = require('@sentry/nextjs');

const moduleExports = {
  experimental: {
    /**
     * Enable `superjson` experimental support for swc.
     */
    swcPlugins: [
      [
        "next-superjson-plugin", {},
      ],
    ],
  },
  reactStrictMode: true,
  swcMinify: true,
  sentry: {
    // Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
    // for client-side builds. (This will be the default starting in
    // `@sentry/nextjs` version 8.0.0.) See
    // https://webpack.js.org/configuration/devtool/ and
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
    // for more information.
    hideSourceMaps: true,
    widenClientFileUpload: true,
    autoInstrumentServerFunctions: true,

    // Disable SentryWebpackPlugin so that the project can build without Sentry CLI token
    disableClientWebpackPlugin: true,
    disableServerWebpackPlugin: true,
  },
};

// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(moduleExports);

Additional context

The issue is also reported on Sentry Javascript repository: getsentry/sentry-javascript#5904

server gets terminated when I use swcplugin

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

After installing & configuring in next.config.js when I restart the server and try to access page, the server gets terminated without any error logs.

Expected behavior

Expecting serialization works properly

Reproduction link

No response

Version

^0.6.2

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  experimental: {
    swcPlugins: [
      [
        "next-superjson-plugin",
        {
          excluded: [],
        },
      ],
    ],
  },
};

export default nextConfig;

Additional context

No response

Children are undefined in client components rendered by RSCs

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

It seems that children passed to Client components with data-superjson attributes are not present in the client component?

Expected behavior

I would expect children to be passed through transparently to the Client component as it is without the superjson integration.

Reproduction link

https://github.com/samtgarson/appdir-reproduction-app/tree/superjson

Version

0.5.3

Config

/** @type {import("next").NextConfig} */
module.exports = {
  reactStrictMode: true,
  experimental: {
    appDir: true,
    swcPlugins: [["next-superjson-plugin", { excluded: ["children"] }]],
  },
};


(Have tried with and without the `excluded` option)

Additional context

No response

Plugin does not appear to be working from nested Server Components

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

When I render a Client Component within a "top-level" Server Component (a page.tsx) in Next.js 13 (app directory) the plugin works like a charm.

However, when I render (let's say) a Server Component within another Server Component and render a Client Component within the first Server Component, the plugin does not seem to work.

This works:

// page.tsx
export default function Page() {
  const object = {
    date: new Date(),
    name: "Whatever",
  };

  return <ClientComponent data={object} data-superjson />;
}

This does not:

// page.tsx
export default function Page() {
  const object = {
    date: new Date(),
    name: "Whatever",
  };

  return <ServerComponent data={object} />;
}


// ServerComponent.tsx
export default function ServerComponent({ object }) {
  return <ClientComponent data={object} data-superjson />;
}

I have verified that typeof object.date returns object within ServerComponent.tsx, but within ClientComponent.tsx it's turned into a string with Next.js complaining about passing a non-plain object from a Server Component to a Client Component. This warning is eliminated using this plugin in the first example.

Expected behavior

I expect the data to be passed through as-is to the different Server Components (which it is) and handled by this plugin the moment it reaches a Client Component (this does not happen).

Reproduction link

No response

Version

0.5.3

Config

I'm not passing in any options.

Additional context

I've tried setting the data-superjson attribute on the entire component trail, but that's not solving the issue (it is, in fact, breaking my entire app).

I don't currently have a reproduction repo but I can create one if necessary.

getLayout

Describe the bug

when using getLayout function causes a full reload and the layout wont load.
instead of using function using the layout as component won't cause any problem.

Home.getLayout = (page) => { return <PrimaryLayout>{page}</PrimaryLayout> }

Expected behavior

Not performing a full reload and be able to render the layout component.

Reproduction link

No response

Version

0.3.0

Config

No response

Additional context

No response

Integration with @nrwl/nx

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'm trying to implement this with a next.js project generated with nx.

Expected behavior

I'm still getting the same serialization error.

It gave the error that its picking up the swc config too: warn - You have enabled experimental feature (swcPlugins) in next.config.js..

If I update the string to something random, it throws an error, so that means it is running that swc plugin code I think.

Reproduction link

https://github.com/shawnmclean/next-superjson-nx

Version

0.5.4

Config

//@ts-check

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withNx } = require('@nrwl/next/plugins/with-nx');

/**
 * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
 **/
const nextConfig = {
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]],
  },
  nx: {
    // Set this to true if you would like to to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: false,
  },
};

module.exports = withNx(nextConfig);

Additional context

No response

Segmentation fault

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I've installed a clean Next.js using TypeScript:

  • Linux Mint 20.2
  • Node 16
  • Next.js 12

After installing the plugin I receive

Segmentation fault (core dumped)

As soon as I open the app.

I'm not really sure if this is related to #34, but I got a lot of thread panics while using TypeScript path aliases. After getting rid of them the said error remains.

Expected behavior

It shouldn't die.

Reproduction link

https://github.com/nehalist/next-superjson-plugin-issue

Version

0.4.8

Config

No response

Additional context

No response

Plugin broke with Next 13.4.4

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

After upgrading from Next 13.4.3 to 13.4.4 using next-superjson-plugin now throws the following error during build:

- error ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/client/dev/amp-dev.js
Error: Filesystem cache is not enabled, cannot read plugin from phsyical path
- wait compiling...
- error ./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next/dist/client/dev/amp-dev.js
Error: Filesystem cache is not enabled, cannot read plugin from phsyical path

Looks like that error is coming from swc but I'm not sure what changed between 13.4.3 and 13.4.4 that could use that.

Expected behavior

App should still run with next dev

Reproduction link

No response

Version

0.5.8

Config

// @ts-check

/**
 * @type {import('next').NextConfig}
 **/
module.exports = {
	experimental: {
		esmExternals: true,
		swcPlugins: [
			['next-superjson-plugin', {}],
		],
	},
	pageExtensions: ['page.tsx', 'page.ts'],
	reactStrictMode: true,
};


### Additional context

_No response_

SWC plugin doesn't deserialise props, however serialisation works fine

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

The plugin auto serialised props while returning from getServerSideProps, this works as expected.

return {
  props: {
    dataToBeSerialized,
  },
}

However in side of the component prop, it's not deserialising the props. The date fields are still in string inside the component.

Expected behavior

As per the doc it should auto deserialise as well, so will expect the date date fields to be Date instead of string

Reproduction link

No response

Version

SWC plugin: 0.5.6 SuperJSON: 1.12.2

Config

const nextConfig = {
  pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

Additional context

I have tested it in Next latest stable and canary version

Dev/Build thread panic error introduced with v0.6.2

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

Upgrading from 0.6.1 to 0.6.2 introduced this bug that prevent execution both during next dev and next build:

With next.js 14.1.0:
thread '' panicked at C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\rkyv-0.7.42\src\impls\core\mod.rs:267:17:
assertion failed: !result.is_null()

With latest canary release:
thread '' panicked at C:\Users\Administrator.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmer-wasix-0.18.0\src\runtime\task_manager\tokio.rs:105:19:
there is no reactor running, must be called from the context of a Tokio 1.x runtime

Expected behavior

Dev and Build running without error

Reproduction link

No response

Version

14.1.0 and 14.1.1-canary.52

Config

const nextConfig = {
  output: 'standalone',
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]]
  }
}


### Additional context

Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Binaries:
Node: 20.11.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.1.1-canary.52 // Latest available version is detected (14.1.1-canary.52).
eslint-config-next: 14.1.0
react: 18.2.0
react-dom: 18.2.0
typescript: 5.3.3
Next.js Config:
output: standalone

Error serializing with getStaticPaths

Hi @orionmiz and Thanks for make king-wang-zzang (very wonderful) package :)
However, When I getStaticPaths with NextJS 12.2.4, It's throws SerializableError It came from looks like not serializing

Is that expected behavior? And Can you know how to fix it?
Thank you :)

Build fails w/ swc transform "RuntimeError: unreachable"

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

  1. Install next-superjson-plugin
  2. Build the application
  3. Watch the build fail

Initially reported at nextjs, see vercel/next.js#61432, where it was pointed out to be an issue with the superjson plugin.

Expected behavior

build does not fail

Reproduction link

https://github.com/aplr/next_swc_plugin_issue

Version

14.1.1-canary.27

Config

No response

Additional context

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 21.5.0
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: 8.14.1
Relevant Packages:
  next: 14.1.1-canary.25 // Latest available version is detected (14.1.1-canary.25).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A
Error log

thread 'thread 'thread 'thread '' panicked at '' panicked at '' panicked at 'called Result::unwrap() on an Err value: LayoutErrorcalled Result::unwrap() on an Err value: LayoutErrorcalled Result::unwrap() on an Err value: LayoutError', ', ' panicked at '', called Result::unwrap() on an Err value: LayoutError/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs:::', 266266/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs:266:::6767266
:6767note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/server/future/route-modules/app-page/module.compiled.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
stack backtrace:
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_document.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_app.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
thread '' panicked at stack backtrace:
/Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_error.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
thread '' panicked at 'called Result::unwrap() on an Err value: LayoutError', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs:thread 'thread '266:' panicked at 'called Result::unwrap() on an Err value: LayoutError67', ' panicked at '
/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rscalled Result::unwrap() on an Err value: LayoutErrornote: run with RUST_BACKTRACE=1 environment variable to display a backtrace
:thread '', 266/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs::' panicked at '266called Result::unwrap() on an Err value: LayoutError:67thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
', failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/client/components/not-found-error.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
67
stack backtrace:
/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
:266note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
:67
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/client/components/error-boundary.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/server/future/route-kind.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
thread 'stack backtrace:
' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/server/app-render/entry-base.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
thread 'thread 'thread '' panicked at '' panicked at '' panicked at 'called Result::unwrap() on an Err value: LayoutErrorcalled Result::unwrap() on an Err value: LayoutErrorcalled Result::unwrap() on an Err value: LayoutError', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs::266266:67:',
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
67
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs:thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs266thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162::14162:
:failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/client.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
:stack backtrace:
14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/tools.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
67note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

stack backtrace:
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/server/future/route-modules/app-page/vendored/rsc/react-jsx-runtime.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
thread '' panicked at 'called Result::unwrap() on an Err value: LayoutError', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rkyv-0.7.42/src/impls/core/mod.rs:266:67
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread '' panicked at /Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.272.4/src/plugin.rs:162:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/app/now.tsx")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:
stack backtrace:
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.
Failed to compile.

./node_modules/next/dist/pages/_app.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_app.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2:
3:

./node_modules/next/dist/pages/_document.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_document.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2:
3:

./node_modules/next/dist/pages/_error.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/pages/_error.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2:
3:

Import trace for requested module:
./node_modules/next/dist/pages/_error.js

./app/now.tsx
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/app/now.tsx")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2:
3:

Import trace for requested module:
./app/now.tsx
./app/page.tsx

./node_modules/next/dist/client/components/error-boundary.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next/dist/client/components/error-boundary.js")'

Caused by:
0: failed to invoke /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm as js transform plugin at /Users/andreas/Developer/playground/next_swc_plugin_issue/node_modules/next-superjson-plugin/dist/next_superjson.wasm
1: RuntimeError: unreachable

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2: _BrotliDecoderVersion
3: _BrotliDecoderVersion
4: _BrotliDecoderVersion
5: _BrotliDecoderVersion
6: _BrotliDecoderVersion
7:
8: _BrotliDecoderVersion
9: _BrotliDecoderVersion
10: _BrotliDecoderVersion
11: _BrotliDecoderVersion
12:
13:
14:
15:
16:
17:
18:

Stack backtrace:
0: _napi_register_module_v1
1: _napi_register_module_v1
2:
3:

Jest Error: Cannot find module 'next-superjson-plugin/tools'

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

After upgrading from 0.4.x to 0.5.6 I get an error when trying to run my test with Jest.

After investigation, it seems that this plugin adds an import to my pages. The import seems to be:

import { withSuperJSONPage as _withSuperJSONPage } from "next-superjson-plugin/tools";

In PR 57, there seems to have been a change too how the library is packaged. This leads to a case where the typescript resolver cannot resolve next-superjson-plugin/tools anymore.

I verified this by trying to import from this module path manually, which failed. The only path I can import from is next-superjson-plugin/dist/tools

PLEASE NOTE: Building the actual application still works and I believe this is due to exports configuration in your package.json. The bug is only related to type resolution with TypeScript

Expected behavior

I would expect that after the upgrade to v5, module resolution in TypeScript still works like before.

I think the package.json has to be adapted to reflect the new folder layout for TypeScript module resolution.

Reproduction link

No response

Version

0.5.6

Config

No response

Additional context

No response

in a custom app getInitialProps the first own prop is [Function: withSuperJSON] instead of the value

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'm trying to return props from a custom app getInitialProps function. But for some reason the first own property is always [Function: withSuperJSON] instead of the actual property.

Example here:
https://github.com/neotrow/next-superjson-test/blob/main/pages/_app.tsx#L30

Expected behavior

I would expect the above mentioned console log to be
ownProps { prop1: 'foo', prop2: 'bar', prop3: 'baz' }
and not
ownProps { prop1: [Function: withSuperJSON], prop2: 'bar', prop3: 'baz' }

Reproduction link

https://github.com/neotrow/next-superjson-test

Version

0.5.9

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

module.exports = nextConfig;

Additional context

No response

Cannot access displayName.valueOf on the server

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I use this plugin very heavily in a small production app, thanks for the OSS!

Trying to upgrade to Next 14 and any RSCs with the data-superjson attribute anywhere in their tree completely error out, with the following error:

 β¨― Error: Cannot access displayName.valueOf on the server. You cannot dot into a client module from a server component. You can only pass the imported name through.

I have been able to narrow this down with pretty high confidence to this plugin, although it's very difficult to debug.

Some research indicates that this issue can display in Next.js when arrays of children are rendered on the server without a key prop (e.g.). I have been seeing #70 for a long time throughout my app, although it's been ignorable but this doesn't seem to be a coincidenceβ€”I wonder if it's possible that the key attribute is getting lost through this plugin.

(I do still get the Warning: Each child in a list should have a unique "key" prop stacktrace next to the above error)

Expected behavior

The page does not explode and the plugin works as described.

Reproduction link

Not available but I can add users to a private repo if it would help

Version

superjson 1.13.3, next-superjson-plugin 0.5.10, next 14.0.3

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]],
    serverActions: true,
    serverActionsBodySizeLimit: '2mb',
    serverComponentsExternalPackages: ['mjml', 'sharp']
  },
  transpilePackages: ['shared', 'database', 'email', 'core'],
  images: {
    unoptimized: true,
    minimumCacheTTL: 60 * 60 * 24 * 90, // 90 days
    remotePatterns: [
      {
        protocol: 'https',
        hostname: new URL(process.env.S3_DOMAIN).hostname
      }
    ]
  }
}

Additional context

As mentioned, this is very difficult to debug without a real stack trace, the error points at the parent of the data-superjson element, so any advice in debugging this further and I would be happy to investigate myself.

Error serializing with imported getServerSideProps

hi @orionmiz and thank you for the plugin, it works perfectly when getServerSideProps sits on the same page file.

However, I am importing a common getServerSideProps from ../utils/getServerSideProps.tsx and it that case the seralisation does not happen:

error - SerializableError: Error serializing `.fallback["/api/state"].createdAt` returned from `getServerSideProps` in "/".

Is that the intended behaviour? Is there a way to add a path to be processed?

Thank you

`Module not found: ESM packages (superjson) need to be imported.` in Next.js 14.0.4

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I'm encountering a 'Module not found' error related to ESM package handling in Next.js 14.04. The issue arises when trying to use the 'superjson' package in my project.

./node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/next-superjson-plugin/dist/tools.js:65:18
Module not found: ESM packages (superjson) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./src/app/posts/page.tsx

Expected behavior

no error occurs.

Reproduction link

No response

Version

[email protected], [email protected], [email protected]

Config

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    swcPlugins: [["next-superjson-plugin", {}]],
  },
};

module.exports = nextConfig;

Additional context

No response

SWC should transform pageProps from _app.tsx

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

In order to use patterns like react-query prefetch, the transform must happen in _app.tsx, as well as in the specific pages.

In this and other common patterns, _app.tsx may be passing some pageProps into global providers.

As it is currently, pageProps will be passed into global providers untransformed, leading to difficult to solve bugs.

export default function App({ Component, pageProps }: AppProps) {

     return ( <QueryClientProvider client={rssQueryClient}>
        <Hydrate state={pageProps.dehydratedState}>
              <Component {...pageProps} />
        </Hydrate>
      </QueryClientProvider>);
}

Expected behavior

I would expect pageProps to be transformed when received by _app.tsx

Reproduction link

No response

Version

"next-superjson-plugin": "^0.5.6"
"superjson": "^1.12.2",

Config

const nextConfig = {
  experimental: {
    swcPlugins: [
      [
        'next-superjson-plugin',
        {
          excluded: []
        }
      ]
    ]
  },
  output: 'standalone'
};

Additional context

An easy workaround for the time being is to do something like

  const fixedPageProps = useMemo(() => superjson.deserialize({
    json: pageProps,
    meta: pageProps._superjson
  }) as AppProps["pageProps"], [pageProps]);

and use fixedPageProps where pageProps would be inserted normally. Hopefully this is helpful for someone, though I do feel strongly that this should be solved by the SWC as default behavior.

thread '<unnamed>' panicked at 'failed to register unwind information'

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

Disclaimer - I wasn't able to verify this bug on next@canary, since switching to it resulted in all kinds of other unrelated issues.

Basically, adding next-superjson-plugin causes the build using npm run build to break. It still works as intended during development. Just making the production build is what fails.

This is the Docker file I use for building:

# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
RUN \
  if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
  elif [ -f package-lock.json ]; then npm ci; \
  elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
  else echo "Lockfile not found." && exit 1; \
  fi

# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG ENV_FILE
COPY ${ENV_FILE} .env.production

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1

# RUN yarn build

# If using npm comment out above and use below instead
RUN npm run build

# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app

ARG NODE_ENV_OVERRIDE
ENV NODE_ENV ${NODE_ENV_OVERRIDE}

# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]

Expected behavior

The build should not crash.

Reproduction link

No response

Version

NextJS 12.3.1, plugin - 0.4.2

Config

experimental: {
    swcPlugins: [
      [
        'next-superjson-plugin',
        {
          excluded: []
        }
      ]
    ]
  }

Additional context

Full build log:

#16 0.669
#16 0.669 > [email protected] build
#16 0.669 > next build
#16 0.669
#16 0.918 info  - Loaded env from /app/.env.production
#16 0.918 info  - Loaded env from /app/.env
#16 1.044 warn  - You have enabled experimental feature (swcPlugins) in next.config.js.
#16 1.044 warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
#16 1.044
#16 1.059 Attention: Next.js now collects completely anonymous telemetry regarding usage.
#16 1.059 This information is used to shape Next.js' roadmap and prioritize features.
#16 1.059 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
#16 1.059 https://nextjs.org/telemetry
#16 1.060
#16 1.151 info  - Linting and checking validity of types...
#16 7.073 info  - Creating an optimized production build...
#16 7.965 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 7.965 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#16 8.035 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.049 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.062 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.075 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.088 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.102 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.116 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.130 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.142 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.155 thread '<unnamed>' panicked at 'failed to register unwind information: "unsupported unwind information"', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-engine-universal-2.3.0/src/code_memory.rs:199:18
#16 8.409 Failed to compile.
#16 8.409
#16 8.409 ./node_modules/next/dist/pages/_error.js
#16 8.409 Error: failed to process failed to register unwind information: "unsupported unwind information"
#16 8.409
#16 8.409 ./src/pages/_app.tsx
#16 8.409 Error: failed to process failed to register unwind information: "unsupported unwind information"
#16 8.409
#16 8.409 ./src/pages/_document.tsx
#16 8.409 Error: failed to process failed to register unwind information: "unsupported unwind information"
#16 8.409
#16 8.409 ./src/pages/admin/lottery.tsx
#16 8.409 Error: failed to process failed to register unwind information: "unsupported unwind information"
#16 8.409
#16 8.409 ./src/pages/game/[game].tsx
#16 8.409 Error: failed to process failed to register unwind information: "unsupported unwind information"
#16 8.409
#16 8.410
#16 8.410 > Build failed because of webpack errors
#16 8.437 npm notice
#16 8.437 npm notice New minor version of npm available! 8.15.0 -> 8.19.2
#16 8.438 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
#16 8.438 npm notice Run `npm install -g [email protected]` to update!
#16 8.438 npm notice

thread '<unnamed>' panicked at 'failed to invoke plugin

Hello, I have migrated to Ubuntu OS and I'm getting bellow error.

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/media/.../node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/media/.../node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /media/.../node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[329]:0x62a25)
           at <unnamed> (<module>[355]:0x6bd6b)
           at <unnamed> (<module>[357]:0x6d15e)
           at <unnamed> (<module>[41]:0xc3fb)
           at <unnamed> (<module>[105]:0x1cf8d)
           at <unnamed> (<module>[158]:0x343b0)
           at <unnamed> (<module>[183]:0x3c8ce)
           at <unnamed> (<module>[124]:0x2332b)
           at <unnamed> (<module>[751]:0xd2250)
           at <unnamed> (<module>[750]:0xd1fe1)
           at <unnamed> (<module>[589]:0xaf798)
    2: heap_get_oob', /usr/local/cargo/registry/src/github.com-.../src/plugin.rs:216:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error Command failed with exit code 1.

out of bounds memory access

Describe the bug

I get a out of bounds memory access on 0.4.2:

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `/node_modules/next-superjson-plugin/next_superjson.wasm` as js transform plugin at /node_modules/next-superjson-plugin/next_superjson.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[329]:0x62a25)
           at <unnamed> (<module>[355]:0x6bd6b)
           at <unnamed> (<module>[357]:0x6d15e)
           at <unnamed> (<module>[41]:0xc3fb)
           at <unnamed> (<module>[105]:0x1cf8d)
           at <unnamed> (<module>[158]:0x343b0)
           at <unnamed> (<module>[183]:0x3c8ce)
           at <unnamed> (<module>[124]:0x2332b)
           at <unnamed> (<module>[751]:0xd2250)
           at <unnamed> (<module>[750]:0xd1fe1)
           at <unnamed> (<module>[589]:0xaf798)
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1]    31891 bus error  npm run dev

If I add RUST_BACKTRACE=1 to my .zshrc it simply returns:

[1]    32614 bus error  npm run dev

Expected behavior

Run without failure

Reproduction link

No response

Version

0.4.2

Config

No response

Additional context

MacBook Pro (Retina, 15-inch, Mid 2015)
MacOS 12.6

unable to resolve dependency tree

Describe the bug

Yo updated my package.json with "next-superjson-plugin": "^0.4.2", (and "next": "^12.3.0",). This is what I get:

npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/next
npm ERR!   next@"^12.3.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer next@">12.3.0" from [email protected]
npm ERR! node_modules/next-superjson-plugin
npm ERR!   next-superjson-plugin@"^0.4.2" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

--force does not help. Am I missing something?

Expected behavior

to install next-superjson-plugin 0.4.2 with the canary version of next (12.3.0).

Reproduction link

No response

Version

0.4.2

Config

No response

Additional context

No response

Error: next tried to access next-superjson-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

getting this error:

error - ../../.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/pages/_document.js
Error: next tried to access next-superjson-plugin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: next-superjson-plugin
Required by: next@virtual:e293270790bda2411a3626e57e15862403457209cbe755a222c752c37c8f53870ac5708914fca9c46ad11f81505a4af613c8b5e4bba765909191bb5f14d3b656#npm:13.0.6-canary.0 (via monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/build/swc/)

Require stack:
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/build/swc/options.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/build/swc/index.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/build/output/store.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/build/output/index.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/cli/next-dev.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/lib/commands.js
- monorepo/.yarn/__virtual__/next-virtual-aa7c738504/0/cache/next-npm-13.0.6-canary.0-a5832376b0-6f9e3bc3ce.zip/node_modules/next/dist/bin/next
    at Array.map (<anonymous>)`

### Expected behavior

no errors :)


### Reproduction link

_No response_

### Version

0.4.9

### Config

```javascript
/** @type {import('next').NextConfig} */
const nextConfig = {
	reactStrictMode: true,
	swcMinify: true,
	experimental: {
		swcPlugins: [
			[
				"next-superjson-plugin",
				{
					excluded: [],
				},
			],
		],
	},
};

module.exports = nextConfig;

Additional context

i have a monorepo using yarn workspaces, yarn 3 & pnp

deps of this particular workspace

"dependencies": {
		"@types/node": "18.11.9",
		"@types/react": "18.0.25",
		"@types/react-dom": "18.0.9",
		"cldr": "^7.3.0",
		"database": "workspace:*",
		"firebase": "^9.14.0",
		"firebase-admin": "^11.3.0",
		"next": "canary",
		"next-firebase-auth": "canary",
		"next-superjson-plugin": "^0.4.9",
		"react": "18.2.0",
		"react-dom": "18.2.0",
		"superjson": "^1.11.0",
		"typescript": "4.9.3",
		"winston": "^3.8.2"
	},
``

Each child in a list should have a unique "key" prop.

Verify Next.js canary release

  • I verified that the issue exists in the latest Next.js canary release

Describe the bug

I see the Each child in a list should have a unique "key" prop. warning message on the client side on multiple occassions, basically every
I figured out, that is, because I'm feeding the data to the react context api.

    <DocumentListContextProvider
      documents={documents}
      data-superjson
    >
        <div />
        <SomeServerComponentSvg />
        <SomeClientComponentAccessingContext />
    </DocumentListContextProvider>

Which components are affected?
Apparently the warning appears for every node where there are more than 1 children. That goes for normal components as well as plain jsx.

A full error log:

hydration-error-info.js?7847:27 Warning: Each child in a list should have a unique "key" prop. See https://reactjs.org/link/warning-keys for more information.
    at div
    at DocumentListContextProvider (webpack-internal:///(app-client)/./app/(index)/documents/document-list-context.tsx:25:11)
    at WithSuperJSON (webpack-internal:///(app-client)/../../node_modules/next-superjson-plugin/dist/tools.js:153:55)
    at SuperJSONComponent (webpack-internal:///(app-client)/../../node_modules/next-superjson-plugin/dist/client.js:18:24)
    at ScrollAndFocusHandler (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:153:1)
    at InnerLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:195:11)
    at RedirectErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:361:9)
    at RedirectBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:368:11)
    at NotFoundBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:404:11)
    at LoadingBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:317:11)
    at ErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/error-boundary.js:72:11)
    at RenderFromTemplateContext (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/render-from-template-context.js:12:34)
    at OuterLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:23:11)
    at div
    at ScrollAndFocusHandler (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:153:1)
    at InnerLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:195:11)
    at RedirectErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:361:9)
    at RedirectBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:368:11)
    at NotFoundBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:404:11)
    at LoadingBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:317:11)
    at ErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/error-boundary.js:72:11)
    at RenderFromTemplateContext (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/render-from-template-context.js:12:34)
    at OuterLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:23:11)
    at div
    at div
    at ScrollAndFocusHandler (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:153:1)
    at InnerLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:195:11)
    at RedirectErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:361:9)
    at RedirectBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:368:11)
    at NotFoundErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:397:9)
    at NotFoundBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:404:11)
    at LoadingBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:317:11)
    at ErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/error-boundary.js:72:11)
    at RenderFromTemplateContext (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/render-from-template-context.js:12:34)
    at OuterLayoutRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/layout-router.js:23:11)
    at body
    at html
    at ReactDevOverlay (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/react-dev-overlay/internal/ReactDevOverlay.js:61:9)
    at HotReload (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/react-dev-overlay/hot-reloader-client.js:20:11)
    at Router (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/app-router.js:48:11)
    at ErrorBoundaryHandler (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/error-boundary.js:59:9)
    at ErrorBoundary (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/error-boundary.js:72:11)
    at AppRouter (webpack-internal:///(app-client)/../../node_modules/next/dist/client/components/app-router.js:24:13)
    at ServerRoot (webpack-internal:///(app-client)/../../node_modules/next/dist/client/app-index.js:147:11)
    at RSCComponent
    at Root (webpack-internal:///(app-client)/../../node_modules/next/dist/client/app-index.js:164:11)

I am using the 13.2.4-canary.8 version of next.

Expected behavior

I expect to see no warning about missing unique key props

Reproduction link

No response

Version

0.5.6

Config

module.exports = {
  reactStrictMode: true,
  experimental: {
    appDir: true,
    swcPlugins: [
      [ 'next-superjson-plugin', {} ]
    ]
  },
  async redirects() {
    return [
      {
        source: '/',
        destination: '/documents',
        permanent: true,
      },
    ]
  },
  transpilePackages: ['ui'],
};

Additional context

File
document-list-context.tsx

'use client';

import type { Dispatch, ReactNode } from 'react';
import { createContext, useReducer } from 'react';
import type { DocumentRevisionModel } from 'api-client';

export enum DocumentListContextActionKind {
  SetDocuments = 'setDocuments',
  AddDocument = 'addDocument',
}

export type DocumentListContextAction =
  | {
      type: DocumentListContextActionKind.SetDocuments;
      documents: Array<DocumentRevisionModel>;
    }
  | {
      type: DocumentListContextActionKind.AddDocument;
      document: DocumentRevisionModel;
    };

export interface DocumentListContextState {
  documents: Array<DocumentRevisionModel>;
}

export interface DocumentListContextInterface extends DocumentListContextState {
  documents: Array<DocumentRevisionModel>;
  dispatch: Dispatch<DocumentListContextAction>;
}

export const DocumentListContext = createContext<DocumentListContextInterface>({
  documents: [],
  dispatch: () => {
    throw new Error('DocumentListContext not initialized');
  },
});

interface DocumentListContextProviderProps {
  children: ReactNode;
  initialDocuments?: Array<DocumentRevisionModel>;
}

export function DocumentListContextProvider({
  children,
  initialDocuments = [],
}: DocumentListContextProviderProps) {
  const [state, dispatch] = useReducer(
    (state: DocumentListContextState, action: DocumentListContextAction) => {
      switch (action.type) {
        case DocumentListContextActionKind.SetDocuments:
          return {
            ...state,
            documents: action.documents,
          };
        case DocumentListContextActionKind.AddDocument:
          return {
            ...state,
            documents: [...state.documents, action.document],
          };
        default:
          return state;
      }
    },
    {
      documents: initialDocuments,
    },
  );

  return (
    <DocumentListContext.Provider
      value={{
        documents: state.documents,
        dispatch,
      }}
    >
      {children}
    </DocumentListContext.Provider>
  );
}

File
page.tsx

export default async function Page() {
  const apiConfiguration = createConfiguration({
    baseServer: new ServerConfiguration('http://localhost:3001', {}),
  });
  const documentsApi = new DocumentsApi(apiConfiguration);
  const documents = await documentsApi.documentsControllerList();

  return (
    <DocumentListContextProvider
      initialDocuments={documents.documents.map((document) => ({
        ...document,
      }))}
      data-superjson
    >
      {/* both will warn on this layer*/}
      <div />
      <div>
        <div>this div will not warn because there is only one child</div>
      </div>
    </DocumentListContextProvider>
  );
}
    ```

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

Verify Next.js canary release

  • I verified that the issue exists in the latest 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)

getInitialProps is not supported

Describe the bug

getInitialProps is not the recommended way of passing props to components anymore, but it has not been deprecated. I think this plugin should support it.

Expected behavior

The getInitialProps output should be converted to SuperJson.

Reproduction link

No response

Version

0.3.0

Config

module.exports = {
	reactStrictMode: true,
	swcMinify: true,
	experimental: {
		swcPlugins: [
			[
				"next-superjson-plugin",
				{
					excluded: [],
				},
			],
		],
	},
}

Additional context

No response

Missing export __get_transform_plugin_core_pkg_diag

Describe the bug

When enabling the plugin the terminal returns:

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../node_modules/next/dist/client/next-dev.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
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("/Users/.../node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../node_modules/next/dist/client/router.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../src/pages/_app.tsx")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../node_modules/next/dist/pages/_error.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
thread 'thread '<unnamed>' panicked at '<unnamed>failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../src/pages/_app.tsx")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag' panicked at '', failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../src/pages/_document.tsx")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs', :/Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216216::1414

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../node_modules/next/dist/pages/_error.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.224.0/src/plugin.rs:216:14
error - ./node_modules/next/dist/client/dev/amp-dev.js
Error: failed to process failed to invoke plugin: failed to invoke plugin on 'Some("/Users/.../node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    Missing export __get_transform_plugin_core_pkg_diag

Expected behavior

Not throw error

Reproduction link

No response

Version

0.4.1

Config

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  experimental: {
    swcPlugins: [['next-superjson-plugin', {}]],
  },
};

module.exports = nextConfig;

Additional context

Next 12.3.0

Build fails on Vercel sporadically

Describe the bug

Next.js build fails on Vercel sporadically with many errors looking as such:

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("/vercel/path0/pages/auth/login.tsx")'

Caused by:
  0: Failed to create plugin instance
  1: missing requires CPU features: "EnumSet(AVX512DQ | AVX512VL | AVX512F)"', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.212.1/src/plugin.rs:222:14

Expected behavior

The build should always run successfully.

Reproduction link

No response

Version

0.4.0

Config

{
  experimental: {
    esmExternals: "loose",
    swcPlugins: [
      [
        "next-superjson-plugin",
        {
          excluded: [],
        },
      ],
    ],
  },
  webpack: (config, context) => {
    config.resolve.fallback = { fs: false }

    return config
  },
}

Additional context

Next.js version: 12.2.5

I believe this error happens when the host machine that is building the project on Vercel has a CPU that doesn’t have either of those features: AVX-512DQ, AVX-512VL, or AVX-512F. Since Vercel might use different host machines for each build, this would explain why it would fail sporadically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.