You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on #970, I'm realizing that modifying the rootFiles array feels super-slow, and it might be way slower than modifying existing files to import extra stuff.
We can maintain a synthetic $$ts-node-rootfiles.ts script in memory. When we need to trigger inclusion of another file, we append a /// <reference path="" /> to our synthetic script.
This wouldn't work with noResolve, but honestly who uses noResolve? And those users will need to turn on --files which avoids the whole problem anyway.
Blocked by #970, since overriding isExternalLibraryImport eliminates the need to add external files to rootFiles.
Older notes to myself below this line
Crazy idea to avoid rootFiles
ts-node maintains a synthetic /<project-dir>/$$ts-node-requires$$.ts script in memory.
Every time our require() hook is called, check if the target file is already in the program. If not, we want to pull the target file into the program. We append an import statement to our synthetic script.
We ask the language service for diagnostics and emit. TS compiler does incremental parsing of our synthetic file, resolves the appended import statement, and pulls in the require() target.
The text was updated successfully, but these errors were encountered:
While working on #970, I'm realizing that modifying the
rootFiles
array feels super-slow, and it might be way slower than modifying existing files to import extra stuff.We can maintain a synthetic
$$ts-node-rootfiles.ts
script in memory. When we need to trigger inclusion of another file, we append a/// <reference path="" />
to our synthetic script.This wouldn't work with
noResolve
, but honestly who usesnoResolve
? And those users will need to turn on--files
which avoids the whole problem anyway.Blocked by #970, since overriding
isExternalLibraryImport
eliminates the need to add external files torootFiles
.Older notes to myself below this line
Crazy idea to avoid
rootFiles
ts-node maintains a synthetic
/<project-dir>/$$ts-node-requires$$.ts
script in memory.Every time our
require()
hook is called, check if the target file is already in the program. If not, we want to pull the target file into the program. We append an import statement to our synthetic script.We ask the language service for diagnostics and emit. TS compiler does incremental parsing of our synthetic file, resolves the appended import statement, and pulls in the
require()
target.The text was updated successfully, but these errors were encountered: