Cannot set property 'exports' of undefined #406
Comments
likely either in if you change your code to the following, you can figure out where the problem is: +console.log("webpack module.exports is ok");
const initSqlJs = require('sql.js');
+console.log("sqljs module.exports is ok");
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(); |
Hey @kaizhu256, thanks for the suggestion. I tried putting the logging statements and they both work fine (which is confusing and annoying). I checked the stack trace of the error and I'm seeing the error when I call
|
searching thru the source code, the only place where so i'm stumped as well. |
After doing some more digging I'm even more confused. The error was coming from
Which is weird, so I checked the original file in the
The latter block makes perfect sense, this is what I'd expect. The first block is really strange but it does explain why my code is failing. For whatever reason On a semi-related note, I originally was testing this code with source maps enabled, which would show the latter block of code but behind the scenes it must have actually been running the first block of code. So while debugging I was seeing the code enter the if statement despite the fact that the expression evaluated to false. I was starting to question everything I knew about software development |
The same issue. Quick and dirty workaround which works for my project:
Than I recompilled sql.js and imported the single sql-wasm.js to the project. |
I have the same porblem too. |
I just ran into this problem as well. Comment by @amura11 pretty much nailed the issue with Webpack trying to be smart by statically optimize In my Webpack config, I added the following lines to bundle
|
module: { |
Did you report this bug to webpack ? |
the issue is still persisting Uncaught (in promise) TypeError: Cannot set property 'exports' of undefined |
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 ininitSqlJs
before it gets to locating the wasm binary.My setup is as follows:
WebPack Config
Main Code
The text was updated successfully, but these errors were encountered: