How to include wasm file/binding with wranger + webpack?

I would like to use WebAssembly using Cloudflar workers.
I’m using Node.js v12.18.4 and wrangler to build and deploy our project.

I would like to use rust library and the maintainer created wasm file and uploaded to npm.

I’ve written codes by following the library’s documentation but it returns “Uncaught SyntaxError: Illegal return statement” on development environment (wrangler dev). The status code is 523.

How can I use distribution build wasm on wrangler, webpack environment?

I could not find solution with the error message only.


addEventListener('fetch', event => {
 * Respond with hello worker text
 * @param {Request} request
async function handleRequest(event) {
  import("@silvia-odwyer/photon").then(photon => {
  return new Response("Hello world")


module.exports = {
  target: 'webworker',
  devtool: "cheap-module-source-map",
  mode: 'development',
  optimization: {
    usedExports: true,


name = "test"
type = "webpack"
account_id = "q1234"
route = ""
zone_id = ""
workers_dev = true
webpack_config = "webpack.config.js"