sql-js / sql-js/sql.js

Can't import sql-wasm.wasm

Đang mở
#480 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
JavaScript
Star
13.7k
Fork
1.1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I want to make sqlite db and browser work together offline in reactJS. I am using "react": "^17.0.2",

It seems there is a sqljs, sql-js and sql.js existing at the same time. Why do you use - in the name? To confuse?

image

I dare to install new version of it and used this demo
https://github.com/sql-js/react-sqljs-demo

And it complains on import string

import sqlWasm from "!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm";

src/App.js
Line 6:1: Unexpected '!' in '!!file-loader?name=sql-wasm-[contenthash].wasm!sql.js/dist/sql-wasm.wasm'. Do not use import syntax to configure webpack loaders import/no-webpack-loader-syntax

After I delete !! in it it complains on

  useEffect(async () => {
    // sql.js needs to fetch its wasm file, so we cannot immediately instantiate the database
    // without any configuration, initSqlJs will fetch the wasm files directly from the same path as the js
    // see ../craco.config.js
    try {
      const SQL = await initSqlJs({ locateFile: () => sqlWasm });
      setDb(new SQL.Database());
    } catch (err) {
      setError(err);
    }
  }, []);

put async inside useEffect. I just want to extract some data from SQLite DB offline

Maybe you could provide code to work with existing DB on localhost offline with use of react ?

P.S.
another approach doesn't work for me either even I put wasm file in the root folder

image

image

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Start with the linked react-sqljs-demo, then inspect src/App.js and the referenced craco.config.js around the sql.js/dist/sql-wasm.wasm import and initSqlJs call. Reproduce the loader and useEffect errors with the reported React version. Done means an existing SQLite database can be loaded and queried offline in the React app without the reported import or WASM errors.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, react, sqlite, wasm
Lĩnh vực
databases, frontend, web-dev
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.