Skip to content

v0.25.0

Compare
Choose a tag to compare
@github-actions github-actions released this 13 Jan 13:56
· 454 commits to main since this release
  • 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()
})