Skip to content

Using standalone file_packager #24504

@lkwinta

Description

@lkwinta

I am working on porting Geant 4, physics simulator into Web Assembly. I will be downloading many huge datafiles so I figured out that manually creating emscripten datafiles with file packager might be great way to handle this problem.

Unfortunately, I have got into problem that I can't fix. Unfortunately, my project is quite modern and the only way I can load WASM is with modularize option - I can't pass global var as pre module.

Here is my data structure. I am using react with typescriprt. All data files and wasm binaries are inside public directory, hence I have to overwrite locateFile function. WASM processig will be done inside web worker.

Image

For the main Wasm import I am using such syntax:

import {default as MainModule} from "./geant4_wasm/geant4_wasm.js";

var preModule = {
 ...
}

var mod = MainModule(preModule);

I was trying to load file_packager's js. output using importScripts function inside web worker with global variable syntax but for some reason, while using webpack it doesn't work - global variable is not transfered to the imported file - i tried logging inside preload files, it loads but without initialization preModule.

var preModule = {
 ....
}

var Module = preModule;
importScripts("/preload_G4EMLOW8.6.1.js"); // file loads but with empty Module
// I have to access public directory in this case since unimported files are not packed inside react package

I kindly ask for adding similar modularize option for file_packager as for emcc or for suggestion how could i solve my problem.

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