Open ry opened 7 months ago
This is trouble, it's essentially custom loaders: https://nodejs.org/docs/latest/api/module.html#customization-hooks that need to be executed before the actual code is executed.
I wonder if it might be best to bypass this module somehow. The sole purpose of the tsx
module is to allow node to work natively with TypeScript files.
The the observable
package only used module.register()
to add support for running TS code, this works now thanks to https://github.com/denoland/deno/pull/24965 . There the function is merely stubbed, but that's enough to unblock observable
.
I would benefit from Deno supporting that. @bartlomieju FWIW, Node has a static and dynamic mode for that. With the --import
flag, it indeed needs to run before any code is loaded, but programmatically (this issue's case), it can be executed at any time in the lifecycle of the program, but then only applies to thereafter dynamically imported modules.
Interestingly enough, normal (static) imports from post-registration dynamically loaded modules seem to also work in my tests.
Version: deno 1.42.1+92a8ada
https://nodejs.org/docs/latest/api/module.html#moduleregisterspecifier-parenturl-options