cloudflare / next-on-pages

CLI to build and develop Next.js apps for Cloudflare Pages
https://www.npmjs.com/package/@cloudflare/next-on-pages
MIT License
1.3k stars 126 forks source link

[🐛 Bug]: next-on-pages fails with SyntaxError: Unexpected token (268:4) #344

Closed AlecKriebel closed 1 year ago

AlecKriebel commented 1 year ago

next-on-pages environment related information

System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 CPU: (10) arm64 Apple M1 Pro Memory: 16 GB Shell: /bin/zsh Binaries: Node: 19.4.0 Yarn: 1.22.19 npm: 9.6.6 pnpm: N/A Package Manager Used: npm Relevant Packages: @cloudflare/next-on-pages: 1.1.0 vercel: [object Promise] next: [object Promise]

Description

next-on-pages builds are failing with the error SyntaxError: Unexpected token (268:4)

This is reproducible locally and on Cloudflare pages for me. A different project I have locally, using the same versions of packages, is succeeding.

Both projects are using the app router with server components, and pages/api, however the failing repo is making use of not-found, og, & robots Next.js features.

2023-06-26T15:13:45.322363Z Cloning repository...
2023-06-26T15:13:46.683872Z  * branch            f6a99b6ec58d716a281f5cf4d3d61504987f5720 -> FETCH_HEAD
2023-06-26T15:13:46.684051Z 
2023-06-26T15:13:46.796771Z HEAD is now at f6a99b6 try to add deps for cloudflare pages
2023-06-26T15:13:46.797364Z 
2023-06-26T15:13:46.908883Z 
2023-06-26T15:13:46.940462Z Success: Finished cloning repository files
2023-06-26T15:13:47.629149Z Installing dependencies
2023-06-26T15:13:47.637004Z Python version set to 2.7
2023-06-26T15:13:50.795589Z Downloading and installing node v19.4.0...
2023-06-26T15:13:51.166781Z Downloading https://nodejs.org/dist/v19.4.0/node-v19.4.0-linux-x64.tar.xz...
2023-06-26T15:13:52.057969Z Computing checksum with sha256sum
2023-06-26T15:13:52.193458Z Checksums matched!
2023-06-26T15:13:57.392362Z Now using node v19.4.0 (npm v9.2.0)
2023-06-26T15:13:57.639922Z Started restoring cached build plugins
2023-06-26T15:13:57.649085Z Finished restoring cached build plugins
2023-06-26T15:13:58.028994Z Attempting ruby version 2.7.1, read from environment
2023-06-26T15:13:59.487725Z Using /opt/buildhome/.rvm/gems/ruby-2.7.1
2023-06-26T15:14:00.457224Z Using PHP version 5.6
2023-06-26T15:14:00.546741Z 5.2.5 is already installed.
2023-06-26T15:14:00.564014Z Using Swift version 5.2.5
2023-06-26T15:14:00.564396Z Started restoring cached node modules
2023-06-26T15:14:00.576584Z Finished restoring cached node modules
2023-06-26T15:14:00.584042Z Started restoring cached yarn cache
2023-06-26T15:14:00.594952Z Finished restoring cached yarn cache
2023-06-26T15:14:00.61567Z  Installing yarn at version 1.22.4
2023-06-26T15:14:00.633145Z Installing Yarn!
2023-06-26T15:14:00.633437Z > Downloading tarball...
2023-06-26T15:14:00.666477Z 
2023-06-26T15:14:00.666824Z [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.mmbeo6fwkD
2023-06-26T15:14:00.66749Z    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2023-06-26T15:14:00.668299Z                                  Dload  Upload   Total   Spent    Left  Speed
2023-06-26T15:14:00.729552Z 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    80    0    80    0     0   1290      0 --:--:-- --:--:-- --:--:--  1290
2023-06-26T15:14:00.751944Z 
100    92  100    92    0     0   1095      0 --:--:-- --:--:-- --:--:--  1095
2023-06-26T15:14:00.824858Z 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2023-06-26T15:14:00.997335Z 
  0 1215k    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 1215k  100 1215k    0     0  3694k      0 --:--:-- --:--:-- --:--:-- 29.6M
2023-06-26T15:14:00.997701Z 
2023-06-26T15:14:00.997974Z [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.mmbeo6fwkD.asc
2023-06-26T15:14:00.998417Z   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
2023-06-26T15:14:00.998747Z                                  Dload  Upload   Total   Spent    Left  Speed
2023-06-26T15:14:01.030856Z 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100    84  100    84    0     0   2625      0 --:--:-- --:--:-- --:--:--  2625
2023-06-26T15:14:01.033198Z 
100    96  100    96    0     0   2823      0 --:--:-- --:--:-- --:--:--  2823
2023-06-26T15:14:01.062086Z 
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
2023-06-26T15:14:01.160735Z 
100  1028  100  1028    0     0   6345      0 --:--:-- --:--:-- --:--:--  6345
2023-06-26T15:14:01.171348Z > Verifying integrity...
2023-06-26T15:14:01.198228Z gpg: Oops: lock already held by us
2023-06-26T15:14:01.207986Z gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC
2023-06-26T15:14:01.208307Z gpg:                using RSA key 6D98490C6F1ACDDD448E45954F77679369475BAA
2023-06-26T15:14:01.210922Z gpg: Good signature from "Yarn Packaging <yarn@dan.cx>" [unknown]
2023-06-26T15:14:01.213107Z gpg: WARNING: This key is not certified with a trusted signature!
2023-06-26T15:14:01.213364Z gpg:          There is no indication that the signature belongs to the owner.
2023-06-26T15:14:01.213608Z Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
2023-06-26T15:14:01.213784Z      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
2023-06-26T15:14:01.214661Z > GPG signature looks good
2023-06-26T15:14:01.214853Z > Extracting to ~/.yarn...
2023-06-26T15:14:01.289756Z > Adding to $PATH...
2023-06-26T15:14:01.305227Z > We've added the following to your /opt/buildhome/.bashrc
2023-06-26T15:14:01.305561Z > If this isn't the profile of your current shell then please add the following to your correct profile:
2023-06-26T15:14:01.30573Z     
2023-06-26T15:14:01.305849Z export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
2023-06-26T15:14:01.305964Z 
2023-06-26T15:14:01.699896Z > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
2023-06-26T15:14:02.080572Z Installing NPM modules using Yarn version 1.22.4
2023-06-26T15:14:03.299564Z yarn install v1.22.4
2023-06-26T15:14:03.444749Z [1/4] Resolving packages...
2023-06-26T15:14:03.940308Z [2/4] Fetching packages...
2023-06-26T15:15:21.841623Z [3/4] Linking dependencies...
2023-06-26T15:16:09.916341Z [4/4] Building fresh packages...
2023-06-26T15:17:22.51024Z  Done in 199.22s.
2023-06-26T15:17:22.539145Z NPM modules installed using Yarn
2023-06-26T15:17:22.839501Z Installing Hugo 0.54.0
2023-06-26T15:17:23.525149Z Hugo Static Site Generator v0.54.0-B1A82C61A/extended linux/amd64 BuildDate: 2019-02-01T10:04:38Z
2023-06-26T15:17:23.527736Z Started restoring cached go cache
2023-06-26T15:17:23.541376Z Finished restoring cached go cache
2023-06-26T15:17:23.626554Z go version go1.14.4 linux/amd64
2023-06-26T15:17:23.639568Z go version go1.14.4 linux/amd64
2023-06-26T15:17:23.644417Z Installing missing commands
2023-06-26T15:17:23.644731Z Verify run directory
2023-06-26T15:17:23.644891Z Executing user command: yarn && cd packages/web && npx @cloudflare/next-on-pages@1
2023-06-26T15:17:23.863773Z yarn install v1.22.4
2023-06-26T15:17:24.007724Z [1/4] Resolving packages...
2023-06-26T15:17:24.511167Z success Already up-to-date.
2023-06-26T15:17:24.519009Z Done in 0.66s.
2023-06-26T15:17:27.422417Z ⚡️ @cloudflare/next-on-pages CLI v.1.1.0
2023-06-26T15:17:27.424975Z ⚡️ Detected Package Manager: npm
2023-06-26T15:17:27.425293Z ⚡️ Preparing project...
2023-06-26T15:17:27.427418Z ⚡️ Project is ready
2023-06-26T15:17:27.427803Z ⚡️ Building project...
2023-06-26T15:17:28.740854Z ▲  Vercel CLI 30.2.3
2023-06-26T15:17:28.928118Z ▲  Warning: When using Next.js, it is recommended to place JavaScript Functions inside of the `pages/api` (provided by Next.js) directory instead of `api` (provided by Vercel). Other languages (Python, Go, etc) should still go in the `api` directory. Learn More: https://nextjs.org/docs/api-routes/introduction
2023-06-26T15:17:29.636618Z ▲  Installing dependencies...
2023-06-26T15:17:29.880494Z ▲  yarn install v1.22.4
2023-06-26T15:17:30.029781Z ▲  [1/4] Resolving packages...
2023-06-26T15:17:30.536687Z ▲  success Already up-to-date.
2023-06-26T15:17:30.547268Z ▲  Done in 0.67s.
2023-06-26T15:17:30.566536Z ▲  Detected Next.js version: 13.4.7
2023-06-26T15:17:30.569701Z ▲  Running "yarn run build"
2023-06-26T15:17:30.789283Z ▲  yarn run v1.22.4
2023-06-26T15:17:30.853792Z ▲  $ contentlayer build && next build
2023-06-26T15:17:36.171903Z ▲  Generated 15 documents in .contentlayer
2023-06-26T15:17:36.175676Z ▲  (node:2038) [DEP0164] DeprecationWarning: Implicit coercion to integer for exit code is deprecated.
2023-06-26T15:17:36.176131Z ▲  (Use `node --trace-deprecation ...` to show where the warning was created)
2023-06-26T15:17:39.279958Z ▲  Attention: Next.js now collects completely anonymous telemetry regarding usage.
2023-06-26T15:17:39.280594Z ▲  This information is used to shape Next.js' roadmap and prioritize features.
2023-06-26T15:17:39.280768Z ▲  You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
2023-06-26T15:17:39.281078Z ▲  https://nextjs.org/telemetry
2023-06-26T15:17:39.453849Z ▲  - info Creating an optimized production build...
2023-06-26T15:17:40.883743Z ▲  Generated 15 documents in .contentlayer
2023-06-26T15:18:27.223575Z ▲  
2023-06-26T15:18:27.223121Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.223264Z ▲  A Node.js API is used (process.emitWarning at line: 196) which is not supported in the Edge Runtime.
2023-06-26T15:18:27.223416Z ▲  Learn more: https://nextjs.org/docs/api-reference/edge-runtime
2023-06-26T15:18:27.223575Z ▲  
2023-06-26T15:18:27.223704Z ▲  Import trace for requested module:
2023-06-26T15:18:27.223811Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.223929Z ▲  ../../node_modules/stripe/esm/stripe.core.js
2023-06-26T15:18:27.224038Z ▲  ../../node_modules/stripe/esm/stripe.esm.worker.js
2023-06-26T15:18:27.224151Z ▲  ./lib/stripe.ts
2023-06-26T15:18:27.224267Z ▲  
2023-06-26T15:18:27.224373Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.224483Z ▲  A Node.js API is used (process.emitWarning at line: 199) which is not supported in the Edge Runtime.
2023-06-26T15:18:27.224609Z ▲  Learn more: https://nextjs.org/docs/api-reference/edge-runtime
2023-06-26T15:18:27.224714Z ▲  
2023-06-26T15:18:27.224815Z ▲  Import trace for requested module:
2023-06-26T15:18:27.224916Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.225018Z ▲  ../../node_modules/stripe/esm/stripe.core.js
2023-06-26T15:18:27.225142Z ▲  ../../node_modules/stripe/esm/stripe.esm.worker.js
2023-06-26T15:18:27.225251Z ▲  ./lib/stripe.ts
2023-06-26T15:18:27.225354Z ▲  
2023-06-26T15:18:27.225469Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.225617Z ▲  A Node.js API is used (process.version at line: 242) which is not supported in the Edge Runtime.
2023-06-26T15:18:27.225743Z ▲  Learn more: https://nextjs.org/docs/api-reference/edge-runtime
2023-06-26T15:18:27.22587Z  ▲  
2023-06-26T15:18:27.226002Z ▲  Import trace for requested module:
2023-06-26T15:18:27.22611Z  ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.226215Z ▲  ../../node_modules/stripe/esm/stripe.core.js
2023-06-26T15:18:27.22632Z  ▲  ../../node_modules/stripe/esm/stripe.esm.worker.js
2023-06-26T15:18:27.226422Z ▲  ./lib/stripe.ts
2023-06-26T15:18:27.226549Z ▲  
2023-06-26T15:18:27.22667Z  ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.226777Z ▲  A Node.js API is used (process.platform at line: 243) which is not supported in the Edge Runtime.
2023-06-26T15:18:27.226888Z ▲  Learn more: https://nextjs.org/docs/api-reference/edge-runtime
2023-06-26T15:18:27.226991Z ▲  
2023-06-26T15:18:27.227098Z ▲  Import trace for requested module:
2023-06-26T15:18:27.227199Z ▲  ../../node_modules/stripe/esm/utils.js
2023-06-26T15:18:27.227311Z ▲  ../../node_modules/stripe/esm/stripe.core.js
2023-06-26T15:18:27.227422Z ▲  ../../node_modules/stripe/esm/stripe.esm.worker.js
2023-06-26T15:18:27.227545Z ▲  ./lib/stripe.ts
2023-06-26T15:18:27.227672Z ▲  
2023-06-26T15:18:27.227784Z ▲  - info Linting and checking validity of types...
2023-06-26T15:18:39.924711Z ▲  - info Collecting page data...
2023-06-26T15:18:42.071917Z ▲  - info Generating static pages (0/4)
2023-06-26T15:18:42.141073Z ▲  - info Generating static pages (1/4)
2023-06-26T15:18:42.175315Z ▲  - info Generating static pages (2/4)
2023-06-26T15:18:42.191392Z ▲  - info Generating static pages (3/4)
2023-06-26T15:18:42.456167Z ▲  - info Generating static pages (4/4)
2023-06-26T15:18:42.490557Z ▲  - info Finalizing page optimization...
2023-06-26T15:18:42.501824Z ▲  
2023-06-26T15:18:42.576971Z ▲  Route (app)                                Size     First Load JS
2023-06-26T15:18:42.577328Z ▲  ┌ ℇ /                                      0 B                0 B
2023-06-26T15:18:42.577568Z ▲  ├ ℇ /[...slug]                             226 B          90.9 kB
2023-06-26T15:18:42.577784Z ▲  ├ ℇ /api/og                                0 B                0 B
2023-06-26T15:18:42.578006Z ▲  ├ ℇ /api/posts                             0 B                0 B
2023-06-26T15:18:42.578218Z ▲  ├ ℇ /api/posts/[postId]                    0 B                0 B
2023-06-26T15:18:42.578351Z ▲  ├ ℇ /api/signup                            0 B                0 B
2023-06-26T15:18:42.578465Z ▲  ├ ℇ /blog                                  189 B          88.5 kB
2023-06-26T15:18:42.578596Z ▲  ├ ℇ /blog/[...slug]                        228 B          90.9 kB
2023-06-26T15:18:42.578722Z ▲  ├ ℇ /dashboard                             448 B           125 kB
2023-06-26T15:18:42.578837Z ▲  ├ ℇ /dashboard/billing                     5.12 kB         106 kB
2023-06-26T15:18:42.578953Z ▲  ├ ℇ /dashboard/settings                    4.47 kB         149 kB
2023-06-26T15:18:42.57907Z  ▲  ├ ℇ /docs/[[...slug]]                      1.03 kB        98.7 kB
2023-06-26T15:18:42.579172Z ▲  ├ ℇ /editor/[postId]                       5.2 kB          120 kB
2023-06-26T15:18:42.579274Z ▲  ├ ℇ /guides                                187 B          83.8 kB
2023-06-26T15:18:42.57944Z  ▲  ├ ℇ /guides/[...slug]                      1.03 kB        98.7 kB
2023-06-26T15:18:42.579635Z ▲  ├ ℇ /login                                 167 B           155 kB
2023-06-26T15:18:42.579802Z ▲  ├ ○ /opengraph-image.jpg                   0 B                0 B
2023-06-26T15:18:42.57993Z  ▲  ├ ℇ /pricing                               187 B          83.8 kB
2023-06-26T15:18:42.580048Z ▲  ├ ℇ /register                              167 B           155 kB
2023-06-26T15:18:42.58016Z  ▲  └ ○ /robots.txt                            0 B                0 B
2023-06-26T15:18:42.580318Z ▲  + First Load JS shared by all              77.9 kB
2023-06-26T15:18:42.580449Z ▲  ├ chunks/3089-911f6f76826b6e23.js        25.2 kB
2023-06-26T15:18:42.58058Z  ▲  ├ chunks/7d8153d6-4f60e19681a32dc9.js    50.5 kB
2023-06-26T15:18:42.580687Z ▲  ├ chunks/main-app-06aa9159abd2a6fd.js    218 B
2023-06-26T15:18:42.580795Z ▲  └ chunks/webpack-0985d45c43c79319.js     2 kB
2023-06-26T15:18:42.580915Z ▲  
2023-06-26T15:18:42.581029Z ▲  Route (pages)                              Size     First Load JS
2023-06-26T15:18:42.58119Z  ▲  ┌ ○ /404                                   184 B          75.3 kB
2023-06-26T15:18:42.581317Z ▲  ├ ℇ /api/refresh-tokens                    0 B            75.1 kB
2023-06-26T15:18:42.581429Z ▲  ├ ℇ /api/stripe                            0 B            75.1 kB
2023-06-26T15:18:42.581559Z ▲  ├ ℇ /api/users/stripe                      0 B            75.1 kB
2023-06-26T15:18:42.581665Z ▲  └ ℇ /api/webhooks/stripe                   0 B            75.1 kB
2023-06-26T15:18:42.581774Z ▲  + First Load JS shared by all              75.1 kB
2023-06-26T15:18:42.581886Z ▲  ├ chunks/framework-d8458ae884c231d6.js   45 kB
2023-06-26T15:18:42.581994Z ▲  ├ chunks/main-6c4334778225c94d.js        27.9 kB
2023-06-26T15:18:42.582104Z ▲  ├ chunks/pages/_app-deaf369e3c06744d.js  196 B
2023-06-26T15:18:42.582215Z ▲  └ chunks/webpack-0985d45c43c79319.js     2 kB
2023-06-26T15:18:42.582326Z ▲  
2023-06-26T15:18:42.582429Z ▲  ƒ Middleware                               107 kB
2023-06-26T15:18:42.582572Z ▲  ℇ  (Streaming)  server-side renders with streaming (uses React 18 SSR streaming or Server Components)
2023-06-26T15:18:42.582688Z ▲  ○  (Static)     automatically rendered as static HTML (uses no initial props)
2023-06-26T15:18:43.217755Z ▲  Done in 72.43s.
2023-06-26T15:18:43.30734Z  ▲  Traced Next.js server files in: 22.067ms
2023-06-26T15:18:54.699264Z ▲  Created all serverless functions in: 11.392s
2023-06-26T15:18:57.671596Z ▲  Collected static files (public/, static/, .next/static): 13.101ms
2023-06-26T15:18:58.005784Z ▲  Using TypeScript 4.7.4 (local user-provided)
2023-06-26T15:19:05.461835Z ▲  Build Completed in .vercel/output [2m]
2023-06-26T15:19:05.636635Z ⚡️ Completed `npx vercel build`.
2023-06-26T15:19:10.233151Z /opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12953
2023-06-26T15:19:10.233663Z   var err = new SyntaxError(message);
2023-06-26T15:19:10.233907Z             ^
2023-06-26T15:19:10.234053Z 
2023-06-26T15:19:10.234202Z SyntaxError: Unexpected token (268:4)
2023-06-26T15:19:10.234352Z     at pp$4.raise (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12953:13)
2023-06-26T15:19:10.234498Z     at pp$9.unexpected (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:10547:8)
2023-06-26T15:19:10.234631Z     at pp$9.expect (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:10544:27)
2023-06-26T15:19:10.234739Z     at pp$5.parseParenAndDistinguishExpression (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12467:36)
2023-06-26T15:19:10.23485Z      at pp$5.parseExprAtom (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12359:43)
2023-06-26T15:19:10.234957Z     at pp$5.parseExprSubscripts (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12200:19)
2023-06-26T15:19:10.235062Z     at pp$5.parseMaybeUnary (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12171:17)
2023-06-26T15:19:10.235166Z     at pp$5.parseExprOps (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12102:19)
2023-06-26T15:19:10.235269Z     at pp$5.parseMaybeConditional (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12086:19)
2023-06-26T15:19:10.235371Z     at pp$5.parseMaybeAssign (/opt/buildhome/repo/node_modules/@cloudflare/next-on-pages/dist/index.js:12043:19) {
2023-06-26T15:19:10.235486Z   pos: 85971,
2023-06-26T15:19:10.235605Z   loc: Position2 { line: 268, column: 4 },
2023-06-26T15:19:10.23571Z    raisedAt: 85972
2023-06-26T15:19:10.235812Z }
2023-06-26T15:19:10.235913Z 
2023-06-26T15:19:10.236019Z Node.js v19.4.0
2023-06-26T15:19:10.313671Z Failed: build command exited with code: 1
2023-06-26T15:19:11.86978Z  Failed: error occurred while running build command

Reproduction

My repo is private, but the package in questions is a direct adaption of https://github.com/shadcn/taxonomy that's modified to be deployed on Cloudflare pages using next-on-pages (adding export const runtime = "edge"; atop many files).

I do not have reproduction steps since I don't know the root cause, but would be happy to provide my .vercel/output if it'd be useful!

Pages Deployment Method

Pages CI (GitHub/GitLab integration)

Pages Deployment ID

f39a87aa-4213-4967-b436-d903cc723636

Additional Information

On next-on-pages version 0.10.2, I get the error output:

⚡️ Completed `npx vercel build`.
✘ [ERROR] Expected ")" but found ";"

    ../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/editor/[postId].func.js:268:4:
      268 │ `)});function _(e,r,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=S(r,o);else{var a=...
          │     ^
          ╵     )

✘ [ERROR] Could not resolve "/wasm/wasm_53adb396180a95eb122a0218c93e3d6474b1a27e.wasm"

    ../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js:2:64:
      2 │ ...95eb122a0218c93e3d6474b1a27e = require("/wasm/wasm_53adb396180a95eb122a0218c93e3d6474b1a27e.wasm");
        ╵                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Could not resolve "/wasm/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm"

    ../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js:3:62:
      3 │ ...c0131e9ebe945031077e8a02633b = require("/wasm/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm");
        ╵                                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1575
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 3 errors:
../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js:2:64: ERROR: Could not resolve "/wasm/wasm_53adb396180a95eb122a0218c93e3d6474b1a27e.wasm"
../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js:3:62: ERROR: Could not resolve "/wasm/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm"
../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/editor/[postId].func.js:268:4: ERROR: Expected ")" but found ";"
    at failureErrorWithLog (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1575:15)
    at /Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1033:28
    at runOnEndCallbacks (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1447:61)
    at buildResponseToResult (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1031:7)
    at /Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:1143:14
    at responseCallbacks.<computed> (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:680:9)
    at handleIncomingPacket (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:735:9)
    at Socket.readFromStdout (/Users/alec/Desktop/alec-dev/starter/node_modules/@cloudflare/next-on-pages/node_modules/esbuild/lib/main.js:656:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 64,
        file: '../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js',
        length: 58,
        line: 2,
        lineText: '  const wasm_53adb396180a95eb122a0218c93e3d6474b1a27e = require("/wasm/wasm_53adb396180a95eb122a0218c93e3d6474b1a27e.wasm");',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not resolve "/wasm/wasm_53adb396180a95eb122a0218c93e3d6474b1a27e.wasm"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 62,
        file: '../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/api/og.func.js',
        length: 58,
        line: 3,
        lineText: 'const wasm_5b50c798761dc0131e9ebe945031077e8a02633b = require("/wasm/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm");',
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'Could not resolve "/wasm/wasm_5b50c798761dc0131e9ebe945031077e8a02633b.wasm"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 4,
        file: '../../../../../../../private/var/folders/cp/bbqcpp814bjd_6mfhk6lxf7r0000gn/T/mhm4o2hni7/editor/[postId].func.js',
        length: 1,
        line: 268,
        lineText: '`)});function _(e,r,n,i){var o=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=S(r,o);else{var a=document.createTextNode(o),l=e.childNodes;l[r]&&e.removeChild(l[r]),l.length?e.insertBefore(a,l[r]):e.appendChild(a)}}},function(e,r){e.exports=function(e){var r="u">typeof window&&window.location;if(!r)throw Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=r.protocol+"//"+r.host,i=n+r.pathname.replace(/\\/[^\\/]*$/,"/");return e.replace(/url\\s*\\(((?:[^)(]|\\((?:[^)(]+|\\([^)(]*\\))*\\))*)\\)/gi,function(e,r){var o=r.trim().replace(/^"(.*)"$/,function(e,r){return r}).replace(/^\'(.*)\'$/,function(e,r){return r});return/^(#|data:|http:\\/\\/|https:\\/\\/|file:\\/\\/\\/|\\s*$)/i.test(o)?e:"url("+JSON.stringify(0===o.indexOf("//")?o:0===o.indexOf("/")?n+o:i+o.replace(/^\\.\\//,""))+")"})}},function(e,r,n){var i,o,a,l,c,u;e.exports=(i="cdx-notify",o="cdx-notify__cross",a="cdx-notify__button--confirm",l="cdx-notify__button",c="cdx-notify__btns-wrapper",{alert:u=function(e){var r=document.createElement("DIV"),n=document.createElement("DIV"),a=e.message,l=e.style;return r.classList.add(i),l&&r.classList.add(i+"--"+l),r.innerHTML=a,n.classList.add(o),n.addEventListener("click",r.remove.bind(r)),r.appendChild(n),r},confirm:function(e){var r=u(e),n=document.createElement("div"),i=document.createElement("button"),d=document.createElement("button"),h=r.querySelector("."+o),p=e.cancelHandler,f=e.okHandler;return n.classList.add(c),i.innerHTML=e.okText||"Confirm",d.innerHTML=e.cancelText||"Cancel",i.classList.add(l),d.classList.add(l),i.classList.add(a),d.classList.add("cdx-notify__button--cancel"),p&&"function"==typeof p&&(d.addEventListener("click",p),h.addEventListener("click",p)),f&&"function"==typeof f&&i.addEventListener("click",f),i.addEventListener("click",r.remove.bind(r)),d.addEventListener("click",r.remove.bind(r)),n.appendChild(i),n.appendChild(d),r.appendChild(n),r},prompt:function(e){var r=u(e),n=document.createElement("div"),i=document.createElement("button"),d=document.createElement("input"),h=r.querySelector("."+o),p=e.cancelHandler,f=e.okHandler;return n.classList.add(c),i.innerHTML=e.okText||"Ok",i.classList.add(l),i.classList.add(a),d.classList.add("cdx-notify__input"),e.placeholder&&d.setAttribute("placeholder",e.placeholder),e.default&&(d.value=e.default),e.inputType&&(d.type=e.inputType),p&&"function"==typeof p&&h.addEventListener("click",p),f&&"function"==typeof f&&i.addEventListener("click",function(){f(d.value)}),i.addEventListener("click",r.remove.bind(r)),n.appendChild(d),n.appendChild(i),r.appendChild(n),r},getWrapper:function(){var e=document.createElement("DIV");return e.classList.add("cdx-notifies"),e}})}]);let eF=E(ej);class e${show(e){eF.show(e)}}class eU extends ek{constructor({config:e,eventsDispatcher:r}){super({config:e,eventsDispatcher:r}),this.notifier=new e$}get methods(){return{show:e=>this.show(e)}}show(e){return this.notifier.show(e)}}class ez extends ek{get methods(){let e=()=>this.isEnabled;return{toggle:e=>this.toggle(e),get isEnabled(){return e()}}}toggle(e){return this.Editor.ReadOnly.toggle(e)}get isEnabled(){return this.Editor.ReadOnly.isEnabled}}var eH={};({get exports(){return eH},set exports(s){eH=s}}).exports=function(){function e(e){var r=e.tags;if(!Object.keys(r).map(function(e){return typeof r[e]}).every(function(e){return"object"===e||"boolean"===e||"function"===e}))throw Error("The configuration was invalid");this.config=e}var r=["P","LI","TD","TH","DIV","H1","H2","H3","H4","H5","H6","PRE"];function n(e){return -1!==r.indexOf(e.nodeName)}var i=["A","B","STRONG","I","EM","SUB","SUP","U","STRIKE"];return e.prototype.clean=function(e){let r=document.implementation.createHTMLDocument(),n=r.createElement("div");return n.innerHTML=e,this._sanitize(r,n),n.innerHTML},e.prototype._sanitize=function(e,r){var o=e.createTreeWalker(r,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null,!1),a=o.firstChild();if(a)do{if(a.nodeType===Node.TEXT_NODE){if(!(""===a.data.trim()&&(a.previousElementSibling&&n(a.previousElementSibling)||a.nextElementSibling&&n(a.nextElementSibling))))continue;r.removeChild(a),this._sanitize(e,r);break}if(a.nodeType===Node.COMMENT_NODE){r.removeChild(a),this._sanitize(e,r);break}var l,c,u,d,h=(u=a,-1!==i.indexOf(u.nodeName));h&&(d=Array.prototype.some.call(a.childNodes,n));var p=!!r.parentNode,f=n(r)&&n(a)&&p,m=a.nodeName.toLowerCase(),g=(l=this.config,c=a,"function"==typeof l.tags[m]?l.tags[m](c):l.tags[m]);if(h&&d||typeof g>"u"||"boolean"==typeof g&&!g||!this.config.keepNestedBlockElements&&f){if(!("SCRIPT"===a.nodeName||"STYLE"===a.nodeName))for(;a.childNodes.length>0;)r.insertBefore(a.childNodes[0],a);r.removeChild(a),this._sanitize(e,r);break}for(var y=0;y<a.attributes.length;y+=1){var v=a.attributes[y];(function(e,r,n){var i=e.name.toLowerCase();return!0!==r&&("function"==typeof r[i]?!r[i](e.value,n):typeof r[i]>"u"||!1===r[i]||"string"==typeof r[i]&&r[i]!==e.value)})(v,g,a)&&(a.removeAttribute(v.name),y-=1)}this._sanitize(e,a)}while(a=o.nextSibling())},e}();let eq=eH;function eV(e,r){return e.map(e=>{let n=D(r)?r(e.tool):r;return z(n)||(e.data=eZ(e.data,n)),e})}function eW(e,r={}){return new eq({tags:r}).clean(e)}function eZ(e,r){return Array.isArray(e)?eG(e,r):B(e)?eK(e,r):j(e)?eJ(e,r):e}function eG(e,r){return e.map(e=>eZ(e,r))}function eK(e,r){let n={};for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let o=e[i],a=eY(r[i])?r[i]:r;n[i]=eZ(o,a)}return n}function eJ(e,r){return B(r)?eW(e,r):!1===r?eW(e,{}):e}function eY(e){return B(e)||F(e)||D(e)}class eQ extends ek{get methods(){return{clean:(e,r)=>this.clean(e,r)}}clean(e,r){return eW(e,r)}}class eX extends ek{get methods(){return{save:()=>this.save()}}save(){let e="Editor\'s content can not be saved in read-only mode";return this.Editor.ReadOnly.isEnabled?(P(e,"warn"),Promise.reject(Error(e))):this.Editor.Saver.save()}}class e0 extends ek{get methods(){return{findParentTag:(e,r)=>this.findParentTag(e,r),expandToTag:e=>this.expandToTag(e)}}findParentTag(e,r){return new eS().findParentTag(e,r)}expandToTag(e){new eS().expandToTag(e)}}class e1 extends ek{get classes(){return{block:"cdx-block",inlineToolButton:"ce-inline-tool",inlineToolButtonActive:"ce-inline-tool--active",input:"cdx-input",loader:"cdx-loader",button:"cdx-button",settingsButton:"cdx-settings-button",settingsButtonActive:"cdx-settings-button--active"}}}class e2 extends ek{get methods(){return{close:()=>this.close(),open:()=>this.open(),toggleBlockSettings:e=>this.toggleBlockSettings(e),toggleToolbox:e=>this.toggleToolbox(e)}}open(){this.Editor.Toolbar.moveAndOpen()}close(){this.Editor.Toolbar.close()}toggleBlockSettings(e){if(-1===this.Editor.BlockManager.currentBlockIndex){P("Could\'t toggle the Toolbar because there is no block selected ","warn");return}e??!this.Editor.BlockSettings.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.BlockSettings.open()):this.Editor.BlockSettings.close()}toggleToolbox(e){if(-1===this.Editor.BlockManager.currentBlockIndex){P("Could\'t toggle the Toolbox because there is no block selected ","warn");return}e??!this.Editor.Toolbar.toolbox.opened?(this.Editor.Toolbar.moveAndOpen(),this.Editor.Toolbar.toolbox.open()):this.Editor.Toolbar.toolbox.close()}}var e3={};l={get exports(){return e3},set exports(s){e3=s}},window,l.exports=function(e){var r={};function n(i){if(r[i])return r[i].exports;var o=r[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,i){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:i})},n.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r||4&r&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(i,o,(function(r){return e[r]}).bind(null,o));return i},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){e.exports=n(1)},function(e,r,n){n.r(r),n.d(r,"default",function(){return i});class i{constructor(){this.nodes={wrapper:null,content:null},this.showed=!1,this.offsetTop=10,this.offsetLeft=10,this.offsetRight=10,this.hidingDelay=0,this.handleWindowScroll=()=>{this.showed&&this.hide(!0)},this.loadStyles(),this.prepare(),window.addEventListener("scroll",this.handleWindowScroll,{passive:!0})}get CSS(){return{tooltip:"ct",tooltipContent:"ct__content",tooltipShown:"ct--shown",placement:{left:"ct--left",bottom:"ct--bottom",right:"ct--right",top:"ct--top"}}}show(e,r,n){this.nodes.wrapper||this.prepare(),this.hidingTimeout&&clearTimeout(this.hidingTimeout);let i=Object.assign({placement:"bottom",marginTop:0,marginLeft:0,marginRight:0,marginBottom:0,delay:70,hidingDelay:0},n);if(i.hidingDelay&&(this.hidingDelay=i.hidingDelay),this.nodes.content.innerHTML="","string"==typeof r)this.nodes.content.appendChild(document.createTextNode(r));else{if(!(r instanceof Node))throw Error("[CodeX Tooltip] Wrong type of \\xabcontent\\xbb passed. It should be an instance of Node or String. But "+typeof r+" given.");this.nodes.content.appendChild(r)}switch(this.nodes.wrapper.classList.remove(...Object.values(this.CSS.placement)),i.placement){case"top":this.placeTop(e,i);break;case"left":this.placeLeft(e,i);break;case"right":this.placeRight(e,i);break;default:this.placeBottom(e,i)}i&&i.delay?this.showingTimeout=setTimeout(()=>{this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0},i.delay):(this.nodes.wrapper.classList.add(this.CSS.tooltipShown),this.showed=!0)}hide(e=!1){if(this.hidingDelay&&!e)return this.hidingTimeout&&clearTimeout(this.hidingTimeout),void(this.hidingTimeout=setTimeout(()=>{this.hide(!0)},this.hidingDelay));this.nodes.wrapper.'... 61291 more characters,
        namespace: '',
        suggestion: ')'
      },
      notes: [],
      pluginName: '',
      text: 'Expected ")" but found ";"'
    }
  ],
  warnings: []
}

Would you like to help?

AlecKriebel commented 1 year ago

Digging into the build output from version 0.10.2, this is likely a dupe of #39 (wasm being imported). Please close if that can be verified.

I've confirmed I can get builds to succeed if I prevent my /api/og (which uses @vercel/og which uses wasm), and my editor/pages.tsx (which uses @editorjs/editorjs, which seems to use wasm?) from being bundled into the .vercel/output

Here's the /api/og: https://github.com/shadcn/taxonomy/blob/main/app/api/og/route.tsx Here's the /editor/[postid] server-rendered page: https://github.com/shadcn/taxonomy/blob/main/app/(editor)/editor/%5BpostId%5D/page.tsx

If this is the wasm issue, being able to check a package for compatibility with workers would be hugely beneficial and save tons of time!

james-elicx commented 1 year ago

Hey there, sorry to hear you're running into problems 🙁.

If possible, please don't use 0.10.2, that is a very old version that we no longer offer support for, nor is it at all similar to the current state of the library, or representative of many fixes we've implemented since then. It would be appreciated if all debugging is done against the latest release 🙂.

Anyway, onto the actual SyntaxError. The stack trace looks like it is referencing functions in acorn, presumably from when we call parse. As you checked the box that you were interested in helping, my suggestion might be to log the function file paths being parsed and try to find the one causing the error, and then try and find the line/position in the code that it references when throwing the error.

You could also try out the prerelease in https://github.com/cloudflare/next-on-pages/pull/325 and see if it's related to that.

AlecKriebel commented 1 year ago

Just to chime back in here for anyone else that finds this, the prerelease branch linked does not fix the issue unfortunately :(

I'll find some time to debug & dig further into this soon, however!

dario-piotrowicz commented 1 year ago

@AlecKriebel it's just a hunch but could you try the latest beta release? @james-elicx has cleaned up some code related to your issue, I think there is a chance that it might be solving your issue

dario-piotrowicz commented 1 year ago

Closing this issue due to inactivity (and because the bug might have been fixed since the issue was created)

@AlecKriebel is you circle back to this and still experience the bug please feel free to ping me and/or reopen the issue 🙏

EdamAme-x commented 1 month ago

same issue on wsl 2

EdamAme-x commented 1 month ago

I fixed it by editing it manually. (latest version)

/home/edamamex/.bun/install/global/node_modules/@cloudflare/next-on-pages/dist/index.js:4872
    this.script = s4, this.pmCmd = void 0, this.targetArgs = (r2 == null ? void 0 : r2.args) ?? [];
                                                                                              ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47