mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
Provide compiled JSON to TypeScript compiler. (#4404)
Fixes #4101 Previously, we would just provide the raw JSON to the TypeScript compiler worker, but TypeScript does not transform JSON. This caused a problem when emitting a bundle, that the JSON would just be "inlined" into the output, instead of being transformed into a module. This fixes this problem by providing the compiled JSON to the TypeScript compiler, so TypeScript just sees JSON as a "normal" TypeScript module.
This commit is contained in:
parent
83f4916195
commit
da8cb408c8
5 changed files with 60 additions and 7 deletions
|
@ -4,7 +4,7 @@ import { bold, cyan, yellow } from "../colors.ts";
|
|||
import { CompilerOptions } from "./api.ts";
|
||||
import { buildBundle } from "./bundler.ts";
|
||||
import { ConfigureResponse, Host } from "./host.ts";
|
||||
import { SourceFile } from "./sourcefile.ts";
|
||||
import { MediaType, SourceFile } from "./sourcefile.ts";
|
||||
import { atob, TextEncoder } from "../web/text_encoding.ts";
|
||||
import * as compilerOps from "../ops/compiler.ts";
|
||||
import * as util from "../util.ts";
|
||||
|
@ -51,13 +51,13 @@ function cache(
|
|||
// NOTE: If it's a `.json` file we don't want to write it to disk.
|
||||
// JSON files are loaded and used by TS compiler to check types, but we don't want
|
||||
// to emit them to disk because output file is the same as input file.
|
||||
if (sf.extension === ts.Extension.Json) {
|
||||
if (sf.mediaType === MediaType.Json) {
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: JavaScript files are only cached to disk if `checkJs`
|
||||
// option in on
|
||||
if (sf.extension === ts.Extension.Js && !checkJs) {
|
||||
if (sf.mediaType === MediaType.JavaScript && !checkJs) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue