Cannot set property 'exports' of undefined
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'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();
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- electron, javascript, sqlite, wasm, webpack
- Lĩnh vực
- build-system, database, desktop
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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
- 35/100