diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2018-11-02 11:30:30 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-11-01 19:33:18 -0700 |
commit | 7f8284addf6d2e49f8a885c751c470167c619a86 (patch) | |
tree | d9b9756d517f465750d62a73ede57fd57b579602 /js/compiler.ts | |
parent | 6345b60ed8b784939c9fbad8148c3e98ba07a013 (diff) |
Fix performance regression with JSON Modules
Diffstat (limited to 'js/compiler.ts')
-rw-r--r-- | js/compiler.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/js/compiler.ts b/js/compiler.ts index 88a383e4b..941691f5c 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -441,27 +441,27 @@ export class DenoCompiler } const { fileName, sourceCode, mediaType, moduleId } = moduleMetaData; console.warn("Compiling", moduleId); - const service = this._service; // Instead of using TypeScript to transpile JSON modules, we will just do // it directly. if (mediaType === MediaType.Json) { moduleMetaData.outputCode = jsonAmdTemplate(sourceCode, fileName); } else { + const service = this._service; assert( mediaType === MediaType.TypeScript || mediaType === MediaType.JavaScript ); - // TypeScript is overly opinionated that only CommonJS modules kinds can - // support JSON imports. Allegedly this was fixed in - // Microsoft/TypeScript#26825 but that doesn't seem to be working here, - // so we will trick the TypeScript compiler. - this._options.module = ts.ModuleKind.AMD; const output = service.getEmitOutput(fileName); - this._options.module = ts.ModuleKind.CommonJS; // Get the relevant diagnostics - this is 3x faster than // `getPreEmitDiagnostics`. const diagnostics = [ - ...service.getCompilerOptionsDiagnostics(), + // TypeScript is overly opinionated that only CommonJS modules kinds can + // support JSON imports. Allegedly this was fixed in + // Microsoft/TypeScript#26825 but that doesn't seem to be working here, + // so we will ignore complaints about this compiler setting. + ...service + .getCompilerOptionsDiagnostics() + .filter(diagnostic => diagnostic.code !== 5070), ...service.getSyntacticDiagnostics(fileName), ...service.getSemanticDiagnostics(fileName) ]; |