Can't import sql-wasm.wasm
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 13.7k
- Forks
- 1.1k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?

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


Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, react, sqlite, wasm
- Área
- databases, frontend, web-dev
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100