Skip to content

Using sql.js with next js fails #309

@martonlanga

Description

@martonlanga

Bug report

Describe the bug

Trying to use sql.js in a nextjs project throws an error, while trying to initialize the module.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. npx create-next-app next-sql.js
  2. cd next-sql.js/
  3. npm i sql.js
  4. Inside pages/index.js:
import initSQL from "sql.js";

const Page = () => {
  console.log(initSQL);
  console.log(initSQL());
  initSQL().then(SQL => {
    console.log(SQL);
    const db = new SQL.Database();
    console.log(db);
  });

  return null;
};

export default Page;
  1. npm run dev
  2. See Error in Console

Expected behavior

Ability to import and use sql.js like in the example provided here.

Screenshots

Mozilla-Console
Chrome-Console

Additional context

Also, without defining fs in next.config.js, sql-wasm.js throws a module not found error about the fs module.
My guess is that I should change my config settings to support wasm, but I'm not really familiar with that.

Issue in next.js repo.

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