diff --git a/packages/plugin-wasm/docs/interfaces/WasmPluginOptions.md b/packages/plugin-wasm/docs/interfaces/WasmPluginOptions.md index e7f9182d..b2989ccc 100644 --- a/packages/plugin-wasm/docs/interfaces/WasmPluginOptions.md +++ b/packages/plugin-wasm/docs/interfaces/WasmPluginOptions.md @@ -31,7 +31,7 @@ with) Emscripten versions 2.0.34 and 3.1.46, among others. -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 -s ENVIRONMENT='web,webview,worker' - -s EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers'] + -s EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers'] -s EXPORTED_RUNTIME_METHODS=['cwrap'] ``` diff --git a/packages/plugin-wasm/src/options.ts b/packages/plugin-wasm/src/options.ts index 257f7e1d..4cec5336 100644 --- a/packages/plugin-wasm/src/options.ts +++ b/packages/plugin-wasm/src/options.ts @@ -22,7 +22,7 @@ export interface WasmPluginOptions { * -s EXPORT_ES6=1 * -s USE_ES6_IMPORT_META=0 * -s ENVIRONMENT='web,webview,worker' - * -s EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers'] + * -s EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers'] * -s EXPORTED_RUNTIME_METHODS=['cwrap'] * ``` */ diff --git a/packages/plugin-wasm/src/plugin.ts b/packages/plugin-wasm/src/plugin.ts index 731d0503..4b267b0f 100644 --- a/packages/plugin-wasm/src/plugin.ts +++ b/packages/plugin-wasm/src/plugin.ts @@ -128,7 +128,7 @@ async function buildWasm( // and Node.js contexts (tested in Emscripten 2.0.34 and 3.1.46). addFlag(`ENVIRONMENT='web,webview,worker'`) addFlag( - `EXPORTED_FUNCTIONS=['_malloc','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']` + `EXPORTED_FUNCTIONS=['_malloc','_free','_getMaxOutputIndices','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']` ) addFlag(`EXPORTED_RUNTIME_METHODS=['cwrap']`) } diff --git a/packages/runtime/README.md b/packages/runtime/README.md index b0e900de..9055f72e 100644 --- a/packages/runtime/README.md +++ b/packages/runtime/README.md @@ -128,13 +128,14 @@ $ emcc \ build/.c build/macros.c build/model.c build/vensim.c \ -Ibuild -o ./output/.js -Wall -Os \ -s STRICT=1 -s MALLOC=emmalloc -s FILESYSTEM=0 -s MODULARIZE=1 \ --s EXPORTED_FUNCTIONS="['_malloc','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']" \ +-s EXPORTED_FUNCTIONS="['_malloc','_free','_getInitialTime','_getFinalTime','_getSaveper','_runModelWithBuffers']" \ -s EXPORTED_RUNTIME_METHODS="['cwrap']" ``` Note that the generated module must export the following functions at minimum: - `_malloc` +- `_free` - `_getInitialTime` - `_getFinalTime` - `_getSaveper`