Quasar Upgrade MSSQL fails FIXED (Inegalantly): Working on a new program, I had MSSQL working but I when upgraded Quasar, the problem re-appeared, and it caused an older program that was working to no longer compile with the same errors. I’ve upgraded NPM, VS Build tools, reinstalled MSSQL, tedious and msnodesqlv8 modules; ran electron-rebuild. Two modes of failure, below. Non-Quasar Electron program using MSSQL still works, so problem is definitely introduced by Quasar. Sam
Two methods, each with different error message:
import sql from ‘mssql’ <using default driver tedious> gets webpack_require is not a function
import sql from ‘mssql/msnodesqlv8’ gets "specified module could not be found: node_modules\msnodesquv8\build\Release/ec1\0188…node
Ahah (Ugh): By trial and error I got it to work with the following Webpack theatrics, including null-loader. If anyone can figure out what is the right way to do this I would like to know and hopefully others can use Quasar Electron MSSQL (and Azure SQL): <7/2: I ended up using msnodesqlv8 rather than default tedious, as for some reason I could not get the connection to complete. Other settings that may or may not matter: bundler: ‘builder’ and target: ‘electron-renderer’ )
// https://quasar.dev/quasar-cli/handling-webpack
extendWebpack (cfg) {
cfg.module.rules.push({
enforce: ‘pre’,
test: /.(js|vue)$/,
loader: ‘eslint-loader’,
exclude: /node_modules/
})
cfg.externals = {
mssql: “require(‘mssql’)”,
tedious: “require(‘tedious’)”,
msnodesqlv8: “require(‘msnodesqlv8’)” // added 7/2
}
cfg.module.rules.push({
test: /.node$/,
use: ‘node-loader’
})
cfg.target = ‘electron-renderer’
// 7/1/20 trying this see
cfg.module.rules.push({
test: /.mssql$/,
loader: ‘null-loader’
})
cfg.module.rules.push({
test: /(tedious)/,
loader: ‘null-loader’
})
}