Shubham Singh
01/26/2023, 10:03 AMSQLDelight
in a KMP project that supports Android, iOS, JS and JVM
In case of JS
, the documentation suggests adding the following files inside webpack.conf.d
package (which in my case is webpack.config.d
since I used KVision to build my JS project):
fs.js
// project/webpack.conf.d/fs.js
config.resolve = {
fallback: {
fs: false,
path: false,
crypto: false,
}
};
and
wasm.js
// project/webpack.conf.d/wasm.js
const CopyWebpackPlugin = require('copy-webpack-plugin');
config.plugins.push(
new CopyWebpackPlugin({
patterns: [
{
from: '../../node_modules/sql.js/dist/sql-wasm.wasm',
to: '../../../{your project}/build/distributions'
}
]
})
);
Alongwith that, I need to add 2 npm deps as well i.e. sql.js
and copy-webpack-plugin
I did it all, but when I try to launch the app, I see the following error:Robert Jaros
01/26/2023, 10:10 AMwebpack.config.js
file (in the build/js/packages/play......./
directory) to see what is in the line 143.Shubham Singh
01/26/2023, 10:12 AMconfig.resolve.modules.push("../../processedResources/js/main");
Robert Jaros
01/26/2023, 10:12 AMfs.js
file has broken config.resolve
objectRobert Jaros
01/26/2023, 10:14 AMlet config = {
mode: 'development',
resolve: {
modules: [
"node_modules"
]
},
plugins: [],
module: {
rules: []
}
};
Robert Jaros
01/26/2023, 10:15 AMfs.js
to also contains modules: ["node_modules"]
Robert Jaros
01/26/2023, 10:17 AMconfig.resolve.fallback = {
fs: false,
path: false,
crypto: false
}
Shubham Singh
01/26/2023, 10:19 AMlet config
variable was set up exactly how you described
or just add fallback object:
```config.resolve.fallback = {
fs: false,
path: false,
crypto: false
}```This helped.. now the project is working fine! Thank you very much Robert 👏