next-compute-js icon indicating copy to clipboard operation
next-compute-js copied to clipboard

New Next.js 13 project with TypeScript does not compile

Open egeriis opened this issue 2 years ago • 2 comments

I understand that Next.js 13 is not yet listed as officially supported. That said, this information may be helpful.

After bootstrapping a clean Next.js 13 project with TypeScript support, I was getting a lot of errors about unsupported syntax when running fastly compute serve:

✘ [ERROR] Transforming array spread to the configured target environment ("es5") is not supported yet

    bin/index.js:2:1276885:
      2 │ ...n,h=[...Array.isArray(u)?u:[u],...Array.isArray(p)?p:[p]];a.defa...
        ╵                                   ~~~

  The target environment was set to "es5" here:

    ../tsconfig.json:3:14:
      3 │     "target": "es5",
        ╵               ~~~~~

✘ [ERROR] Transforming const to the configured target environment ("es5") is not supported yet

    bin/index.js:2:1277385:
      2 │ ...vmode":void 0}))}function S(){const{docComponentsRendered:e}=a.u...
        ╵                                  ~~~~~

These errors refer to the TypeScript configuration.

After changing target to es6 in tsconfig.json, the project did compile and fastly compute serve ran without issue. However, it still wasn't possible to access the Next.js app, as I was getting 500 response and saw this message in terminal:

2023-01-12T15:08:21.860974Z  WARN no backend definitions found in /Users/ronni/Development/seatgeek/fastly-nextjs-poc/compute-js/fastly.toml
2023-01-12T15:08:21.861102Z  INFO Listening on http://127.0.0.1:7676
2023-01-12T15:08:34.983914Z  INFO request{id=0}: handling request GET http://127.0.0.1:7676/
2023-01-12T15:08:35.013234Z  INFO request{id=0}: request completed using 31.2 MB of WebAssembly heap
2023-01-12T15:08:35.013261Z  INFO request{id=0}: request completed in 29ms
Promise rejected but never handled: A.isTargetLikeServerless is not a function
Stack:
  get _isLikeServerless@<stdin>:2108:51
  getFontManifest@<stdin>:2006:26
  @<stdin>:25826:779
  D@<stdin>:1784:15
  bin/index.js/5150/getServer/<@<stdin>:2132:38
  fulfilled@<stdin>:317:26

egeriis avatar Jan 12 '23 15:01 egeriis

I compiled it successfully with esnext

doronaviguy avatar Apr 03 '23 05:04 doronaviguy

@doronaviguy Was the service accessible? As noted, it was possible to compile it after changing the target, however, the app did not run correctly when I tried.

egeriis avatar Apr 04 '23 15:04 egeriis