arlyon / stailwc

Tailwind in SWC, Nextjs, and Vite, fast 🚀
https://npmjs.com/package/stailwc
Apache License 2.0
230 stars 3 forks source link

Error in Next.js 13.4.4 using the app router #36

Closed gpoole closed 1 year ago

gpoole commented 1 year ago

I've used the following config with Next.js 13.4.4 and the app router:

const stailwc = require('stailwc/install')

/** @type {import('next').NextConfig} */
const nextConfig = {
  swcMinify: true,
  compiler: {
    styledComponents: true
  },
  experimental: {
    swcPlugins: [stailwc()]
  }
}

module.exports = nextConfig

I get the following error from Next trying to load a page:

- error ./node_modules/next/dist/pages/_app.js
Error: Filesystem cache is not enabled, cannot read plugin from phsyical path
gpoole commented 1 year ago

This particular error seems to be related to https://github.com/vercel/next.js/pull/50651 which seems to have changed in 13.4.* and it looks like they'll be releasing a fix soon.

I tried rolling Next.js back to 13.0.1 since that's listed as the supported version, but I'm now seeing this:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:/home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs266:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
:266:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<removed>/node_modules/next/dist/client/app-next-dev.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: out of bounds memory access
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<removed>/node_modules/next/dist/client/next-dev.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: out of bounds memory access
    2: heap_get_oob', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<removed>/node_modules/next/dist/client/dev/amp-dev.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<removed>/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266: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("<removed>/node_modules/next/dist/pages/_error.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266: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("<removed>/node_modules/next/dist/pages/_app.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266: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("<removed>/node_modules/next/dist/pages/_app.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266: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("<removed>/node_modules/next/dist/pages/_error.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: LayoutError', /home/arlyon/.cargo/registry/src/github.com-1ecc6299db9ec823/rkyv-0.7.42/src/impls/core/mod.rs:266: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("<removed>/node_modules/next/dist/pages/_document.js")'

Caused by:
    0: failed to invoke `<removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm` as js transform plugin at <removed>/node_modules/stailwc/target/wasm32-wasi/release/stailwc.wasm
    1: RuntimeError: call stack exhausted
    2: stk_ovf', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc-0.232.53/src/plugin.rs:228:14

I'm running macOS Monterey 12.6.3 on an M1 Mac.

arlyon commented 1 year ago

Hi! I am assuming you are using the default emotion engine, which currently is not supported with serverside rendering using the app router. Please see this for more info. https://github.com/emotion-js/emotion/issues/2928

If you decide to use client side rendering, I am releasing a new version today (0.17.0) and have verified that all the examples work so have a look at the readme on master for the relevant versions (or the examples) and let me know if they work for you.

gpoole commented 1 year ago

Hi @arlyon! I'm using styled components on this project and as far as I can tell emotion shouldn't have been enabled.

I've tried installing Next 13.4.3 following the latest readme and it all works now. I'm not sure what the issue could have been though, since I'm certain I tried that version of Next before opening this issue. I'll close since it's fixed now.

Thanks for following up and thanks for your work on this project!