External modules & optional core features #514
Replies: 5 comments 14 replies
-
I like your proposal. I thought you were going to suggest the usual expose all the headers and so on, but it's more sensible, I like it. We can iron out the details, but I like that you are thinking about build time!
I'm not so sure. I could easily add a So that would give us |
Beta Was this translation helpful? Give feedback.
-
I think I like it, there would be some stuff I wanted to add for my build too. Though there are CMake ways to handle stuff like this. Not that I am the greatest fan of cmake but if it's used it probably should be used consistently. |
Beta Was this translation helpful? Give feedback.
-
Hi @KaruroChori, I wanted to join the discussion since you mentioned the example of I think both for this repository and lv_binding_js, one of these two approaches (txiki.js as a library in the 'main' application I don't have a big preference or opinion, but intuitively for me, it makes more sense to have txiki.js as a dependency in a project that wants to extend it. And I agree that it would be nice if some features in the core, like wasm, could be disabled. |
Beta Was this translation helpful? Give feedback.
-
@jspngh Based on your updated code, I also started porting the quickjs bindings for lvgl as an external module. I opened https://github.com/KaruroChori/txiki-modules to track the selected packages I have been adapting/porting as txiki modules. |
Beta Was this translation helpful? Give feedback.
-
Sorry for my lack of understanding here, but what would the most naive implementation of
I'd be very interested in playing around with |
Beta Was this translation helpful? Give feedback.
-
Case
At the moment txiki.js is a monolithic distribution.
This poses several issues while integrating it in complete applications.
Avoiding forking
When integrating txiki.js in our application, we cannot disable core features which are not needed (like the sizable WebAssembly module) or adding new ones, unless we want to maintain a divergent branch.
The
ffi
module is great, has good ergonomics and shifts a lot of problems on the application side; still, its overhead is not always acceptable and there are cases in which a deeper integration of custom libraries with the runtime is the better choice; no less as they are compiled in faster bytecode viaqjsc
before bundling.This proposal would avoid the need for most of the divergent branches, ensuring the integrator with a greater degree of flexibility, and minimal impact on the current base-code & build process.
Platform specific modules & minimalism
As a monolithic distribution, there is some care needed when selecting features to avoid creep and ensure minimalism of the core runtime.
This can come at the expense of relevant but platform-specific modules which cannot be reasonably shipped as part of the main project; or, at the very least, they should not be enabled by default for everyone.
To provide some realistic examples:
Otherwise, we end up with a graveyard of side-projects using txiki.js like this. It manually embeds a now old version of txiki.js, and trying to fix this now is virtually impossible without a major refactoring.
Proposal
My suggestion is:
extras
sub-folders not tracked in git, where additional dependencies and core code can be added to the project (basically we would have to add those entries to.gitignore
once for all). They would have to coverdeps
,benchmark
,examples
,tests
,src/bundles/c
(shared across all extra modules) &src/
modules.toml
(or yaml/json, whatever) file to list all desired packages which are going to be downloaded and expanded in the relevant folder structure.extra
folders, and ensure they end up in the next build steps.modules.toml
file as before where core features can be flagged.I would like to stress that this is not meant to be a full packet manager, nor it should be.
All we need are:
master
branchSure, we can perform some very basic checks, like matching a specific version of the runtime (or a range of it), but this is as far as I would go.
Realistically we don't want and cannot ship multiple versions of the same module as core due to aliasing, so handling parenting, cyclic deps etc is not really something we should care to support.
External ts types
They are to be handled as separate npm packages. This is in line with what is done for the current core as well; as such their distribution is out of scope in respect to this proposal.
Affected issues
Implementing this proposal would offer some relief for #160.
It is not a full solution, but we can easily structure most of our application to be an external module, ensuring most of its code will be handled as bytecode, while keeping small bits and configuration as normal code.
Beta Was this translation helpful? Give feedback.
All reactions