Skip to content

npm module: Electron and Node linuxduino.wasm file load  #3

@jgarzagu

Description

@jgarzagu

Currently is difficult to load a wasm file from another directory. When installing the linuxduino npm module there is an error when requiring linuxduino as it files to load wasm. See (emscripten-core/emscripten#5342). Currently there is no an actual solution from emscripten.

Solution/Workaround

Knowing that this code will only run on linux the following code in the linuxduino.js output was modified:

var wasmBinaryFile = Module['wasmBinaryFile'] || 'serial.wasm');

to this:

if (typeof window === 'object') {
	// If running Electron+Node
	var wasmBinaryFile = Module['wasmBinaryFile'] || 'serial.wasm';
	} else {
	// If running Node
	var wasmBinaryFile = Module['wasmBinaryFile'] || (__dirname+'/serial.wasm');
} 

This works perfect for running linuxduino with node. But when using Electron with the linuxduino code hosted from a server you need to include the linuxduino.wasm file next to the file that does the require('linuxduino') in the server files.

TODO: Find a better solution or wait for emscripten to solve this.

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