Hi, I’m trying to load the wasm + esm library into a publish build. It works in the editor, but it doesn’t work in the build.
-
ESM asset URL is not importable in published build
In the Editor I can doimport('/api/.../libktx.mjs')and it works. But in the published build the same asset is served from.../js/esm-scripts/.../libktx.mjson S3 and that URL returns 403, so dynamicimport()fails. Is this S3 ESM path intentionally non-public? Is there a supported way to make an ESM asset importable in a published build? -
Exposing ESM to globalThis
Since the new ESM system removes hidden globals, is it acceptable/supported to add at the end of my own ESM module (for examplelibktx.mjs):
globalThis.createKtxModule = createKtxModule;
so that other scripts can use it in the published build (where import() is not possible)? Or is there a recommended / official way to expose functionality from an ESM script to the global scope?
-
Custom WASM + JS glue flow
Docs show how to use WASM Module assets, but how should we register a custom WASM + JS glue pair (likelibktx.wasm+libktx.mjs) so that PlayCanvas loads the JS glue first, and then we can call the factory from our game scripts? Is there an example of doing this with a user-provided ESM glue file? -
Keep ESM in /files/assets/
Is there any way (asset type or setting) to force an ESM script to stay under/files/assets/...on publish instead of being moved tojs/esm-scripts/...? The goal is to fetch/import it like a normal file. If not, is hosting the ESM on an external CDN the recommended workaround? -
Load order for external ESM
If we hostlibktx.mjsexternally and doglobalThis.createKtxModule = ...there, what is the supported way to make sure this script runs before the PlayCanvas scene ESM scripts in the published build?