From 73e22ed9c2e8776eb3bebb0f3a6990d3bbad129a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Apr 2015 22:54:06 -0700 Subject: [PATCH 1/4] Add convertToBase64 method --- Jakefile | 3 +- src/compiler/utilities.ts | 77 ++++++++++++++++++++++++ tests/cases/unittests/convertToBase64.ts | 33 ++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/cases/unittests/convertToBase64.ts diff --git a/Jakefile b/Jakefile index 2efd973a0218e..0712b8414ba7f 100644 --- a/Jakefile +++ b/Jakefile @@ -145,7 +145,8 @@ var harnessSources = [ "services/documentRegistry.ts", "services/preProcessFile.ts", "services/patternMatcher.ts", - "versionCache.ts" + "versionCache.ts", + "convertToBase64.ts" ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e3efd12de0a0c..f475ea750533b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1815,4 +1815,81 @@ module ts { export function getLocalSymbolForExportDefault(symbol: Symbol) { return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & NodeFlags.Default) ? symbol.valueDeclaration.localSymbol : undefined; } + + /** + * Replace each instance of non-ascii characters by one, two, three, or four escape sequences + * representing the UTF-8 encoding of the character, and return the expanded char code list. + */ + function getExpandedCharCodes(input: string): number[] { + let output: number[] = []; + let length = input.length; + let leadSurrogate: number = undefined; + + for (let i = 0; i < length; i++) { + let charCode = input.charCodeAt(i); + + // handel utf8 + if (charCode < 0x80) { + output.push(charCode); + } + else if (charCode < 0x800) { + output.push((charCode >> 6) | 0B11000000); + output.push((charCode & 0B00111111) | 0B10000000); + } + else if (charCode < 0x10000) { + output.push((charCode >> 12) | 0B11100000); + output.push(((charCode >> 6) & 0B00111111) | 0B10000000); + output.push((charCode & 0B00111111) | 0B10000000); + } + else if (charCode < 0x20000) { + output.push((charCode >> 18) | 0B11110000); + output.push(((charCode >> 12) & 0B00111111) | 0B10000000); + output.push(((charCode >> 6) & 0B00111111) | 0B10000000); + output.push((charCode & 0B00111111) | 0B10000000); + } + else { + Debug.assert(false, "Unexpected code point"); + } + } + + return output; + } + + const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + + /** + * Converts a string to a base-64 encoded ASCII string. + */ + export function convertToBase64(input: string): string { + var result = ""; + let charCodes = getExpandedCharCodes(input); + let i = 0; + let length = charCodes.length; + let byte1: number, byte2: number, byte3: number, byte4: number; + + while (i < length) { + // Convert every 6-bits in the input 3 character points + // into a base64 digit + byte1 = charCodes[i] >> 2; + byte2 = (charCodes[i] & 0B00000011) << 4 | charCodes[i + 1] >> 4; + byte3 = (charCodes[i + 1] & 0B00001111) << 2 | charCodes[i + 2] >> 6; + byte4 = charCodes[i + 2] & 0B00111111; + + // We are out of characters in the input, set the extra + // digits to 64 (padding character). + if (i + 1 >= length) { + byte3 = byte4 = 64; + } + else if (i + 2 >= length) { + byte4 = 64; + } + + // Write to the ouput + result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4); + + i += 3; + } + + return result; + } } diff --git a/tests/cases/unittests/convertToBase64.ts b/tests/cases/unittests/convertToBase64.ts new file mode 100644 index 0000000000000..96c082ae78992 --- /dev/null +++ b/tests/cases/unittests/convertToBase64.ts @@ -0,0 +1,33 @@ +/// + +module ts { + describe('convertToBase64', () => { + function runTest(input: string): void { + var actual = ts.convertToBase64(input); + var expected = new Buffer(input).toString("base64"); + assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')"); + } + + it("Converts ASCII charaters correctelly", () => { + runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + }); + + it("Converts escape sequences correctelly", () => { + runTest("\t\n\r\\\"\'\u0062"); + }); + + it("Converts simple unicode characters correctelly", () => { + runTest("ΠΣ ٵپ औठ ⺐⺠"); + }); + + it("Converts simple code snippit correctelly", () => { + runTest(`/// +var x: string = "string"; +console.log(x);`); + }); + + it("Converts simple code snippit with unicode characters correctelly", () => { + runTest(`var Π = 3.1415; console.log(Π);`); + }); + }); +} From a998abb153be952397a80fd96c1a2018acc388c2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Apr 2015 00:14:23 -0700 Subject: [PATCH 2/4] Add inlineSourceMap option --- src/compiler/commandLineParser.ts | 4 ++ .../diagnosticInformationMap.generated.ts | 4 ++ src/compiler/diagnosticMessages.json | 19 ++++- src/compiler/emitter.ts | 55 +++++++++----- src/compiler/program.ts | 15 ++++ src/compiler/types.ts | 1 + src/harness/compilerRunner.ts | 13 ++-- src/harness/harness.ts | 10 ++- .../reference/inlineSourceMap.errors.txt | 9 +++ tests/baselines/reference/inlineSourceMap.js | 9 +++ .../reference/inlineSourceMap.sourcemap.txt | 61 ++++++++++++++++ .../reference/inlineSourceMap2.errors.txt | 19 +++++ tests/baselines/reference/inlineSourceMap2.js | 12 ++++ .../reference/inlineSourceMap2.sourcemap.txt | 71 +++++++++++++++++++ tests/cases/compiler/inlineSourceMap.ts | 5 ++ tests/cases/compiler/inlineSourceMap2.ts | 11 +++ 16 files changed, 294 insertions(+), 24 deletions(-) create mode 100644 tests/baselines/reference/inlineSourceMap.errors.txt create mode 100644 tests/baselines/reference/inlineSourceMap.js create mode 100644 tests/baselines/reference/inlineSourceMap.sourcemap.txt create mode 100644 tests/baselines/reference/inlineSourceMap2.errors.txt create mode 100644 tests/baselines/reference/inlineSourceMap2.js create mode 100644 tests/baselines/reference/inlineSourceMap2.sourcemap.txt create mode 100644 tests/cases/compiler/inlineSourceMap.ts create mode 100644 tests/cases/compiler/inlineSourceMap2.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 48817798d817a..af4a44204e393 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -30,6 +30,10 @@ module ts { type: "boolean", description: Diagnostics.Print_this_message, }, + { + name: "inlineSourceMap", + type: "boolean", + }, { name: "listFiles", type: "boolean", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index b4380f4d2deaf..380cd7378f8f2 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -445,6 +445,10 @@ module ts { Option_noEmitOnError_cannot_be_specified_with_option_separateCompilation: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'separateCompilation'." }, Option_out_cannot_be_specified_with_option_separateCompilation: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'separateCompilation'." }, Option_separateCompilation_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'separateCompilation' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." }, + Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, + Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, + Option_out_cannot_be_specified_with_option_inlineSourceMap: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'inlineSourceMap'." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fe349b783439b..65382ab7f04e7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -661,7 +661,7 @@ }, "Invalid use of '{0}'. Class definitions are automatically in strict mode.": { "category": "Error", - "code": 1210 + "code": 1210 }, "A class declaration without the 'default' modifier must have a name": { "category": "Error", @@ -1772,6 +1772,23 @@ "category": "Error", "code": 5047 }, + "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.": { + "category": "Error", + "code": 5048 + }, + "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.": { + "category": "Error", + "code": 5049 + }, + "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.": { + "category": "Error", + "code": 5050 + }, + "Option 'out' cannot be specified with option 'inlineSourceMap'.": { + "category": "Error", + "code": 5051 + }, + "Concatenate and emit output to single file.": { "category": "Message", "code": 6001 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 43db3e69cd718..28848a1af78f4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -52,7 +52,7 @@ var __param = this.__param || function(index, decorator) { return function (targ let compilerOptions = host.getCompilerOptions(); let languageVersion = compilerOptions.target || ScriptTarget.ES3; - let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined; + let sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; let diagnostics: Diagnostic[] = []; let newLine = host.getNewLine(); @@ -169,7 +169,7 @@ var __param = this.__param || function(index, decorator) { return function (targ /** Sourcemap data that will get encoded */ let sourceMapData: SourceMapData; - if (compilerOptions.sourceMap) { + if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) { initializeEmitterWithSourceMaps(); } @@ -564,19 +564,25 @@ var __param = this.__param || function(index, decorator) { return function (targ recordSourceMapSpan(comment.end); } - function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string) { + function serializeSourceMapContents(version: number, file: string, sourceRoot: string, sources: string[], names: string[], mappings: string, sourcesContent?: string[]) { if (typeof JSON !== "undefined") { - return JSON.stringify({ - version: version, - file: file, - sourceRoot: sourceRoot, - sources: sources, - names: names, - mappings: mappings - }); + let map: any = { + version, + file, + sourceRoot, + sources, + names, + mappings + }; + + if (sourcesContent !== undefined) { + map.sourcesContent = sourcesContent; + } + + return JSON.stringify(map); } - return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}"; + return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\" " + (sourcesContent !== undefined ? ",\"sourcesContent\":[" + serializeStringArray(sourcesContent) + "]" : "") + "}"; function serializeStringArray(list: string[]): string { let output = ""; @@ -591,19 +597,34 @@ var __param = this.__param || function(index, decorator) { return function (targ } function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) { - // Write source map file encodeLastRecordedSourceMapSpan(); - writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents( + + let fileContents = compilerOptions.inlineSourceMap ? [currentSourceFile.text] : undefined; + let sourceMapText = serializeSourceMapContents( 3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, - sourceMapData.sourceMapMappings), /*writeByteOrderMark*/ false); + sourceMapData.sourceMapMappings, + fileContents); + sourceMapDataList.push(sourceMapData); + let sourceMapUrl: string; + if (compilerOptions.inlineSourceMap) { + // Encode the sourceMap into the sourceMap url + let base64SourceMapText = convertToBase64(sourceMapText); + sourceMapUrl = `//# sourceMappingURL=data:application/json;base64,${base64SourceMapText}`; + } + else { + // Write source map file + writeFile(host, diagnostics, sourceMapData.sourceMapFilePath, sourceMapText, /*writeByteOrderMark*/ false); + sourceMapUrl = `//# sourceMappingURL=${sourceMapData.jsSourceMappingURL}`; + } + // Write sourcemap url to the js file and write the js file - writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); + writeJavaScriptFile(emitOutput + sourceMapUrl, writeByteOrderMark); } // Initialize source map data @@ -861,7 +882,7 @@ var __param = this.__param || function(index, decorator) { return function (targ function emitLiteral(node: LiteralExpression) { let text = getLiteralText(node); - if (compilerOptions.sourceMap && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { + if ((compilerOptions.sourceMap || compilerOptions.inlineSourceMap) && (node.kind === SyntaxKind.StringLiteral || isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } // For versions below ES6, emit binary & octal literals in their canonical decimal form. diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 69faeda2db059..8bf9d049b8d2a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -472,6 +472,21 @@ module ts { } } + if (options.inlineSourceMap) { + if (options.sourceMap) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.mapRoot) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.sourceRoot) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); + } + if (options.out) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_inlineSourceMap)); + } + } + if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) { // Error to specify --mapRoot or --sourceRoot without mapSourceFiles if (options.mapRoot) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7477705796396..8bddb943892c4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1587,6 +1587,7 @@ module ts { diagnostics?: boolean; emitBOM?: boolean; help?: boolean; + inlineSourceMap?: boolean; listFiles?: boolean; locale?: string; mapRoot?: string; diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index d4dd8e312588f..8b4e60f8f607e 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -159,7 +159,7 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it('Correct sourcemap content for ' + fileName, () => { - if (options.sourceMap) { + if (options.sourceMap || options.inlineSourceMap) { Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => { var record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { @@ -228,11 +228,14 @@ class CompilerBaselineRunner extends RunnerBase { }); it('Correct Sourcemap output for ' + fileName, () => { - if (options.sourceMap) { - if (result.sourceMaps.length !== result.files.length) { - throw new Error('Number of sourcemap files should be same as js files.'); - } + if (options.sourceMap && result.sourceMaps.length !== result.files.length) { + throw new Error('Number of sourcemap files should be same as js files.'); + } + else if (options.inlineSourceMap && result.sourceMaps.length > 0) { + throw new Error('No sourcemap files should be generated if inlineSourceMaps was set.'); + } + if (options.sourceMap) { Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 784d8312d6901..bef3c38cc0113 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1016,6 +1016,10 @@ module Harness { options.sourceRoot = setting.value; break; + case 'maproot': + options.mapRoot = setting.value; + break; + case 'sourcemap': options.sourceMap = !!setting.value; break; @@ -1069,6 +1073,10 @@ module Harness { includeBuiltFiles.push({ unitName: builtFileName, content: normalizeLineEndings(IO.readFile(builtFileName), newLine) }); break; + case 'inlinesourcemap': + options.inlineSourceMap = setting.value === 'true'; + break; + default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1465,7 +1473,7 @@ module Harness { "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "separatecompilation"]; + "separatecompilation", "inlinesourcemap", "maproot", "sourceroot"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/tests/baselines/reference/inlineSourceMap.errors.txt b/tests/baselines/reference/inlineSourceMap.errors.txt new file mode 100644 index 0000000000000..8d92d6a161d3e --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/inlineSourceMap.ts(3,1): error TS2304: Cannot find name 'console'. + + +==== tests/cases/compiler/inlineSourceMap.ts (1 errors) ==== + + var x = 0; + console.log(x); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap.js b/tests/baselines/reference/inlineSourceMap.js new file mode 100644 index 0000000000000..da0f6de96d37b --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap.js @@ -0,0 +1,9 @@ +//// [inlineSourceMap.ts] + +var x = 0; +console.log(x); + +//// [inlineSourceMap.js] +var x = 0; +console.log(x); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap.sourcemap.txt b/tests/baselines/reference/inlineSourceMap.sourcemap.txt new file mode 100644 index 0000000000000..e344ecc43abdd --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap.sourcemap.txt @@ -0,0 +1,61 @@ +=================================================================== +JsFile: inlineSourceMap.js +mapUrl: inlineSourceMap.js.map +sourceRoot: +sources: inlineSourceMap.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:tests/cases/compiler/inlineSourceMap.js +sourceFile:inlineSourceMap.ts +------------------------------------------------------------------- +>>>var x = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > + > +2 >var +3 > x +4 > = +5 > 0 +6 > ; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0) +4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0) +5 >Emitted(1, 10) Source(2, 10) + SourceIndex(0) +6 >Emitted(1, 11) Source(2, 11) + SourceIndex(0) +--- +>>>console.log(x); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > x +7 > ) +8 > ; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 8) Source(3, 8) + SourceIndex(0) +3 >Emitted(2, 9) Source(3, 9) + SourceIndex(0) +4 >Emitted(2, 12) Source(3, 12) + SourceIndex(0) +5 >Emitted(2, 13) Source(3, 13) + SourceIndex(0) +6 >Emitted(2, 14) Source(3, 14) + SourceIndex(0) +7 >Emitted(2, 15) Source(3, 15) + SourceIndex(0) +8 >Emitted(2, 16) Source(3, 16) + SourceIndex(0) +--- +>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap2.errors.txt b/tests/baselines/reference/inlineSourceMap2.errors.txt new file mode 100644 index 0000000000000..f35aabd8fa674 --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap2.errors.txt @@ -0,0 +1,19 @@ +error TS5051: Option 'out' cannot be specified with option 'inlineSourceMap'. +error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. +error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'. + + +!!! error TS5051: Option 'out' cannot be specified with option 'inlineSourceMap'. +!!! error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. +!!! error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. +==== tests/cases/compiler/inlineSourceMap2.ts (1 errors) ==== + + // configuration errors + + var x = 0; + console.log(x); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap2.js b/tests/baselines/reference/inlineSourceMap2.js new file mode 100644 index 0000000000000..679b480af3ed6 --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap2.js @@ -0,0 +1,12 @@ +//// [inlineSourceMap2.ts] + +// configuration errors + +var x = 0; +console.log(x); + +//// [outfile.js] +// configuration errors +var x = 0; +console.log(x); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbi8vIGNvbmZpZ3VyYXRpb24gZXJyb3JzXG5cbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap2.sourcemap.txt b/tests/baselines/reference/inlineSourceMap2.sourcemap.txt new file mode 100644 index 0000000000000..3994efe82bf3a --- /dev/null +++ b/tests/baselines/reference/inlineSourceMap2.sourcemap.txt @@ -0,0 +1,71 @@ +=================================================================== +JsFile: outfile.js +mapUrl: file:///folder/outfile.js.map +sourceRoot: file:///folder/ +sources: inlineSourceMap2.ts +=================================================================== +------------------------------------------------------------------- +emittedFile:outfile.js +sourceFile:inlineSourceMap2.ts +------------------------------------------------------------------- +>>>// configuration errors +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^ +1 > + > +2 >// configuration errors +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 24) Source(2, 24) + SourceIndex(0) +--- +>>>var x = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > + > + > +2 >var +3 > x +4 > = +5 > 0 +6 > ; +1 >Emitted(2, 1) Source(4, 1) + SourceIndex(0) +2 >Emitted(2, 5) Source(4, 5) + SourceIndex(0) +3 >Emitted(2, 6) Source(4, 6) + SourceIndex(0) +4 >Emitted(2, 9) Source(4, 9) + SourceIndex(0) +5 >Emitted(2, 10) Source(4, 10) + SourceIndex(0) +6 >Emitted(2, 11) Source(4, 11) + SourceIndex(0) +--- +>>>console.log(x); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > x +7 > ) +8 > ; +1->Emitted(3, 1) Source(5, 1) + SourceIndex(0) +2 >Emitted(3, 8) Source(5, 8) + SourceIndex(0) +3 >Emitted(3, 9) Source(5, 9) + SourceIndex(0) +4 >Emitted(3, 12) Source(5, 12) + SourceIndex(0) +5 >Emitted(3, 13) Source(5, 13) + SourceIndex(0) +6 >Emitted(3, 14) Source(5, 14) + SourceIndex(0) +7 >Emitted(3, 15) Source(5, 15) + SourceIndex(0) +8 >Emitted(3, 16) Source(5, 16) + SourceIndex(0) +--- +>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbi8vIGNvbmZpZ3VyYXRpb24gZXJyb3JzXG5cbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file diff --git a/tests/cases/compiler/inlineSourceMap.ts b/tests/cases/compiler/inlineSourceMap.ts new file mode 100644 index 0000000000000..35e9845ba58d5 --- /dev/null +++ b/tests/cases/compiler/inlineSourceMap.ts @@ -0,0 +1,5 @@ +// @target: ES3 +// @inlinesourcemap: true + +var x = 0; +console.log(x); \ No newline at end of file diff --git a/tests/cases/compiler/inlineSourceMap2.ts b/tests/cases/compiler/inlineSourceMap2.ts new file mode 100644 index 0000000000000..1d426f1773634 --- /dev/null +++ b/tests/cases/compiler/inlineSourceMap2.ts @@ -0,0 +1,11 @@ +// @target: ES3 +// @sourcemap: true +// @maproot: file:///folder +// @sourceroot: file:///folder +// @out: outfile.js +// @inlinesourcemap: true + +// configuration errors + +var x = 0; +console.log(x); \ No newline at end of file From cacf34a4c26de32e054762606a6ee5a42ced3683 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 9 Apr 2015 16:55:42 -0700 Subject: [PATCH 3/4] Check for inlineSoruceMaps first --- src/harness/compilerRunner.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 8b4e60f8f607e..2845feb75b61f 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -228,14 +228,17 @@ class CompilerBaselineRunner extends RunnerBase { }); it('Correct Sourcemap output for ' + fileName, () => { - if (options.sourceMap && result.sourceMaps.length !== result.files.length) { - throw new Error('Number of sourcemap files should be same as js files.'); - } - else if (options.inlineSourceMap && result.sourceMaps.length > 0) { - throw new Error('No sourcemap files should be generated if inlineSourceMaps was set.'); + if (options.inlineSourceMap) { + if (result.sourceMaps.length > 0) { + throw new Error('No sourcemap files should be generated if inlineSourceMaps was set.'); + } + return null; } + else if (options.sourceMap) { + if (result.sourceMaps.length !== result.files.length) { + throw new Error('Number of sourcemap files should be same as js files.'); + } - if (options.sourceMap) { Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. From 658bba9eaf7475790ed06ca1b24e0a2138efbd7e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 20 Apr 2015 20:33:31 -0700 Subject: [PATCH 4/4] Add --inlineSources option --- src/compiler/commandLineParser.ts | 4 + .../diagnosticInformationMap.generated.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/emitter.ts | 11 +- src/compiler/program.ts | 8 +- src/compiler/types.ts | 18 +-- src/harness/harness.ts | 7 +- src/harness/sourceMapRecorder.ts | 3 + tests/baselines/reference/inlineSourceMap.js | 2 +- .../reference/inlineSourceMap.sourcemap.txt | 4 +- .../reference/inlineSourceMap2.errors.txt | 2 - tests/baselines/reference/inlineSourceMap2.js | 2 +- .../reference/inlineSourceMap2.sourcemap.txt | 4 +- .../reference/inlineSources.errors.txt | 16 +++ tests/baselines/reference/inlineSources.js | 17 +++ .../baselines/reference/inlineSources.js.map | 2 + .../reference/inlineSources.sourcemap.txt | 114 ++++++++++++++++++ .../reference/inlineSources2.errors.txt | 16 +++ tests/baselines/reference/inlineSources2.js | 17 +++ .../reference/inlineSources2.sourcemap.txt | 114 ++++++++++++++++++ tests/cases/compiler/inlineSources.ts | 12 ++ tests/cases/compiler/inlineSources2.ts | 12 ++ 22 files changed, 366 insertions(+), 23 deletions(-) create mode 100644 tests/baselines/reference/inlineSources.errors.txt create mode 100644 tests/baselines/reference/inlineSources.js create mode 100644 tests/baselines/reference/inlineSources.js.map create mode 100644 tests/baselines/reference/inlineSources.sourcemap.txt create mode 100644 tests/baselines/reference/inlineSources2.errors.txt create mode 100644 tests/baselines/reference/inlineSources2.js create mode 100644 tests/baselines/reference/inlineSources2.sourcemap.txt create mode 100644 tests/cases/compiler/inlineSources.ts create mode 100644 tests/cases/compiler/inlineSources2.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d34d56b46cae5..e1a0063e513db 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -34,6 +34,10 @@ module ts { name: "inlineSourceMap", type: "boolean", }, + { + name: "inlineSources", + type: "boolean", + }, { name: "listFiles", type: "boolean", diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 9ff765d732a3c..d683333e1d4b9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -455,7 +455,7 @@ module ts { Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." }, Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." }, Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." }, - Option_out_cannot_be_specified_with_option_inlineSourceMap: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'inlineSourceMap'." }, + Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." }, Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." }, Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 51e1be81086e8..915134d8cdebe 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1808,7 +1808,7 @@ "category": "Error", "code": 5050 }, - "Option 'out' cannot be specified with option 'inlineSourceMap'.": { + "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index be35991630ef9..90d5022f6cd6a 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -493,6 +493,13 @@ var __param = this.__param || function(index, decorator) { return function (targ // The one that can be used from program to get the actual source file sourceMapData.inputSourceFileNames.push(node.fileName); + + if (compilerOptions.inlineSources) { + if (!sourceMapData.sourceMapSourcesContent) { + sourceMapData.sourceMapSourcesContent = []; + } + sourceMapData.sourceMapSourcesContent.push(node.text); + } } function recordScopeNameOfNode(node: Node, scopeName?: string) { @@ -599,7 +606,6 @@ var __param = this.__param || function(index, decorator) { return function (targ function writeJavaScriptAndSourceMapFile(emitOutput: string, writeByteOrderMark: boolean) { encodeLastRecordedSourceMapSpan(); - let fileContents = compilerOptions.inlineSourceMap ? [currentSourceFile.text] : undefined; let sourceMapText = serializeSourceMapContents( 3, sourceMapData.sourceMapFile, @@ -607,7 +613,7 @@ var __param = this.__param || function(index, decorator) { return function (targ sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings, - fileContents); + sourceMapData.sourceMapSourcesContent); sourceMapDataList.push(sourceMapData); @@ -638,6 +644,7 @@ var __param = this.__param || function(index, decorator) { return function (targ inputSourceFileNames: [], sourceMapNames: [], sourceMapMappings: "", + sourceMapSourcesContent: undefined, sourceMapDecodedMappings: [] }; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index eff1c2047412b..d9bb0914355b1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -484,8 +484,12 @@ module ts { if (options.sourceRoot) { diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap)); } - if (options.out) { - diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_inlineSourceMap)); + } + + + if (options.inlineSources) { + if (!options.sourceMap && !options.inlineSourceMap) { + diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided)); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3741a1b0930c7..5b75ffa974d86 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1092,14 +1092,15 @@ module ts { } export interface SourceMapData { - sourceMapFilePath: string; // Where the sourcemap file is written - jsSourceMappingURL: string; // source map URL written in the .js file - sourceMapFile: string; // Source map's file field - .js file name - sourceMapSourceRoot: string; // Source map's sourceRoot field - location where the sources will be present if not "" - sourceMapSources: string[]; // Source map's sources field - list of sources that can be indexed in this source map - inputSourceFileNames: string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMapSources list - sourceMapNames?: string[]; // Source map's names field - list of names that can be indexed in this source map - sourceMapMappings: string; // Source map's mapping field - encoded source map spans + sourceMapFilePath: string; // Where the sourcemap file is written + jsSourceMappingURL: string; // source map URL written in the .js file + sourceMapFile: string; // Source map's file field - .js file name + sourceMapSourceRoot: string; // Source map's sourceRoot field - location where the sources will be present if not "" + sourceMapSources: string[]; // Source map's sources field - list of sources that can be indexed in this source map + sourceMapSourcesContent?: string[]; // Source map's sourcesContent field - list of the sources' text to be embedded in the source map + inputSourceFileNames: string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMapSources list + sourceMapNames?: string[]; // Source map's names field - list of names that can be indexed in this source map + sourceMapMappings: string; // Source map's mapping field - encoded source map spans sourceMapDecodedMappings: SourceMapSpan[]; // Raw source map spans that were encoded into the sourceMapMappings } @@ -1640,6 +1641,7 @@ module ts { emitBOM?: boolean; help?: boolean; inlineSourceMap?: boolean; + inlineSources?: boolean; listFiles?: boolean; locale?: string; mapRoot?: string; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index bef3c38cc0113..a73b91cc57a2c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1076,6 +1076,10 @@ module Harness { case 'inlinesourcemap': options.inlineSourceMap = setting.value === 'true'; break; + + case 'inlinesources': + options.inlineSources = setting.value === 'true'; + break; default: throw new Error('Unsupported compiler setting ' + setting.flag); @@ -1473,7 +1477,8 @@ module Harness { "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal", - "separatecompilation", "inlinesourcemap", "maproot", "sourceroot"]; + "separatecompilation", "inlinesourcemap", "maproot", "sourceroot", + "inlinesources"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index f7d6bcfeaa11e..528e6ddd52b4f 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -237,6 +237,9 @@ module Harness.SourceMapRecoder { sourceMapRecoder.WriteLine("mapUrl: " + sourceMapData.jsSourceMappingURL); sourceMapRecoder.WriteLine("sourceRoot: " + sourceMapData.sourceMapSourceRoot); sourceMapRecoder.WriteLine("sources: " + sourceMapData.sourceMapSources); + if (sourceMapData.sourceMapSourcesContent) { + sourceMapRecoder.WriteLine("sourcesContent: " + JSON.stringify(sourceMapData.sourceMapSourcesContent)); + } sourceMapRecoder.WriteLine("==================================================================="); } diff --git a/tests/baselines/reference/inlineSourceMap.js b/tests/baselines/reference/inlineSourceMap.js index da0f6de96d37b..94ad43d448730 100644 --- a/tests/baselines/reference/inlineSourceMap.js +++ b/tests/baselines/reference/inlineSourceMap.js @@ -6,4 +6,4 @@ console.log(x); //// [inlineSourceMap.js] var x = 0; console.log(x); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap.sourcemap.txt b/tests/baselines/reference/inlineSourceMap.sourcemap.txt index e344ecc43abdd..6625cc46b21c7 100644 --- a/tests/baselines/reference/inlineSourceMap.sourcemap.txt +++ b/tests/baselines/reference/inlineSourceMap.sourcemap.txt @@ -39,7 +39,7 @@ sourceFile:inlineSourceMap.ts 6 > ^ 7 > ^ 8 > ^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > 2 >console @@ -58,4 +58,4 @@ sourceFile:inlineSourceMap.ts 7 >Emitted(2, 15) Source(3, 15) + SourceIndex(0) 8 >Emitted(2, 16) Source(3, 16) + SourceIndex(0) --- ->>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file +>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lU291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5saW5lU291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap2.errors.txt b/tests/baselines/reference/inlineSourceMap2.errors.txt index f35aabd8fa674..75db5689c66f6 100644 --- a/tests/baselines/reference/inlineSourceMap2.errors.txt +++ b/tests/baselines/reference/inlineSourceMap2.errors.txt @@ -1,11 +1,9 @@ -error TS5051: Option 'out' cannot be specified with option 'inlineSourceMap'. error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. tests/cases/compiler/inlineSourceMap2.ts(5,1): error TS2304: Cannot find name 'console'. -!!! error TS5051: Option 'out' cannot be specified with option 'inlineSourceMap'. !!! error TS5050: Option 'mapRoot' cannot be specified with option 'inlineSourceMap'. !!! error TS5049: Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'. !!! error TS5048: Option 'sourceMap' cannot be specified with option 'inlineSourceMap'. diff --git a/tests/baselines/reference/inlineSourceMap2.js b/tests/baselines/reference/inlineSourceMap2.js index 679b480af3ed6..9cf2786334660 100644 --- a/tests/baselines/reference/inlineSourceMap2.js +++ b/tests/baselines/reference/inlineSourceMap2.js @@ -9,4 +9,4 @@ console.log(x); // configuration errors var x = 0; console.log(x); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbi8vIGNvbmZpZ3VyYXRpb24gZXJyb3JzXG5cbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSourceMap2.sourcemap.txt b/tests/baselines/reference/inlineSourceMap2.sourcemap.txt index 3994efe82bf3a..4d7f499b55a4b 100644 --- a/tests/baselines/reference/inlineSourceMap2.sourcemap.txt +++ b/tests/baselines/reference/inlineSourceMap2.sourcemap.txt @@ -49,7 +49,7 @@ sourceFile:inlineSourceMap2.ts 6 > ^ 7 > ^ 8 > ^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > 2 >console @@ -68,4 +68,4 @@ sourceFile:inlineSourceMap2.ts 7 >Emitted(3, 15) Source(5, 15) + SourceIndex(0) 8 >Emitted(3, 16) Source(5, 16) + SourceIndex(0) --- ->>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbi8vIGNvbmZpZ3VyYXRpb24gZXJyb3JzXG5cbnZhciB4ID0gMDtcbmNvbnNvbGUubG9nKHgpOyJdfQ== \ No newline at end of file +>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0ZmlsZS5qcyIsInNvdXJjZVJvb3QiOiJmaWxlOi8vL2ZvbGRlci8iLCJzb3VyY2VzIjpbImlubGluZVNvdXJjZU1hcDIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsdUJBQXVCO0FBRXZCLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMifQ== \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources.errors.txt b/tests/baselines/reference/inlineSources.errors.txt new file mode 100644 index 0000000000000..1c86dcf4d993e --- /dev/null +++ b/tests/baselines/reference/inlineSources.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/a.ts(3,1): error TS2304: Cannot find name 'console'. +tests/cases/compiler/b.ts(2,1): error TS2304: Cannot find name 'console'. + + +==== tests/cases/compiler/a.ts (1 errors) ==== + + var a = 0; + console.log(a); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. + +==== tests/cases/compiler/b.ts (1 errors) ==== + var b = 0; + console.log(b); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources.js b/tests/baselines/reference/inlineSources.js new file mode 100644 index 0000000000000..c700af7e4c607 --- /dev/null +++ b/tests/baselines/reference/inlineSources.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/inlineSources.ts] //// + +//// [a.ts] + +var a = 0; +console.log(a); + +//// [b.ts] +var b = 0; +console.log(b); + +//// [out.js] +var a = 0; +console.log(a); +var b = 0; +console.log(b); +//# sourceMappingURL=out.js.map \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources.js.map b/tests/baselines/reference/inlineSources.js.map new file mode 100644 index 0000000000000..7e09d95a35c75 --- /dev/null +++ b/tests/baselines/reference/inlineSources.js.map @@ -0,0 +1,2 @@ +//// [out.js.map] +{"version":3,"file":"out.js","sourceRoot":"","sources":["tests/cases/compiler/a.ts","tests/cases/compiler/b.ts"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;ACFf,IAAI,CAAC,GAAG,CAAC,CAAC;AACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC","sourcesContent":["\nvar a = 0;\nconsole.log(a);\n","var b = 0;\nconsole.log(b);"]} \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources.sourcemap.txt b/tests/baselines/reference/inlineSources.sourcemap.txt new file mode 100644 index 0000000000000..47d762f044e6b --- /dev/null +++ b/tests/baselines/reference/inlineSources.sourcemap.txt @@ -0,0 +1,114 @@ +=================================================================== +JsFile: out.js +mapUrl: out.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +sourcesContent: ["\nvar a = 0;\nconsole.log(a);\n","var b = 0;\nconsole.log(b);"] +=================================================================== +------------------------------------------------------------------- +emittedFile:out.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>var a = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > + > +2 >var +3 > a +4 > = +5 > 0 +6 > ; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0) +4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0) +5 >Emitted(1, 10) Source(2, 10) + SourceIndex(0) +6 >Emitted(1, 11) Source(2, 11) + SourceIndex(0) +--- +>>>console.log(a); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > a +7 > ) +8 > ; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 8) Source(3, 8) + SourceIndex(0) +3 >Emitted(2, 9) Source(3, 9) + SourceIndex(0) +4 >Emitted(2, 12) Source(3, 12) + SourceIndex(0) +5 >Emitted(2, 13) Source(3, 13) + SourceIndex(0) +6 >Emitted(2, 14) Source(3, 14) + SourceIndex(0) +7 >Emitted(2, 15) Source(3, 15) + SourceIndex(0) +8 >Emitted(2, 16) Source(3, 16) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:out.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var b = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > +2 >var +3 > b +4 > = +5 > 0 +6 > ; +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(3, 5) Source(1, 5) + SourceIndex(1) +3 >Emitted(3, 6) Source(1, 6) + SourceIndex(1) +4 >Emitted(3, 9) Source(1, 9) + SourceIndex(1) +5 >Emitted(3, 10) Source(1, 10) + SourceIndex(1) +6 >Emitted(3, 11) Source(1, 11) + SourceIndex(1) +--- +>>>console.log(b); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^^-> +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > b +7 > ) +8 > ; +1->Emitted(4, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(4, 8) Source(2, 8) + SourceIndex(1) +3 >Emitted(4, 9) Source(2, 9) + SourceIndex(1) +4 >Emitted(4, 12) Source(2, 12) + SourceIndex(1) +5 >Emitted(4, 13) Source(2, 13) + SourceIndex(1) +6 >Emitted(4, 14) Source(2, 14) + SourceIndex(1) +7 >Emitted(4, 15) Source(2, 15) + SourceIndex(1) +8 >Emitted(4, 16) Source(2, 16) + SourceIndex(1) +--- +>>>//# sourceMappingURL=out.js.map \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources2.errors.txt b/tests/baselines/reference/inlineSources2.errors.txt new file mode 100644 index 0000000000000..1c86dcf4d993e --- /dev/null +++ b/tests/baselines/reference/inlineSources2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/a.ts(3,1): error TS2304: Cannot find name 'console'. +tests/cases/compiler/b.ts(2,1): error TS2304: Cannot find name 'console'. + + +==== tests/cases/compiler/a.ts (1 errors) ==== + + var a = 0; + console.log(a); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. + +==== tests/cases/compiler/b.ts (1 errors) ==== + var b = 0; + console.log(b); + ~~~~~~~ +!!! error TS2304: Cannot find name 'console'. \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources2.js b/tests/baselines/reference/inlineSources2.js new file mode 100644 index 0000000000000..7f4c82f2ac290 --- /dev/null +++ b/tests/baselines/reference/inlineSources2.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/inlineSources2.ts] //// + +//// [a.ts] + +var a = 0; +console.log(a); + +//// [b.ts] +var b = 0; +console.log(b); + +//// [out.js] +var a = 0; +console.log(a); +var b = 0; +console.log(b); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsidGVzdHMvY2FzZXMvY29tcGlsZXIvYS50cyIsInRlc3RzL2Nhc2VzL2NvbXBpbGVyL2IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQ0ZmLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciBhID0gMDtcbmNvbnNvbGUubG9nKGEpO1xuIiwidmFyIGIgPSAwO1xuY29uc29sZS5sb2coYik7Il19 \ No newline at end of file diff --git a/tests/baselines/reference/inlineSources2.sourcemap.txt b/tests/baselines/reference/inlineSources2.sourcemap.txt new file mode 100644 index 0000000000000..e3e14d01e9ee7 --- /dev/null +++ b/tests/baselines/reference/inlineSources2.sourcemap.txt @@ -0,0 +1,114 @@ +=================================================================== +JsFile: out.js +mapUrl: out.js.map +sourceRoot: +sources: tests/cases/compiler/a.ts,tests/cases/compiler/b.ts +sourcesContent: ["\nvar a = 0;\nconsole.log(a);\n","var b = 0;\nconsole.log(b);"] +=================================================================== +------------------------------------------------------------------- +emittedFile:out.js +sourceFile:tests/cases/compiler/a.ts +------------------------------------------------------------------- +>>>var a = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > + > +2 >var +3 > a +4 > = +5 > 0 +6 > ; +1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 5) Source(2, 5) + SourceIndex(0) +3 >Emitted(1, 6) Source(2, 6) + SourceIndex(0) +4 >Emitted(1, 9) Source(2, 9) + SourceIndex(0) +5 >Emitted(1, 10) Source(2, 10) + SourceIndex(0) +6 >Emitted(1, 11) Source(2, 11) + SourceIndex(0) +--- +>>>console.log(a); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > a +7 > ) +8 > ; +1->Emitted(2, 1) Source(3, 1) + SourceIndex(0) +2 >Emitted(2, 8) Source(3, 8) + SourceIndex(0) +3 >Emitted(2, 9) Source(3, 9) + SourceIndex(0) +4 >Emitted(2, 12) Source(3, 12) + SourceIndex(0) +5 >Emitted(2, 13) Source(3, 13) + SourceIndex(0) +6 >Emitted(2, 14) Source(3, 14) + SourceIndex(0) +7 >Emitted(2, 15) Source(3, 15) + SourceIndex(0) +8 >Emitted(2, 16) Source(3, 16) + SourceIndex(0) +--- +------------------------------------------------------------------- +emittedFile:out.js +sourceFile:tests/cases/compiler/b.ts +------------------------------------------------------------------- +>>>var b = 0; +1 > +2 >^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^^^^^^-> +1 > +2 >var +3 > b +4 > = +5 > 0 +6 > ; +1 >Emitted(3, 1) Source(1, 1) + SourceIndex(1) +2 >Emitted(3, 5) Source(1, 5) + SourceIndex(1) +3 >Emitted(3, 6) Source(1, 6) + SourceIndex(1) +4 >Emitted(3, 9) Source(1, 9) + SourceIndex(1) +5 >Emitted(3, 10) Source(1, 10) + SourceIndex(1) +6 >Emitted(3, 11) Source(1, 11) + SourceIndex(1) +--- +>>>console.log(b); +1-> +2 >^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> + > +2 >console +3 > . +4 > log +5 > ( +6 > b +7 > ) +8 > ; +1->Emitted(4, 1) Source(2, 1) + SourceIndex(1) +2 >Emitted(4, 8) Source(2, 8) + SourceIndex(1) +3 >Emitted(4, 9) Source(2, 9) + SourceIndex(1) +4 >Emitted(4, 12) Source(2, 12) + SourceIndex(1) +5 >Emitted(4, 13) Source(2, 13) + SourceIndex(1) +6 >Emitted(4, 14) Source(2, 14) + SourceIndex(1) +7 >Emitted(4, 15) Source(2, 15) + SourceIndex(1) +8 >Emitted(4, 16) Source(2, 16) + SourceIndex(1) +--- +>>>//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsidGVzdHMvY2FzZXMvY29tcGlsZXIvYS50cyIsInRlc3RzL2Nhc2VzL2NvbXBpbGVyL2IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ1YsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQ0ZmLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNWLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJcbnZhciBhID0gMDtcbmNvbnNvbGUubG9nKGEpO1xuIiwidmFyIGIgPSAwO1xuY29uc29sZS5sb2coYik7Il19 \ No newline at end of file diff --git a/tests/cases/compiler/inlineSources.ts b/tests/cases/compiler/inlineSources.ts new file mode 100644 index 0000000000000..f46eacdb57c52 --- /dev/null +++ b/tests/cases/compiler/inlineSources.ts @@ -0,0 +1,12 @@ +// @target: ES3 +// @sourcemap: true +// @inlinesources: true +// @out: out.js + +// @filename: a.ts +var a = 0; +console.log(a); + +// @filename: b.ts +var b = 0; +console.log(b); \ No newline at end of file diff --git a/tests/cases/compiler/inlineSources2.ts b/tests/cases/compiler/inlineSources2.ts new file mode 100644 index 0000000000000..6fa567dc52101 --- /dev/null +++ b/tests/cases/compiler/inlineSources2.ts @@ -0,0 +1,12 @@ +// @target: ES3 +// @inlinesourcemap: true +// @inlinesources: true +// @out: out.js + +// @filename: a.ts +var a = 0; +console.log(a); + +// @filename: b.ts +var b = 0; +console.log(b); \ No newline at end of file