Skip to content

Unable to bundle due to "fs" (sveltekit + cloudflare workers). #620

@hadson172

Description

@hadson172

Sql.js seems like really amazing pice of technology so I would like to use it in one of the projects.
The tech stack of project is

  • sveltekit
  • cloudflare workers

Started for the project was taken from here - https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-kit-site/#setting-up-a-new-project

I would like to use sqlite inside svelte' loader function (+layout.server.ts) to be more specific. It is the code which runs on the server (cloudflare workers) due to fetch requests to load the data.

My setup looks like this:

import initSqlDb from 'sql.js/dist/sql-wasm.js';
	
const SQL = await initSqlDb();

i've tried also this

import initSqlJs from "sql.js/dist/sql-wasm.js";

const SQL = await initSqlJs({
  locateFile: file => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.6.2/${file}`
});

Here is the error I am getting:

Image

As you can see, it is correltly linked to wasm.js version.

When I look inside sql-wasm.js file, I see that there is fs reference:

Image

Is it possible to make this working somehow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions