-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle output of TS compiler for JS and JSON files #2658
Comments
I would strongly object removing The |
Thanks for the reply @kitsonk, I have some questions though:
Sounds good to me, we just need to figure out how to decide if something should be cached or discarded.
Currently it is pretty bad, this bit handles JSON: Lines 46 to 60 in 621af21
Currently TS compiler doesn't perform any trasformation on .json files, ie. output of compiler is the same as input file. I believe we might use the trick presented here: https://twitter.com/mathias/status/1143551692732030979
This issue is to be addressed in #2657
With #2636 landed it is now possible and quite trivial to implement, again we just need some logic to decide whether certain file should be compiled using tsc or not. Can I assume that unless |
That is right, the TypeScript compiler doesn't, but the Deno compiler used to, before the ESM. It would do exactly what is suggested in the link you sent: For something like this: { "foo": "bar" } You would get: define("foo.json", [], function () {
return JSON.parse(`{ "foo": "bar" }`);
}); The problem I just realised is that it isn't possible to generate a module that spreads the results of a string. Each export (key of the imported JSON) of the parsed JSON has to be available statically in ESM. The only real way to do it I think in ESM is how Ry did it. 😢 The other way is the compiler actually parses the JSON, enumerates over the keys and creates an export statement for each one.
Yes, sounds right to me. And changes to the source |
Closed in #2686, not sure why it can't close two issues |
Currently TS compiler during compilation of
.ts
file will compile all encountered.js
and.json
files. For each file it produces compiled file (which is identical to original file) and source map file.They are stored inside
$DENO_DIR/gen/
directory. These files are actually never used because whenLoader
requests module it won't be requested using TS compiler because they are not.ts
files.This issue is related to #2114
Proposed solution:
resolveJsonModule
fromtsconfig.json
or don't cache compiler output for.json
files.js
files unlesscheckJs
is enabled intsconfig.json
- this would have to be done in coordination with Cleanup compiler pipeline #2657 because then TS compiler would be able to return compiled file for.js
fileCC @ry @kitsonk
The text was updated successfully, but these errors were encountered: