Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Nextjs 13.4.8 + swc-plugin = build fail #36

Open
aleksanderd opened this issue Jul 14, 2023 · 4 comments
Open

Nextjs 13.4.8 + swc-plugin = build fail #36

aleksanderd opened this issue Jul 14, 2023 · 4 comments

Comments

@aleksanderd
Copy link

Hi!

Just updated to latest nextjs (need some features) and got build failed

image
...
image

checked several nextjs versions and noticed the problem appeared at 13.4.8

@fritzlolpro
Copy link

Got similar problem
Looks like its not only Next related

"@effector/swc-plugin": "^0.0.10",  

 "@swc/cli": "^0.1.62",
"@swc/core": "^1.3.68",

@kireevmp
Copy link

Still an issue, but it does not look related specifically to Next. I stumbled across it using Vite setup.

Here's a minimal reproduction:

.swcrc
{
  "$schema": "https://json.schemastore.org/swcrc",
  "jsc": {
    "target": "esnext",
    "experimental": {
      "plugins": [["@effector/swc-plugin", {}]]
    }
  }
}
in.js
"asd"?.toString;
out.js
this?.?;
$ RUST_BACKTRACE=full yarn swc in.js -o out.js

In this instance, it does not crash. Here's a version that does:

in.js + stacktrace

in.js

'asd'?.toString()
setTimeout(() => 'asd'?.connect(), 0)

stacktrace:

thread '<unnamed>' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_compiler_base-0.4.8/src/lib.rs:160:32:
invalid utf8 character detected: FromUtf8Error { bytes: [116, 104, 105, 115, 46, 115, 101, 116, 84, 105, 109, 101, 111, 117, 116, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 19, 0, 0, 0, 29, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 224, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 97, 115, 100, 0, 0, 0, 0, 63, 59, 10, 115, 101, 116, 84, 105, 109, 101, 111, 117, 116, 40, 40, 41, 61, 62, 116, 104, 105, 115, 46, 0, 44, 32, 48, 41, 59, 10], error: Utf8Error { valid_up_to: 41, error_len: Some(1) } }
stack backtrace:
   0:        0x1247e2880 - _napi_register_module_v1
   1:        0x1244ca0fc - _blake3_compress_in_place_portable
   2:        0x1247bbc1c - _napi_register_module_v1
   3:        0x1247e3b90 - _napi_register_module_v1
   4:        0x1247e3370 - _napi_register_module_v1
   5:        0x1247e43d4 - _napi_register_module_v1
   6:        0x1247e3e98 - _napi_register_module_v1
   7:        0x1247e3e04 - _napi_register_module_v1
   8:        0x1247e3df8 - _napi_register_module_v1
   9:        0x12588936c - _wasmer_vm_imported_memory32_atomic_notify
  10:        0x1258896e4 - _wasmer_vm_imported_memory32_atomic_notify
  11:        0x12498c19c - _napi_register_module_v1
  12:        0x12493a73c - _napi_register_module_v1
  13:        0x1249535cc - _napi_register_module_v1
  14:        0x124324e70 - <unknown>
failed to handle: invalid utf8 character detected: FromUtf8Error { bytes: [116, 104, 105, 115, 46, 115, 101, 116, 84, 105, 109, 101, 111, 117, 116, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 19, 0, 0, 0, 29, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0, 224, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 97, 115, 100, 0, 0, 0, 0, 63, 59, 10, 115, 101, 116, 84, 105, 109, 101, 111, 117, 116, 40, 40, 41, 61, 62, 116, 104, 105, 115, 46, 0, 44, 32, 48, 41, 59, 10], error: Utf8Error { valid_up_to: 41, error_len: Some(1) } }

Stack backtrace:
   0: _napi_register_module_v1
   1: _wasmer_vm_imported_memory32_atomic_notify
   2: <unknown>
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (/Users/<redacted>/node_modules/@swc/cli/lib/swc/util.js:149:15)
    at files (/Users/<redacted>/node_modules/@swc/cli/lib/swc/file.js:201:19)
    at async _default (/Users/<redacted>/node_modules/@swc/cli/lib/swc/file.js:220:9)

Versions:

@swc/[email protected]


I'm not deeply familiar with Rust, but I can try and make a PR if someone can point me in the correct direction.

@yumauri
Copy link

yumauri commented Feb 6, 2024

This plugin a bit obsolete and unsupported for a while,
you can try new effector SWC plugin from community:
https://github.com/kireevmp/effector-swc-plugin
(but read documentation carefully, especially about version choosing)

@yumauri
Copy link

yumauri commented Feb 7, 2024

Ahaha, @kireevmp I didn't pay attention, that the last message was from the author of new plugin 😅

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

No branches or pull requests

4 participants