Skip to content

Fix the AnyPIAJS tests: Recompile AnyPIAJS for NodeJS #209

@thadk

Description

@thadk

Make another build of AnyPIAJS with the latest version for late 2020, and that works with NodeJS.

I used the below line to replace https://github.com/codeforboston/anypia-js/blob/master/anypiajs/CMakeLists.txt#L67 along with ./installbuild-emscripten-mac.sh to compile it for this project using the July 2020 version of Emscripten.

In this repo, I permanently cached a version of the generated 1.9mb web assembly binary file as /src/static/anypiajs.wasm (it is a special Gatsby folder like /public/). I also added the associated file https://github.com/codeforboston/windfall-elimination/blob/243a300b9ad7316bb6af586f6d15ec060b7610f9/src/library/anypiajs.mjs.

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-s USE_BOOST_HEADERS=1" LINK_FLAGS "-s USE_BOOST_HEADERS=1 -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=1 -s ENVIRONMENT=web -MODULARIZE=1 -s WASM=1 --bind ${EXPORTED_FUNCTIONS} ${EXPORTED_RUNTIME_METHODS}")

In the resulting anypiajs.mjs, I had to manually edit

var Module = (function() {
  var _scriptDir = import.meta.url;

to

var Module = (function() {
  var _scriptDir = "/anypiajs.wasm";

This ENVIRONMENT=web piece breaks nodejs testing though, so the tests I wrote in https://github.com/codeforboston/windfall-elimination/blob/243a300b9ad7316bb6af586f6d15ec060b7610f9/src/test/pia-index.test.ts cannot run yet.

If we make another version, we should make a new versioned name for this wasm filename (and update the path in the manual edit, since that one will be permanently cached once we merge it)

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