Cannot set property 'exports' of undefined

Aperta
#406 16 commenti 8 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
electron, javascript, sqlite, wasm, webpack

Direzione di ricerca

Start with the Webpack configuration and the require('sql.js') call, then inspect where initSqlJs fails before locateFile runs. Reproduce the error in the Electron renderer and compare the bundled module/export behavior; done means determining whether the configuration or sql.js causes the error and documenting a verified resolution.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I'm trying to get Sql.js working with TypeORM inside Electron as part of the renderer but I'm running into an error I don't know how to handle. I'm getting the error: TypeError: Cannot set property 'exports' of undefined. I'm not sure if this is a configuration issue on my end or if there's some sort of bug. It seems like the error happens somewhere in initSqlJs before it gets to locating the wasm binary.

My setup is as follows:

WebPack Config

module.exports = {
    entry: {main: './main.ts'},
    output: {/*Removed for brevity*/},
    target: 'electron-renderer',
    module: {/*Removed for brevity*/},
    plugins: [
        /*Other plugins removed for brevity*/
        new Webpack.NormalModuleReplacementPlugin(/typeorm$/, function (result) {
            result.request = result.request.replace(/typeorm/, "typeorm/browser");
        }),
        new Webpack.ProvidePlugin({
            'window.SQL': 'sql.js/dist/sql-wasm.js'
        }),
        new CopyPlguin({
            patterns: [
                {from: './node_modules/sql.js/dist/sql-wasm.wasm'}
            ]
        })
    ]
}

Main Code

const initSqlJs = require('sql.js');

const SQL = await initSqlJs({
	locateFile: (file: any) => {
		console.log(file); //This line is never printed
		return `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.1.0/dist/${file}`}
});

var db = new SQL.Database();
Lingua principale
JavaScript
Stelle
13.7k
Fork
1.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sql-js/sql.js

Tutte le issue di sql-js/sql.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.