JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 264
  • Score
    100M100P100Q98926F
  • License MIT

Decorators for writing Emscripten libraries

Package Exports

  • emscripten-library-decorator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (emscripten-library-decorator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

emscripten-library-decorator

This package provides decorators for writing Emscripten libraries. Include them in a TypeScript source file by adding a reference path in the beginning pointing to index.ts like:

/// <reference path="node_modules/emscripten-library-decorator/index.ts" />

function _print(message: string) {
    console.log(message);
}

@exportLibrary
class test {
    @dep(_print)
    static hello() {
        _print('Hello, World!!');
    }

    static foobar = 42;
};

The class decorator @exportLibrary exports the static members of the class as an Emscripten library. Place it with no arguments just before the class.

The property decorator @dep is for listing dependencies. It ensures that when an exported function is used in the C or C++ code, other required functions are also included in the compiled Emscripten output after dead code elimination. Place it just before a function with any number of parameters listing the other required functions.

The dependencies should be global functions and their name should begin with an underscore. Otherwise Emscripten's name mangling will change their name in the output making any calls to them fail.

There is a longer article with more information.

License

The MIT License

Copyright (c) 2015 BusFaster Ltd