Is there a way to build a binding without adding default to the require().default?
Trying to use an older package that requires js syntax like so:
var npmPackage = require("npm-package")
var result = npmPackage("my-string")
I currently have it as so, but its adding .default to the bs.js files.
@bs.module("npm-package") external convert: string => string = "default"
If I understand your question correctly, you omit the argument to bs.module and put it as the string at the end instead: https://rescript-lang.org/docs/manual/latest/import-from-export-to-js#import-a-javascript-module-itself-commonjs
2 Likes
Try:
@module external convert: string => string = "npm-package"
Also in newer version of bs-platform you can omit “bs.”
1 Like
Thanks @faliszek and @benadamstyles - this was exactly what I was looking for.
1 Like