jupyterlite / xeus-lua-kernel

A Lua kernel for JupyterLite, powered by Xeus
https://jupyterlite.github.io/demo
BSD 3-Clause "New" or "Revised" License
12 stars 8 forks source link

Bundle the wasm file #5

Open DerThorsten opened 3 years ago

DerThorsten commented 3 years ago

now that we move the xeus lua related files to the asset dir via https://github.com/DerThorsten/jupyterlite_xeus_lua/blob/3a22e56672ef5aca0655fc64aaa39fac74e5b6a2/webpack.config.js#L4

we are facing the problem that xeus_lua.js it not found

ModuleNotFoundError: Module not found: Error: Can't resolve './xeus_lua' in '/home/derthorsten/src/jupyterlite_xeus_lua/lib'
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/Compilation.js:1930:28
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:793:13
    at eval (eval at create (/home/derthorsten/src/jupyterlite_xeus_lua/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:275:22
    at eval (eval at create (/home/derthorsten/src/jupyterlite_xeus_lua/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:431:22
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:124:11
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:665:25
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:850:8
    at /home/derthorsten/src/jupyterlite_xeus_lua/node_modules/webpack/lib/NormalModuleFactory.js:970:5
resolve './xeus_lua' in '/home/derthorsten/src/jupyterlite_xeus_lua/lib'
...
...
...

@jtpio you mentioned:

Locally excluding the emscripten generated files seems to help build the extension.

However the files are not properly emitted to labextension/static yet.

@jtpio any hint on how to continue on that?

Do we need to change the import statement? https://github.com/DerThorsten/jupyterlite_xeus_lua/blob/3a22e56672ef5aca0655fc64aaa39fac74e5b6a2/src/worker.ts#L3

this is all a bit beyond my typescript / webpack competence ...

jtpio commented 3 years ago

we are facing the problem that xeus_lua.js it not found

This part seems to be because xeus_lua.js is not in lib and webpack doesn't find it. So we can reintroduce the copy-files script make sure they are.

Do we need to change the import statement?

Also the wasm file seems to be defined in the emscripten generated file like this:

image

Ideally webpack should be able to find it, so it can generate a URL to the asset automatically (with the public path).

I'm continuing in #6.

DerThorsten commented 3 years ago

bevore I jused the CopyPlugin for the wasm file. Since webpack only looks for imports it is not touching the xeus_lua.wasm string. (since there is nothing like import 'xeus_lua.wasm' ) https://github.com/DerThorsten/jupyterlite/blob/65762755e33aa661a5f46f037eefb1c347aac06a/app/webpack.config.js#L268

jtpio commented 3 years ago

Yes maybe we'll have to use the same approach for now.

Ideally we can find a way to tell webpack to find this wasm file, so it places it along the others under labextension/static, and is able to locate it via a URL such as /lab/extensions/@jupyterlite/xeus-lua/static/12345.wasm (since the extension will be loaded as a federated module).

jtpio commented 3 years ago

I renamed the issue to "Bundle the wasm file" so we can come back to how to best handle the copy of the wasm file later.