@sveltejs/adapter-cloudflare problem in a monorepo

I have a local workspace package that I import into my sveltekit project. Lets say this package has kysely and @libsql/kysely as its dependencies. Consuming this package results in a build failure like this:
Could not resolve "node:stream"
.svelte-kit/output/server/entries/pages/(auth)/onboarding/_page.server.js:14:19:
14 │ import stream from "node:stream";
╵ ~~~~~~~~~~~~~
The package "node:stream" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Could not resolve "node:stream"
.svelte-kit/output/server/entries/pages/(auth)/onboarding/_page.server.js:14:19:
14 │ import stream from "node:stream";
╵ ~~~~~~~~~~~~~
The package "node:stream" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Now if I pnpm install the dependencies of the workspace package directly to the sveltekit project, so in this case kysely and @libsql/kysely, the build is successful. This means that whenever sveltekit consumes a package, I would need to make sure that sveltekit has its dependencies explicitly installed as well. I have confirmed this with a package that uses @aws-sdk as well. Build fails when @aws-sdk is not directly installed to sveltekit, works when it is installed.
2 Replies
chientrm
chientrm10mo ago
npm
@chientrm/adapter-cloudflare
Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration. Latest version: 2.3.4, last published: 12 days ago. Start using @chientrm/adapter-cloudflare in your project by running npm i @chientrm/adapter-cloudflare. There are no other projects in the npm registry using @chientrm/adapter-cloudflare.
chientrm
chientrm10mo ago
in svelte.config.js, change adapter line to this:
adapter: adapter({ nodeCompat: true }),
adapter: adapter({ nodeCompat: true }),