diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts index 58194e35ba708f..b250c96813b4cd 100644 --- a/cli/js/compiler.ts +++ b/cli/js/compiler.ts @@ -717,14 +717,12 @@ function cache( function processConfigureResponse( configResult: ConfigureResponse, - configPath = "" + configPath: string ): ts.Diagnostic[] | undefined { const { ignoredOptions, diagnostics } = configResult; if (ignoredOptions) { console.warn( - (configPath - ? yellow(`Unsupported compiler options in "${configPath}"\n`) - : yellow("Unsupported compiler options.")) + + yellow(`Unsupported compiler options in "${configPath}"\n`) + cyan(` The following options were ignored:\n`) + ` ${ignoredOptions.map((value): string => bold(value)).join(", ")}` ); @@ -990,16 +988,16 @@ self.compilerMain = function compilerMain(): void { } // we only support single root names for bundles assert(rootNames.length === 1); - const bundle = buildBundle(rootNames[0], data, sourceFiles); + const out = buildBundle(rootNames[0], data, sourceFiles); if (outFile) { - const encodedData = encoder.encode(bundle); - console.warn(`Emitting bundle to "${fileName}"`); - writeFileSync(fileName, encodedData); + const encodedData = encoder.encode(out); + console.warn(`Emitting bundle to "${outFile}"`); + writeFileSync(outFile, encodedData); console.warn( `${util.humanFileSize(encodedData.length)} emitted.` ); } else { - console.log(bundle); + console.log(out); } } }; @@ -1011,7 +1009,7 @@ self.compilerMain = function compilerMain(): void { // if there is a configuration supplied, we need to parse that if (config && config.length && configPath) { const configResult = host.configure(configPath, config); - diagnostics = processConfigureResponse(configResult); + diagnostics = processConfigureResponse(configResult, configPath); } let emitSkipped = true; diff --git a/cli/js/compiler_api.ts b/cli/js/compiler_api.ts index 9bc708bef07297..0a77b5db8bf4b0 100644 --- a/cli/js/compiler_api.ts +++ b/cli/js/compiler_api.ts @@ -1,5 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +// This file contains the runtime APIs which will dispatch work to the internal +// compiler within Deno. + import { Diagnostic } from "./diagnostics.ts"; import * as dispatch from "./dispatch.ts"; import { sendAsync, sendSync } from "./dispatch_json.ts"; @@ -284,7 +287,7 @@ export function transpileOnly( sources: Record, options?: CompilerOptions ): Promise> { - util.log("Deno.transpileOnly"); + util.log("Deno.transpileOnly", { sources: Object.keys(sources), options }); const payload = { sources, options: options ? JSON.stringify(options) : undefined @@ -315,7 +318,10 @@ export function transpileOnlySync( sources: Record, options?: CompilerOptions ): Record { - util.log("Deno.transpileOnlySync"); + util.log("Deno.transpileOnlySync", { + sources: Object.keys(sources), + options + }); return sendSync(dispatch.OP_TRANSPILE, { sources, options: options ? JSON.stringify(options) : undefined diff --git a/cli/js/compiler_api_test.ts b/cli/js/compiler_api_test.ts index 1ec5dd33a6f7c1..64a1301830d1bd 100644 --- a/cli/js/compiler_api_test.ts +++ b/cli/js/compiler_api_test.ts @@ -1,10 +1,21 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. + import { assert, assertEquals, test } from "./test_util.ts"; -const { compile, compileSync } = Deno; +const { + compile + // compileSync, + // transpileOnly, + // transpileOnlySync, + // bundle, + // bundleSync +} = Deno; test(async function compilerApiCompileSources() { - const result = await Deno.compile("/foo.ts", { + const [diagnostics, actual] = await compile("/foo.ts", { "/foo.ts": `console.log("foo");\nexport {}\n` }); + assert(diagnostics == null); + assert(actual); + assertEquals(Object.keys(actual).length, 2); }); diff --git a/cli/tests/error_011_bad_module_specifier.ts.out b/cli/tests/error_011_bad_module_specifier.ts.out index 276443e5bf64f3..5f1418c26a8d38 100644 --- a/cli/tests/error_011_bad_module_specifier.ts.out +++ b/cli/tests/error_011_bad_module_specifier.ts.out @@ -1,5 +1,8 @@ [WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_011_bad_module_specifier.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] - at DenoError ([WILDCARD]errors.ts:[WILDCARD]) - at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD]) + at DenoError ($deno$/errors.ts:[WILDCARD]) + at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) + at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) + at resolveModules ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD]) diff --git a/cli/tests/error_012_bad_dynamic_import_specifier.ts.out b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out index 52e5b913e48b8c..bdd08245128db9 100644 --- a/cli/tests/error_012_bad_dynamic_import_specifier.ts.out +++ b/cli/tests/error_012_bad_dynamic_import_specifier.ts.out @@ -1,5 +1,8 @@ [WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] - at DenoError ([WILDCARD]errors.ts:[WILDCARD]) - at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD]) + at DenoError ($deno$/errors.ts:[WILDCARD]) + at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) + at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) + at resolveModules ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD]) diff --git a/cli/tests/error_type_definitions.ts.out b/cli/tests/error_type_definitions.ts.out index e21b6d7945273a..f613a7e2f66619 100644 --- a/cli/tests/error_type_definitions.ts.out +++ b/cli/tests/error_type_definitions.ts.out @@ -1,5 +1,8 @@ [WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "baz" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/type_definitions/bar.d.ts" [WILDCARD]dispatch_json.ts:[WILDCARD] - at DenoError ([WILDCARD]errors.ts:[WILDCARD]) - at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD]) - at sendAsync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD]) + at DenoError ($deno$/errors.ts:[WILDCARD]) + at unwrapResponse ($deno$/dispatch_json.ts:[WILDCARD]) + at sendSync ($deno$/dispatch_json.ts:[WILDCARD]) + at resolveModules ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD]) + at processImports ($deno$/compiler.ts:[WILDCARD])