blitz-js / next-superjson-plugin

SuperJSON Plugin for Next.js Pages and Components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to build after installing next-superjson-plugin

louishugens opened this issue · comments

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

Thanks for reporting!

What is the version of Next.js?

I was also getting that error on version 12.2.1-canary.1. Upgraded to 12.2.5 and now it works. Thanks!

@louishugens Try to upgrade your Next.js version to latest as @felipeptcho said.

SWC seems to be fixing some bugs by changing its internal APIs, and it also affects to the plugin system of Next.js.

So keep your Next.js version to be newest to avoid troublesome errors like you met.

It is working fine after upgrading to version next@12.2.5. Thanks @orionmiz and @felipeptcho.