lingui / swc-plugin

A SWC Plugin For LinguiJS
https://www.npmjs.com/package/@lingui/swc-plugin
MIT License
64 stars 13 forks source link

support @swc/core@1.4.x #88

Closed ouzhou closed 7 months ago

ouzhou commented 7 months ago

hi 1 hope to support @swc/core@1.4.x

2 maybe add dependencies in swc-plugin/package.json to lock version of swc ,like this

  "dependencies": {
    "@swc/core": "^1.3.107"
  }

rather than write this in package.json

  "resolutions": {
    "@swc/core": "1.3.105"
  },
image
timofei-iatsenko commented 7 months ago

I don't build a version with a newer swc_core for a reason. I keep latest version of the plugin working with latest version of nextjs. Unfortunately, latest version of nextjs still sits within v0.82.x - v0.87.x

maybe add dependencies in swc-plugin/package.json to lock version of swc ,like this

it's not possible since they do not follow semver for now and range is open-ended. When they deploy a newer version i will not be able to "close" the range for already published package.

If you're blocked by this, you can build the plugin from sources and add a ready to use binary to your repository. Unfortunately, there is no better way to support all users for now.

ouzhou commented 7 months ago

@thekip https://github.com/vercel/next.js/pull/63790

timofei-iatsenko commented 7 months ago

Cool, let's wait until they release it and i will bump plugin version

semoal commented 7 months ago

Yep, just released mate Opened a pull request: https://github.com/lingui/swc-plugin/pull/89

timofei-iatsenko commented 7 months ago

Still don't see it here https://swc.rs/docs/plugin/selecting-swc-core

semoal commented 7 months ago

Still don't see it here swc.rs/docs/plugin/selecting-swc-core

Probably not updated yet, but Next 14.2 already uses 0.90.30 https://github.com/vercel/next.js/pull/63790

timofei-iatsenko commented 7 months ago

Couldn't be that sure

image
semoal commented 7 months ago

It's curious because tried to upgrade to Next 14.2 and got this error when trying to run next dev or next build:


thread 'thread 'thread 'thread '<unnamed><unnamed>' panicked at '<unnamed>' panicked at '<unnamed>' 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', ', ', 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.rs266::::676726667

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
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.273.24/src/plugin.rs:thread '166' panicked at :/Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.273.24/src/plugin.rs:166:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/x/.pnpm/next@14.2.0_@babel+core@7.23.5_@playwright+test@1.35.0_babel-plugin-macros@3.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `/x/.pnpm/@lingui+swc-plugin@4.0.4_@lingui+macro@4.7.1_next@14.2.0/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm` as js transform plugin at /x/.pnpm/@lingui+swc-plugin@4.0.4_@lingui+macro@4.7.1_next@14.2.0/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm
    1: failed to run Wasm plugin transform. Please14:
failed to invoke plugin: failed to invoke plugin on 'Some("/x/.pnpm/next@14.2.0_@babel+core@7.23.5_@playwright+test@1.35.0_babel-plugin-macros@3.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/next-dev.js")'
``
`
cbratschi commented 7 months ago

It's curious because tried to upgrade to Next 14.2 and got this error when trying to run next dev or next build:

thread 'thread 'thread 'thread '<unnamed><unnamed>' panicked at '<unnamed>' panicked at '<unnamed>' 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', ', ', 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.rs266::::676726667

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
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.273.24/src/plugin.rs:thread '166' panicked at :/Users/geist/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.273.24/src/plugin.rs:166:14:
failed to invoke plugin: failed to invoke plugin on 'Some("/x/.pnpm/next@14.2.0_@babel+core@7.23.5_@playwright+test@1.35.0_babel-plugin-macros@3.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/router.js")'

Caused by:
    0: failed to invoke `/x/.pnpm/@lingui+swc-plugin@4.0.4_@lingui+macro@4.7.1_next@14.2.0/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm` as js transform plugin at /x/.pnpm/@lingui+swc-plugin@4.0.4_@lingui+macro@4.7.1_next@14.2.0/node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm
    1: failed to run Wasm plugin transform. Please14:
failed to invoke plugin: failed to invoke plugin on 'Some("/x/.pnpm/next@14.2.0_@babel+core@7.23.5_@playwright+test@1.35.0_babel-plugin-macros@3.1.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/next-dev.js")'
``
`

Same problem here. Next.js 14.2 fails to invoke node_modules/@lingui/swc-plugin/target/wasm32-wasi/release/lingui_macro_plugin.wasm.

Downgrading Next.js until Lingui gets updated.

timofei-iatsenko commented 7 months ago

@semoal did you try to run your locally built version with Next.js 14.2? Panic during plugin execution might be caused by many different things, swc_core version is only one of them. Rust version, compiler settings, internal bugs in next-swc all those things may commit into the issue.

I personally, prefer to wait until https://swc.rs/docs/plugin/selecting-swc-core would be updated (they usually have it up to date) and then start investigating.

timofei-iatsenko commented 7 months ago

https://github.com/swc-project/swc/issues/8862

timofei-iatsenko commented 7 months ago

released https://github.com/lingui/swc-plugin/releases/tag/4.0.7