v0.25.0
- Initialization breaking change (#22)
Initialization Breaking Change:
before
Module.onEmnapiInitialized = function (err, emnapiExports) {
if (err) {
console.error(err)
return
}
emnapiExports.doSomething()
}
Module.onRuntimeInitialized = function () {
Module.emnapiExports.doSomething()
}
// -sMODULARIZE=1
Module().then(function (Module) {
Module.emnapiExports.doSomething()
})
after
npm install @tybys/emnapi-runtime
<script src="node_modules/@tybys/emnapi-runtime/dist/emnapi.min.js"></script>
const emnapi = require('@tybys/emnapi-runtime') // Node.js
const emnapi = window.emnapi // Browser
const context = emnapi.createContext()
Module.onRuntimeInitialized = function () {
try {
var binding = Module.emnapiInit({ context })
} catch (err) {
console.error(err)
return
}
binding.doSomething()
}
// -sMODULARIZE=1
Module().then(function (Module) {
try {
var binding = Module.emnapiInit({ context })
} catch (err) {
console.error(err)
return
}
binding.doSomething()
})