https://kotlinlang.org logo
#javascript
Title
# javascript
s

Shubham Singh

01/26/2023, 10:03 AM
Hey everyone I'm trying to implement
SQLDelight
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
Copy code
// project/webpack.conf.d/fs.js
config.resolve = {
    fallback: {
        fs: false,
        path: false,
        crypto: false,
    }
};
and
wasm.js
Copy code
// 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:
r

Robert Jaros

01/26/2023, 10:10 AM
Check this generated
webpack.config.js
file (in the
build/js/packages/play......./
directory) to see what is in the line 143.
s

Shubham Singh

01/26/2023, 10:12 AM
This is line 143:
config.resolve.modules.push("../../processedResources/js/main");
r

Robert Jaros

01/26/2023, 10:12 AM
your new
fs.js
file has broken
config.resolve
object
Check the begining of this file - you should have something like
Copy code
let config = {
  mode: 'development',
  resolve: {
    modules: [
      "node_modules"
    ]
  },
  plugins: [],
  module: {
    rules: []
  }
};
change your
fs.js
to also contains
modules: ["node_modules"]
or just add fallback object:
Copy code
config.resolve.fallback = {
        fs: false,
        path: false,
        crypto: false
}
1
🙌 1
s

Shubham Singh

01/26/2023, 10:19 AM
The
let 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 👏
44 Views