Allow transpiled JS to be imported by external modules #662
Labels
area: ffi
The {:extern} attribute and otherwise interfacing with code in other languages
kind: enhancement
Enhancements, feature requests, etc. These are NOT bugs, but ways we can improve Dafny
lang: js
Dafny's JavaScript transpiler and its runtime
part: code-generation
Support for transpiling Dafny to another language. If relevant, add a `lang:` tag
Currently the Dafny to JS transpiler compiles JS that is very difficult to reference from an external module. As is, there are a couple of issues that block being able to use generated code in a meaningful way:
import
orrequire
objects defined in the generated JS. For my own work I have been getting around this by manually insertingmodule.exports = { ... }
in the generated file to explicitly export any module/class/object that I need to reference in my external module.const myExtern = require(./path/to/extern)
to the generated javascript.Additionally, we need documentation to show how one can build a JS module using the dafny to JS transpiler, which looks like any other native module, and can be imported and used the same as any other native module.
The text was updated successfully, but these errors were encountered: