diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-02 00:32:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 00:32:05 +0200 |
commit | de2c042482741dc23f7d975458a1fba95863de53 (patch) | |
tree | d9cb99d069a450ce708952b980ae15857b86a5d9 /cli/js/compiler | |
parent | 96fd0f4692126516239d61784caf6599aa884844 (diff) |
BREAKING: remove support for JSON imports (#5037)
This commit removes support for importing JSON files as modules.
This change is dictated by security; browsers rolled back on this
support as well.
Diffstat (limited to 'cli/js/compiler')
-rw-r--r-- | cli/js/compiler/imports.ts | 2 | ||||
-rw-r--r-- | cli/js/compiler/sourcefile.ts | 5 | ||||
-rw-r--r-- | cli/js/compiler/util.ts | 12 |
3 files changed, 1 insertions, 18 deletions
diff --git a/cli/js/compiler/imports.ts b/cli/js/compiler/imports.ts index 6b48ec945..4261a4123 100644 --- a/cli/js/compiler/imports.ts +++ b/cli/js/compiler/imports.ts @@ -83,8 +83,6 @@ function getMediaType(filename: string): MediaType { return MediaType.JavaScript; case "jsx": return MediaType.JSX; - case "json": - return MediaType.Json; case "ts": return MediaType.TypeScript; case "tsx": diff --git a/cli/js/compiler/sourcefile.ts b/cli/js/compiler/sourcefile.ts index a55de080b..3d547551f 100644 --- a/cli/js/compiler/sourcefile.ts +++ b/cli/js/compiler/sourcefile.ts @@ -34,11 +34,6 @@ function getExtension(fileName: string, mediaType: MediaType): ts.Extension { return fileName.endsWith(".d.ts") ? ts.Extension.Dts : ts.Extension.Ts; case MediaType.TSX: return ts.Extension.Tsx; - case MediaType.Json: - // we internally compile JSON, so what gets provided to the TypeScript - // compiler is an ES module, but in order to get TypeScript to handle it - // properly we have to pretend it is TS. - return ts.Extension.Ts; case MediaType.Wasm: // Custom marker for Wasm type. return ts.Extension.Js; diff --git a/cli/js/compiler/util.ts b/cli/js/compiler/util.ts index 170dff30f..d461fcbbb 100644 --- a/cli/js/compiler/util.ts +++ b/cli/js/compiler/util.ts @@ -48,13 +48,6 @@ function cache( const sf = SourceFile.get(moduleId); if (sf) { - // 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.mediaType === MediaType.Json) { - return; - } - // NOTE: JavaScript files are only cached to disk if `checkJs` // option in on if (sf.mediaType === MediaType.JavaScript && !checkJs) { @@ -65,10 +58,7 @@ function cache( if (emittedFileName.endsWith(".map")) { // Source Map compilerOps.cache(".map", moduleId, contents); - } else if ( - emittedFileName.endsWith(".js") || - emittedFileName.endsWith(".json") - ) { + } else if (emittedFileName.endsWith(".js")) { // Compiled JavaScript compilerOps.cache(".js", moduleId, contents); } else { |