Now to invoke this program, the parent project (or user via CLI) must pass in where the "pages" directory exists.
This is extremely brittle because it needs to resolve the full path, and know the difference between if it is invoked via node or tsx (tsx runs typescript natively)
This becomes an issue because it needs to import from src/ instead of dist/ if its running the TypeScript version, for example.
The runtime also must normalize the "base" directory, perhaps derived from the filepath of the executable argv[1]
Then it must check if the directory exists.
Not sure if most robust implementation but a checklist could be:
Detect if runtime is Node or TSX.
If Node, expect dist/ ??
If TSX, expect src/ ??
Resolve relative path based on current working directory of shell when program is invoked (parse argv[0])
This is important because the TypeScript modules are nested deeply in other directories which quickly breaks the relative path.
Currently this kernel is to be imported into a parent project e.g. https://github.com/pavlovcik/scraper-parent-test/tree/main/src
In the parent project, it should include all of the "pages" logic (the logic that will be imported when the browser is currently on that page. https://github.com/pavlovcik/scraper-parent-test/tree/main/src/pages
Now to invoke this program, the parent project (or user via CLI) must pass in where the "pages" directory exists.
This is extremely brittle because it needs to resolve the full path, and know the difference between if it is invoked via node or tsx (tsx runs typescript natively)
src/
instead ofdist/
if its running the TypeScript version, for example.argv[1]
Not sure if most robust implementation but a checklist could be:
dist/
??src/
??argv[0]
)