cloudflare/pages-plugins

No Loader is Configured for `.wasm` Files

itsmatteomanf opened this issue · 5 comments

When installing the new @cloudflare/pages-plugin-vercel-og plugin, as soon as it is installed with a function created (I used the sample code used in the docs) it fails to build the worker, both locally using wrangler pages dev and when publishing to Pages.

My function.

import React from "react";
import { ImageResponse } from "@cloudflare/pages-plugin-vercel-og/api";

export const onRequest: PagesFunction = async () => {
  return new ImageResponse(<div style={{ display: "flex" }}> Hello, world! </div>, {
    width: 1200,
    height: 630,
  });
};

The error.

Compiling worker to "/var/folders/l5/qwl85bgn0hd2d6r5f_qxm7680000gn/T/functionsWorker-0.4420685186419462.mjs"...
✘ [ERROR] 2 error(s) and 0 warning(s) when compiling Worker.

✘ [ERROR] No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/resvg.wasm?module

    ../node_modules/@vercel/og/dist/index.edge.js:9:23:
      9 │ import resvg_wasm from "./resvg.wasm?module";
        ╵                        ~~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/yoga.wasm?module

    ../node_modules/@vercel/og/dist/index.edge.js:10:22:
      10 │ import yoga_wasm from "./yoga.wasm?module";
         ╵                       ~~~~~~~~~~~~~~~~~~~~

✘ [ERROR] Build failed with 2 errors:

  ../node_modules/@vercel/og/dist/index.edge.js:9:23: ERROR: No loader is configured for ".wasm"
  files: ../node_modules/@vercel/og/dist/resvg.wasm?module
  ../node_modules/@vercel/og/dist/index.edge.js:10:22: ERROR: No loader is configured for ".wasm"
  files: ../node_modules/@vercel/og/dist/yoga.wasm?module

I get similar issues when trying to load the plugin into a normal (not pages) worker:

Uncaught ReferenceError:
  _Users_%User%_Work_%ProjectName%_node_modules__vercel_og_dist_resvg_wasm is
  not defined\n

The place in the esbuild output where the wasm should be loading just falls back to the undefined variable _Users_%User%_Work_%ProjectName%_node_modules__vercel_og_dist_resvg_wasm.

I tried following the instructions on https://developers.cloudflare.com/workers/wrangler/configuration/#bundling to bundle WASM by adding this to my wrangler.toml:

rules = [
  { type = "CompiledWasm", globs = ["**/*.wasm", "node_modules/**/*.wasm"], fallthrough = true }
]

but never see the wasm files in the build files afterwards.

@GregBrimble any ideas on these errors? Did you do anything specific with configuration for WASM when building this out?

I tried to get the plugin running on Pages Functions instead of bare workers, and now have the same issue that @itsmatteomanf encountered.



15:33:43.339 | ✘ [ERROR] 2 error(s) and 0 warning(s) when compiling Worker.
-- | --
15:33:43.340 |  
15:33:43.341 |  
15:33:43.343 |  
15:33:43.344 | ✘ [ERROR] No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/resvg.wasm?module
15:33:43.345 |  
15:33:43.345 | ../node_modules/@vercel/og/dist/index.edge.js:9:23:
15:33:43.345 | 9 │ import resvg_wasm from "./resvg.wasm?module";
15:33:43.345 | ╵                        ~~~~~~~~~~~~~~~~~~~~~
15:33:43.345 |  
15:33:43.345 |  
15:33:43.346 | ✘ [ERROR] No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/yoga.wasm?module
15:33:43.346 |  
15:33:43.346 | ../node_modules/@vercel/og/dist/index.edge.js:10:22:
15:33:43.346 | 10 │ import yoga_wasm from "./yoga.wasm?module";
15:33:43.346 | ╵                       ~~~~~~~~~~~~~~~~~~~~
15:33:43.346 |  
15:33:43.346 |  
15:33:43.347 | ✘ [ERROR] Build failed with 2 errors:
15:33:43.347 |  
15:33:43.347 | ../node_modules/@vercel/og/dist/index.edge.js:9:23: ERROR: No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/resvg.wasm?module
15:33:43.347 | ../node_modules/@vercel/og/dist/index.edge.js:10:22: ERROR: No loader is configured for ".wasm" files: ../node_modules/@vercel/og/dist/yoga.wasm?module
15:33:43.347 |  
15:33:43.347 |  
15:33:43.359 | Failed building Pages Functions.
15:33:44.133 | Failed: an internal error occurred

I think @GregBrimble figured out the issue, he just hasn't had the time to deploy a fix...

any updates? I'm facing the same error. But latest "wrangler": "3.16.0" still has the same issue.