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
In discussion of a StackOverflow question it reminded me have a situation we don't handle well, which could result in runtime errors (or unexpected behaviour).
The scenario is as follows:
There are two modules a.ts and b.ts
b.ts exports a value that is consumed by a.ts, which is a "main" module
Deno is run as deno a.ts
Both a.ts and b.ts are transpiled and cached
a.js and b.js are injected into the runtime
Changes are made to b.ts that remove the export
Deno is run as deno a.ts again
Deno invalidates the cache of b.ts and recompiles it
a.js and b.js are injected into the runtime
a.js fails at runtime because the export is no longer available in b.js
We need some sort of reverse dependency graph that we would need to persist along with the cached outputs, so we could determine if b.ts is invalidated that any modules that depend upon b.ts should also be invalidated.
This is a longterm issue to fix, not something that can be easily addressed, we still have some work to do in cleaning up the compiler and how we deal with modules, and how we cache modules before we would want to tackle this. It is just a reminder to not forget it.
The text was updated successfully, but these errors were encountered:
Thank you for the clear example. I've also had the sneaking suspicion that we had this bug but hadn't actually run into it nor took the time to think it through properly.
It would be great to get a failing integration test for this (which might be somewhat complicated).
I do think we need to be writing "depfiles" for each generated file (I can't find a link describing what a depfile is but it's essentially a simplified makefile)...
TypeScript compilation can and needs to be optimized significantly. The issue is that currently, after a change of file in the dependency tree, it's recompiled along with all of its descendants in the tree, which is completely unnecessary - its ancestors, the files that depend on the modified one, should be the one to be recompiled. In order to mitigate that, we can use the TS compiler's option to perform incremental compilation - that way it saves a build info file with all the dependencies and their hashes, and the next time it only recompiles the necessary files. For this to work correctly, we have to always start compilation from the same file, instead of skipping the root if it's already in the cache. I have a prototype working locally, if anyone's interested I can improve it and make a PR.
In discussion of a StackOverflow question it reminded me have a situation we don't handle well, which could result in runtime errors (or unexpected behaviour).
The scenario is as follows:
a.ts
andb.ts
b.ts
exports a value that is consumed bya.ts
, which is a "main" moduledeno a.ts
a.ts
andb.ts
are transpiled and cacheda.js
andb.js
are injected into the runtimeb.ts
that remove the exportdeno a.ts
againb.ts
and recompiles ita.js
andb.js
are injected into the runtimea.js
fails at runtime because the export is no longer available inb.js
We need some sort of reverse dependency graph that we would need to persist along with the cached outputs, so we could determine if
b.ts
is invalidated that any modules that depend uponb.ts
should also be invalidated.This is a longterm issue to fix, not something that can be easily addressed, we still have some work to do in cleaning up the compiler and how we deal with modules, and how we cache modules before we would want to tackle this. It is just a reminder to not forget it.
The text was updated successfully, but these errors were encountered: