Skip to content

Including an emscripten module in browserify build process #5864

@txusinho

Description

@txusinho

#Hi all,

First of all, I would like to apologize if this is not the right place to ask for help to solve this issue. I'm a browserify user, and since I have problems just with a file create by emscripten, I assume the problem might live here.

Long story short, I'm importing an emscripten module in the frontend using browserify. At execution time, the module exists, but empty.

You can reproduce the issue as follows (requires emcc and browserify installed system wide):

  • Get the code from this repo
  • Compile this file using emcc. I've used this command: emcc main.cpp -o main.js -s EXPORTED_FUNCTIONS="['_int_sqrt']"
  • Create a bundle using browserify (which must be installed system wide): browserify index.js > bundle.js
  • Open index.html in a browser, and you'll see an error in the developer console and one array showing the content of the Module object (this is, an empty array)

I've already tested that the generated code is correct: running in a node environment, works as expected (there is a demonstration using mocha here

PD: I have the same test case, but with a more elaborated toolchain in this repo with a readme to reproduce all the steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions