FishyW / engine

boring stuff nothin to see here
MIT License
0 stars 0 forks source link

Mainly implemented dynamic imports #2

Closed FishyW closed 7 months ago

FishyW commented 7 months ago

Features:

exportWasm() to export a function to wasm. This function also internally snake cases Javascript functions. It optionally can receive a namespace argument.

modifyGlobalFetch() is used to modify the browser's fetch() function. Add modifications to the fetch function here.

Dynamic imports now work. To do a dynamic import, call convertFileSrc() specifying the protocol (ie. "fetch" protocol) then await import the file.

    const file = convertFileSrc(`${WASM_PATH}/project.js`, PROTOCOL);
    const wasm: Wasm = await import(file);

Reloading now can be done using Ctrl+R.

Also note that you need to add an additional path.ts file inside of the routes folder to specify where the wasm file is. See routes/README.md.

Before pulling this commit, pull the engine-lib github first (theres an extra index.ts file added under wasm).