waddler icon indicating copy to clipboard operation
waddler copied to clipboard

Using waddler in workers doesn't work if importing from root

Open yacobmole opened this issue 3 months ago • 0 comments

Minimal Repoduction Repo

https://github.com/yacobmole/waddler-worker

If you import from "waddler" in cloudflare workers the worker fails due to using NodeJS specific methods and imports

For example:

✘ [ERROR] Could not resolve "buffer"


  node_modules/.pnpm/@[email protected]/node_modules/@clickhouse/client/dist/utils/stream.js:10:25:
        10 │ const buffer_1 = require("buffer");
           ╵                          ~~~~~~~~

    The package "buffer" wasn't found on the file system but is built into node.
    - Add the "nodejs_compat" compatibility flag to your project.

The following worker will fail to build.

/**
 * Welcome to Cloudflare Workers! This is your first worker.
 */

// #region Standalone sql query builder for D1
import { sql } from 'waddler/d1';

const _statement = sql`SELECT 1`.toSQL();
// #endregion Standalone sql query builder for D1

// #region This section causes the worker to fail
import { SQLValues } from 'waddler';

const _test = new SQLValues([]);
// #endregion This section causes the worker to fail

// Exported Worker
export default {
	async fetch(): Promise<Response> {
		return new Response('Hello World!');
	},
} satisfies ExportedHandler<Env>;

yacobmole avatar Sep 15 '25 08:09 yacobmole