Skip to content

Crashes out-of-the-box with current NextJS #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mabinogi opened this issue Apr 26, 2025 · 8 comments
Closed

Crashes out-of-the-box with current NextJS #331

mabinogi opened this issue Apr 26, 2025 · 8 comments

Comments

@mabinogi
Copy link

With a brand new NextJS application, following the getting started instructions results in a crash when running NextJS in dev mode.
A production build seems to work fine.

After wrapping the NextJS config with withYak, attempting to render any page results in this:

Error: ./node_modules/next/dist/esm/build/templates/pages.js:3:1
�[1m�[31mModule not found�[39m�[22m: Can't resolve �[32m'next/dist/esm/build/templates/helpers'�[39m
failed to analyse ecmascript module '[project]/node_modules/next/dist/esm/build/templates/helpers.js [ssr] (ecmascript)'

Caused by:
- failed to parse [project]/node_modules/next/dist/esm/build/templates/helpers.js
- Transforming and/or parsing of [project]/node_modules/next/dist/esm/build/templates/helpers.js failed
- failed to run Wasm plugin transform. Please ensure the version of `swc_core` used by the plugin is compatible with the host runtime. See the documentation for compatibility information. If you are an author of the plugin, please update `swc_core` to the compatible version.
- RuntimeError: unreachable

Debug info:
- Execution of <ModuleAssetContext as AssetContext>::process_resolve_result failed
- Execution of apply_module_type failed
- Execution of <EcmascriptModuleAsset as EcmascriptChunkPlaceable>::get_exports failed
- Execution of analyse_ecmascript_module failed
- failed to analyse ecmascript module '[project]/node_modules/next/dist/esm/build/templates/helpers.js [ssr] (ecmascript)'
- Execution of <EcmascriptModuleAsset as EcmascriptParsable>::failsafe_parse failed
- Execution of parse failed
- failed to parse [project]/node_modules/next/dist/esm/build/templates/helpers.js
- Transforming and/or parsing of [project]/node_modules/next/dist/esm/build/templates/helpers.js failed
- failed to run Wasm plugin transform. Please ensure the version of `swc_core` used by the plugin is compatible with the host runtime. See the documentation for compatibility information. If you are an author of the plugin, please update `swc_core` to the compatible version.
  
                  Note that if you want to use the os features like filesystem, you need to use `wasi`. Wasm itself does not have concept of filesystem.
  
                  https://swc.rs/docs/plugin/selecting-swc-core
  
                  See https://plugins.swc.rs/versions/from-plugin-runner/9.0.0 for the list of the compatible versions.
  
                  Build info:
                      Date: 2025-04-16
                      Timestamp: 2025-04-16T21:28:53.524829634Z
  
                  Version info:
                      swc_plugin_runner: 9.0.0
                      Dependencies: anyhow 1.0.98,codspeed-criterion-compat 2.10.1,criterion 0.5.1,enumset 1.1.5,futures 0.3.31,once_cell 1.21.3,parking_lot 0.12.3,rustc-hash 2.1.1,serde 1.0.219,serde_json 1.0.140,swc_atoms 5.0.0,swc_common 8.1.0,swc_css_ast 8.0.0,swc_css_parser 8.0.0,swc_ecma_ast 8.1.2,swc_ecma_loader 8.0.0,swc_ecma_parser 11.1.2,swc_ecma_visit 8.0.0,swc_malloc 1.2.2,swc_plugin_proxy 8.0.0,swc_transform_common 2.0.0,testing 8.0.0,tokio 1.44.2,tracing 0.1.41,vergen 9.0.6,virtual-fs 0.19.0,wasmer 5.0.5-rc1,wasmer-cache 5.0.5-rc1,wasmer-compiler-cranelift 5.0.5-rc1,wasmer-wasix 0.35.0
                  
- RuntimeError: unreachable
      at __rust_start_panic (yak_swc.wasm[6693]:0x126d99)
      at rust_panic (yak_swc.wasm[6682]:0x126b58)
      at std::panicking::rust_panic_with_hook::h79071f5fb265d1d9 (yak_swc.wasm[6678]:0x126a6d)
      at std::panicking::begin_panic_handler::{{closure}}::h410c57f452410813 (yak_swc.wasm[6658]:0x1259fe)
      at std::sys::backtrace::__rust_end_short_backtrace::h514500abf2a2d0ca (yak_swc.wasm[6657]:0x12596a)
      at rust_begin_unwind (yak_swc.wasm[6670]:0x126401)
      at core::panicking::panic_fmt::he306018bf71f8e67 (yak_swc.wasm[6833]:0x138bbc)
      at core::option::expect_failed::h8817b58eea659422 (yak_swc.wasm[6859]:0x13aa7c)
      at relative_posix_path::relative_posix_path::h1c1c8b4f9bdec702 (yak_swc.wasm[2492]:0x65f95)
      at yak_swc::process_transform::hef3f005ec456c833 (yak_swc.wasm[559]:0xdb63)
      at scoped_tls::ScopedKey<T>::set::h2750a0dbf231a1dc (yak_swc.wasm[557]:0xd922)
      at __transform_plugin_process_impl (yak_swc.wasm[2431]:0x638c3)
      at __transform_plugin_process_impl.command_export (yak_swc.wasm[6947]:0x140d0e)
Import map: aliased to module "next" with subpath '/dist/esm/build/templates/helpers' inside of [project]/

https://nextjs.org/docs/messages/module-not-found
    at BuildError (http://localhost:3000/_next/static/chunks/%5Broot-of-the-server%5D__ec07ee34._.js:17509:41)
    at react-stack-bottom-frame (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:13596:24)
    at renderWithHooks (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:3560:24)
    at updateFunctionComponent (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:5317:21)
    at beginWork (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:5916:24)
    at runWithFiberInDEV (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:1335:74)
    at performUnitOfWork (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:7988:97)
    at workLoopSync (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:7880:40)
    at renderRootSync (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:7863:13)
    at performWorkOnRoot (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:7602:212)
    at performWorkOnRootViaSchedulerTask (http://localhost:3000/_next/static/chunks/node_modules_react-dom_82bb97c6._.js:8566:9)
    at MessagePort.performWorkUntilDeadline (http://localhost:3000/_next/static/chunks/node_modules_a51498a5._.js:1119:64)
@Mad-Kat
Copy link
Contributor

Mad-Kat commented Apr 26, 2025

Hey @mabinogi

Thank you very much for opening the issue. It really looks like something doesn't work with our SWC plugin in your error stack. However I cannot reproduce it myself.

Could you create a small reproduction repo?

Do you use turbopack by any chance? How does your page look like?

I will be happy to take a look and figure out what's going on

@mabinogi
Copy link
Author

Hi @Mad-Kat - here's a reproduction repo: https://github.com/mabinogi/next-yak-test

It's really just the result of create-next-app, accepting all the defaults, then following the Getting Started for Next-Yak.
(Install the package, modify the next.config.ts).

And yes, it's using Turbopack

@Mad-Kat
Copy link
Contributor

Mad-Kat commented Apr 26, 2025

Thank you so much for the reproduction.

If you run npm run build the build itself succeeds. That means the setup works, but if you run npm run dev which itself calls next with turbopack enabled, fails.

Currently next-yak doesn't work with turbopack. So if you chose no at the question Would you like to use Turbopack for 'next dev'? of the installer, it should work.

We're actively in contact with the vercel folks and working on the support of turbopack. You can track #315 to get notified once the support for it is established.

@Mad-Kat Mad-Kat closed this as completed Apr 26, 2025
@mabinogi
Copy link
Author

Thanks @Mad-Kat - I can confirm it works for me without Turbopack, sorry for the false alarm!

@Mad-Kat
Copy link
Contributor

Mad-Kat commented Apr 27, 2025

No worries @mabinogi . Feel free to open issues for anything you find.

@mischnic
Copy link

mischnic commented Apr 28, 2025

Is vercel/next.js#74825 still a hard blocker or do the data URL CSS Modules help with that?

@Mad-Kat
Copy link
Contributor

Mad-Kat commented Apr 29, 2025

Hey Niklas

No I don't think it's a hard blocker anymore. I've tested the data URL integration with a custom loader and it seems to work perfect. Thank you a lot for your work there 🚀

Edit: @mischnic After further testing I noticed that this.loadModule (https://webpack.js.org/api/loaders/#thisloadmodule) isn't supported by turbopack. Are there any plans to support it? That would be a hard blocker similar to vercel/next.js#78156. I've created the issue here: vercel/next.js#78693 Feel free to point me/us in any direction you intend this API to work within turbopack.

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

No branches or pull requests

4 participants