Skip to content
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

[🐛 Bug]: wasm imports don't work #676

Closed
1 task
fineshop opened this issue Feb 23, 2024 · 0 comments · Fixed by #681
Closed
1 task

[🐛 Bug]: wasm imports don't work #676

fineshop opened this issue Feb 23, 2024 · 0 comments · Fixed by #681
Labels
bug Something isn't working

Comments

@fineshop
Copy link

fineshop commented Feb 23, 2024

next-on-pages environment related information

System:
        Platform: linux
        Arch: x64
        Version: #1 SMP Thu Oct 5 21:02:42 UTC 2023
        CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
        Memory: 3 GB
        Shell: /bin/bash
Package Manager Used: npm (10.4.0)

Relevant Packages:
        @cloudflare/next-on-pages: 1.9.0
        vercel: 33.4.1
        next: 14.0.4

Description

The build using npx @cloudflare/next-on-pages failing when wasm modules are imported within the app.
I have imported modules (wasm/photon/index.ts and wasm/png/index.ts) in app/api/image/route.ts which imports wasm internally.
Everything works as expected in local development using next dev.
But when we try to build it for cloudflare pages using npx @cloudflare/next-on-pages, it shows the following error:

⚡️ @cloudflare/next-on-pages CLI v.1.9.0
⚡️ Detected Package Manager: npm (10.4.0)
⚡️ Preparing project...
⚡️ Project is ready
⚡️ Building project...
▲  Vercel CLI 33.4.1
▲  WARNING: You should not upload the `.next` directory.
▲  Installing dependencies...
▲  up to date in 587ms
▲  28 packages are looking for funding
▲  run `npm fund` for details
▲  Detected Next.js version: 14.0.4
▲  Detected `package-lock.json` generated by npm 7+
▲  Running "npm run build"
▲  > [email protected] build
▲  > next build
▲  ▲ Next.js 14.0.4
▲  Creating an optimized production build ...
▲  ✓ Compiled successfully
▲  Linting and checking validity of types ...
▲  Collecting page data ...
▲  ⚠ Using edge runtime on a page currently disables static generation for that page
▲  Generating static pages (0/4) ...
▲  Generating static pages (1/4)
▲  Generating static pages (2/4)
▲  Generating static pages (3/4)
▲  ✓ Generating static pages (4/4)
▲  Finalizing page optimization ...
▲  Collecting build traces ...
▲  
▲  Route (app)                              Size     First Load JS
▲  ┌ ○ /                                    335 B          82.2 kB
▲  ├ ℇ /_not-found                          0 B                0 B
▲  ├ ℇ /api/hello                           0 B                0 B
▲  ├ ℇ /api/image                           0 B                0 B
▲  ├ ℇ /client                              620 B          82.5 kB
▲  └ ℇ /server                              141 B            82 kB
▲  + First Load JS shared by all            81.9 kB
▲  ├ chunks/993-25f0712dd7de98d2.js       26.7 kB
▲  ├ chunks/fd9d1056-735d320b4b8745cb.js  53.3 kB
▲  ├ chunks/main-app-f0368426e1af5d32.js  242 B
▲  └ chunks/webpack-3b5a3d1c5cd9ecf8.js   1.69 kB
▲  ○  (Static)        prerendered as static content
▲  ℇ  (Edge Runtime)  server-rendered on demand using the Edge Runtime
▲  Traced Next.js server files in: 501.244ms
▲  Created all serverless functions in: 858.896ms
▲  Collected static files (public/, static/, .next/static): 5.552ms
▲  Build Completed in .vercel/output [21s]
⚡️ Completed `npx vercel build`.
⚡️ Unexpected error: ENOENT: no such file or directory, copyfile '/home/deo/Pages/next-on-pages-get-request-context-test-demo/.vercel/output/functions/api/image.func/wasm/wasm_65d5384f60effcb9a86d814043fa7bb1fdd99f0b.wasm' -> '/home/deo/Pages/next-on-pages-get-request-context-test-demo/.vercel/output/static/_worker.js/__next-on-pages-dist__/wasm/wasm_65d5384f60effcb9a86d814043fa7bb1fdd99f0b.wasm'

Reproduction

  1. Clone the repo:
    git clone https://github.com/techwithdeo/next-cf-pages-wasm.git
    
  2. Choose the directory:
    cd next-cf-pages-wasm
    
  3. Install dependencies
    npm install
    
  4. Start local development:
    npm run dev
    
  5. Open the path in browser (works as expected):
    /api/image
    
  6. Now build it using @cloudflare/next-on-pages (shows error):
    npm run pages:build
    

Pages Deployment Method

None

Pages Deployment ID

Not yet deployed

Additional Information

Note that the build is successful when routes which import wasm are removed/deleted.

Would you like to help?

  • Would you like to help fixing this bug?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant