Closed Chooks22 closed 2 years ago
Moving to implement a feature for hot reloading that might lock this project in CommonJS.
If anyone more versed in ES Modules' caching in node is interested (or can at least give insights), dm me at discord Chooks22#6725
A small update on this:
I have a working prototype for this locally. Still not yet fully tested and not 100% sure I will be able to integrate, but things are looking pretty good.
How it works is splitting the cli commands to its own global package (so running chooks
directly in the terminal), then having maybe separate code for esm/cjs (not yet tested), with the esm code being accessible with the --esm
flag.
The outcome will be a new global cli package, and whats left of the current framework will be a new "core" package. And since it's a trimmed down version of what it used to be, the current lib
, types
, and validation
packages will be merged for simplicity.
Not sure if bundler is necessarily needed, might just hack in another tsconfig file or just do it in the build script.
Biggest road block here is hot reloading, since commonjs' equivalent for
require.cache
currently in use is not available in es modules.The following snippet seems to work, and switching between esm and cjs should be straightforward, but it leads to memory leaks in dev mode.