diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 342cfc59be9..860b900251f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -8085,6 +8085,9 @@ export interface SourceFileMayBeEmittedHost { isSourceFileFromExternalLibrary(file: SourceFile): boolean; getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined; isSourceOfProjectReferenceRedirect(fileName: string): boolean; + getCurrentDirectory(): string; + getCanonicalFileName: GetCanonicalFileName; + useCaseSensitiveFileNames(): boolean; } /** @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 960494f8a9a..bf5223d610f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -62,6 +62,7 @@ import { CommentDirectivesMap, CommentDirectiveType, CommentRange, + comparePaths, compareStringsCaseSensitive, compareValues, Comparison, @@ -162,6 +163,7 @@ import { GetCanonicalFileName, getCombinedModifierFlags, getCombinedNodeFlags, + getCommonSourceDirectory, getContainerFlags, getDirectoryPath, getJSDocAugmentsTag, @@ -6368,13 +6370,31 @@ export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFi */ export function sourceFileMayBeEmitted(sourceFile: SourceFile, host: SourceFileMayBeEmittedHost, forceDtsEmit?: boolean) { const options = host.getCompilerOptions(); - return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && - !sourceFile.isDeclarationFile && - !host.isSourceFileFromExternalLibrary(sourceFile) && - (forceDtsEmit || ( - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName) - )); + // Js files are emitted only if option is enabled + if (options.noEmitForJsFiles && isSourceFileJS(sourceFile)) return false; + // Declaration files are not emitted + if (sourceFile.isDeclarationFile) return false; + // Source file from node_modules are not emitted + if (host.isSourceFileFromExternalLibrary(sourceFile)) return false; + // forcing dts emit => file needs to be emitted + if (forceDtsEmit) return true; + // Check other conditions for file emit + // Source files from referenced projects are not emitted + if (host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) return false; + // Any non json file should be emitted + if (!isJsonSourceFile(sourceFile)) return true; + if (host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) return false; + // Emit json file if outFile is specified + if (outFile(options)) return true; + // Json file is not emitted if outDir is not specified + if (!options.outDir) return false; + // Otherwise if rootDir or composite config file, we know common sourceDir and can check if file would be emitted in same location + if (options.rootDir || (options.composite && options.configFilePath)) { + const commonDir = getNormalizedAbsolutePath(getCommonSourceDirectory(options, () => [], host.getCurrentDirectory(), host.getCanonicalFileName), host.getCurrentDirectory()); + const outputPath = getSourceFilePathInNewDirWorker(sourceFile.fileName, options.outDir, host.getCurrentDirectory(), commonDir, host.getCanonicalFileName); + if (comparePaths(sourceFile.fileName, outputPath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === Comparison.EqualTo) return false; + } + return true; } /** @internal */ diff --git a/src/harness/fakesHosts.ts b/src/harness/fakesHosts.ts index 390d69d93ce..770b092ec5b 100644 --- a/src/harness/fakesHosts.ts +++ b/src/harness/fakesHosts.ts @@ -153,7 +153,10 @@ export class System implements ts.System { } public setModifiedTime(path: string, time: Date) { - this.vfs.utimesSync(path, time, time); + try { + this.vfs.utimesSync(path, time, time); + } + catch { /* ignored */ } } public createHash(data: string): string { diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index ceac563a00a..4159b340dbb 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -1,92 +1,228 @@ -import * as vfs from "../../_namespaces/vfs"; +import { + CompilerOptions, +} from "../../_namespaces/ts"; +import { + dedent, +} from "../../_namespaces/Utils"; import { noChangeOnlyRuns, verifyTsc, + VerifyTscWithEditsInput, } from "../helpers/tsc"; import { - loadProjectFromDisk, + loadProjectFromFiles, replaceText, } from "../helpers/vfs"; describe("unittests:: tsbuild:: with resolveJsonModule option on project resolveJsonModuleAndComposite", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite"); + function getProjFs(tsconfigFiles: object, additionalCompilerOptions?: CompilerOptions) { + return loadProjectFromFiles({ + "/src/src/hello.json": JSON.stringify( + { + hello: "world", + }, + undefined, + " ", + ), + "/src/src/index.ts": dedent` + import hello from "./hello.json" + export default hello.hello + `, + "/src/tsconfig.json": JSON.stringify( + { + compilerOptions: { + composite: true, + moduleResolution: "node", + module: "commonjs", + resolveJsonModule: true, + esModuleInterop: true, + allowSyntheticDefaultImports: true, + outDir: "dist", + skipDefaultLibCheck: true, + ...additionalCompilerOptions, + }, + ...tsconfigFiles, + }, + undefined, + " ", + ), + }); + } + + function verfiyJson( + input: Pick | string, + tsconfigFiles: object, + additionalCompilerOptions?: CompilerOptions, + ) { + if (typeof input === "string") input = { subScenario: input }; + verifyTsc({ + scenario: "resolveJsonModule", + fs: () => getProjFs(tsconfigFiles, additionalCompilerOptions), + commandLineArgs: ["--b", "/src/tsconfig.json", "--v", "--explainFiles", "--listEmittedFiles"], + ...input, + }); + verifyTsc({ + scenario: "resolveJsonModule", + fs: () => getProjFs(tsconfigFiles, { composite: undefined, ...additionalCompilerOptions }), + commandLineArgs: ["--b", "/src/tsconfig.json", "--v", "--explainFiles", "--listEmittedFiles"], + ...input, + subScenario: `${input.subScenario} non-composite`, + }); + } + + verfiyJson("include only", { + include: [ + "src/**/*", + ], }); - after(() => { - projFs = undefined!; // Release the contents - }); + verfiyJson("include only without outDir", { + include: [ + "src/**/*", + ], + }, { outDir: undefined }); - verifyTsc({ - scenario: "resolveJsonModule", - subScenario: "include only", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig_withInclude.json", "--v", "--explainFiles"], - }); - - verifyTsc({ - scenario: "resolveJsonModule", - subScenario: "include of json along with other include", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig_withIncludeOfJson.json", "--v", "--explainFiles"], - }); - - verifyTsc({ - scenario: "resolveJsonModule", - subScenario: "include of json along with other include and file name matches ts file", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig_withIncludeOfJson.json", "--v", "--explainFiles"], + verfiyJson({ + subScenario: "include only with json not in rootDir", modifyFs: fs => { - fs.rimrafSync("/src/src/hello.json"); - fs.writeFileSync("/src/src/index.json", JSON.stringify({ hello: "world" })); - fs.writeFileSync( - "/src/src/index.ts", - `import hello from "./index.json" - -export default hello.hello`, - ); + fs.renameSync("/src/src/hello.json", "/src/hello.json"); + replaceText(fs, "/src/src/index.ts", "./hello.json", "../hello.json"); }, + }, { + include: [ + "src/**/*", + ], + }, { rootDir: "src" }); + + verfiyJson({ + subScenario: "include only with json without rootDir but outside configDirectory", + modifyFs: fs => { + fs.renameSync("/src/src/hello.json", "/hello.json"); + replaceText(fs, "/src/src/index.ts", "./hello.json", "../../hello.json"); + }, + }, { + include: [ + "src/**/*", + ], }); - verifyTsc({ - scenario: "resolveJsonModule", - subScenario: "files containing json file", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig_withFiles.json", "--v", "--explainFiles"], + verfiyJson("include of json along with other include", { + include: [ + "src/**/*", + "src/**/*.json", + ], }); - verifyTsc({ - scenario: "resolveJsonModule", - subScenario: "include and files", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig_withIncludeAndFiles.json", "--v", "--explainFiles"], + verfiyJson({ + subScenario: "include of json along with other include and file name matches ts file", + modifyFs: fs => { + fs.renameSync("/src/src/hello.json", "/src/src/index.json"); + replaceText(fs, "/src/src/index.ts", "hello.json", "index.json"); + }, + }, { + include: [ + "src/**/*", + "src/**/*.json", + ], }); - verifyTsc({ - scenario: "resolveJsonModule", + verfiyJson("files containing json file", { + files: [ + "src/index.ts", + "src/hello.json", + ], + }); + + verfiyJson("include and files", { + files: [ + "src/hello.json", + ], + include: [ + "src/**/*", + ], + }); + + verfiyJson({ subScenario: "sourcemap", - fs: () => projFs, - commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose", "--explainFiles"], - modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"composite": true,`, `"composite": true, "sourceMap": true,`), edits: noChangeOnlyRuns, - }); + }, { + files: [ + "src/index.ts", + "src/hello.json", + ], + }, { sourceMap: true }); - verifyTsc({ - scenario: "resolveJsonModule", + verfiyJson({ subScenario: "without outDir", - fs: () => projFs, - commandLineArgs: ["--b", "src/tsconfig_withFiles.json", "--verbose"], - modifyFs: fs => replaceText(fs, "src/tsconfig_withFiles.json", `"outDir": "dist",`, ""), edits: noChangeOnlyRuns, - }); + }, { + files: [ + "src/index.ts", + "src/hello.json", + ], + }, { outDir: undefined }); }); describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { verifyTsc({ scenario: "resolveJsonModule", subScenario: "importing json module from project reference", - fs: () => loadProjectFromDisk("tests/projects/importJsonFromProjectReference"), + fs: () => + loadProjectFromFiles({ + "/src/strings/foo.json": JSON.stringify( + { + foo: "bar baz", + }, + undefined, + " ", + ), + "/src/strings/tsconfig.json": JSON.stringify( + { + extends: "../tsconfig.json", + include: ["foo.json"], + references: [], + }, + undefined, + " ", + ), + "/src/main/index.ts": dedent` + import { foo } from '../strings/foo.json'; + console.log(foo); + `, + "/src/main/tsconfig.json": JSON.stringify( + { + extends: "../tsconfig.json", + include: [ + "./**/*.ts", + ], + references: [{ + path: "../strings/tsconfig.json", + }], + }, + undefined, + " ", + ), + "/src/tsconfig.json": JSON.stringify( + { + compilerOptions: { + target: "es5", + module: "commonjs", + rootDir: "./", + composite: true, + resolveJsonModule: true, + strict: true, + esModuleInterop: true, + }, + references: [ + { path: "./strings/tsconfig.json" }, + { path: "./main/tsconfig.json" }, + ], + files: [], + }, + undefined, + " ", + ), + }), commandLineArgs: ["--b", "src/tsconfig.json", "--verbose", "--explainFiles"], edits: noChangeOnlyRuns, }); diff --git a/src/testRunner/unittests/tsserver/projectErrors.ts b/src/testRunner/unittests/tsserver/projectErrors.ts index 80a82f97fa5..a80ebc5dbf6 100644 --- a/src/testRunner/unittests/tsserver/projectErrors.ts +++ b/src/testRunner/unittests/tsserver/projectErrors.ts @@ -710,6 +710,7 @@ console.log(blabla);`, compilerOptions: { resolveJsonModule: true, composite: true, + outDir: "dist", }, include, }), diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js new file mode 100644 index 00000000000..64f6b164c26 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js @@ -0,0 +1,83 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' + Part of 'files' list in tsconfig.json +src/src/index.ts + Part of 'files' list in tsconfig.json +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js index e6fb12965a1..34859f3f5ec 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js @@ -17,96 +17,47 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] } Output:: -/lib/tsc --b /src/tsconfig_withFiles.json --v --explainFiles -[12:00:06 AM] Projects in this build: - * src/tsconfig_withFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:07 AM] Project 'src/tsconfig_withFiles.json' is out of date because output file 'src/dist/tsconfig_withFiles.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:08 AM] Building project '/src/tsconfig_withFiles.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/dist/src/hello.json +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/hello.json @@ -138,10 +89,10 @@ var hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; -//// [/src/dist/tsconfig_withFiles.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}",{"version":"-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withFiles.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -165,15 +116,15 @@ exports.default = hello_json_1.default.hello; "affectsGlobalScope": true }, "../src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { "original": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -209,6 +160,6 @@ exports.default = hello_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1124 + "size": 1122 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/importing-json-module-from-project-reference.js b/tests/baselines/reference/tsbuild/resolveJsonModule/importing-json-module-from-project-reference.js index b2d5461ce51..203f18cfb6c 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/importing-json-module-from-project-reference.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/importing-json-module-from-project-reference.js @@ -17,77 +17,78 @@ declare const console: { log(msg: any): void; }; //// [/src/main/index.ts] import { foo } from '../strings/foo.json'; - -console.log(foo); +console.log(foo); + //// [/src/main/tsconfig.json] { - "extends": "../tsconfig.json", - "include": [ - "./**/*.ts" - ], - "references": [ - { - "path": "../strings/tsconfig.json" - } - ] + "extends": "../tsconfig.json", + "include": [ + "./**/*.ts" + ], + "references": [ + { + "path": "../strings/tsconfig.json" + } + ] } //// [/src/strings/foo.json] { - "foo": "bar baz" + "foo": "bar baz" } //// [/src/strings/tsconfig.json] { - "extends": "../tsconfig.json", - "include": [ "foo.json" ], - "references": [] + "extends": "../tsconfig.json", + "include": [ + "foo.json" + ], + "references": [] } //// [/src/tsconfig.json] { - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "rootDir": "./", - "composite": true, - "resolveJsonModule": true, - "strict": true, - "esModuleInterop": true - }, - "references": [ - { - "path": "./strings/tsconfig.json" - }, - { - "path": "./main/tsconfig.json" - } - ], - "files": [] -} - + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "rootDir": "./", + "composite": true, + "resolveJsonModule": true, + "strict": true, + "esModuleInterop": true + }, + "references": [ + { + "path": "./strings/tsconfig.json" + }, + { + "path": "./main/tsconfig.json" + } + ], + "files": [] +} Output:: /lib/tsc --b src/tsconfig.json --verbose --explainFiles -[12:00:06 AM] Projects in this build: +[12:00:13 AM] Projects in this build: * src/strings/tsconfig.json * src/main/tsconfig.json * src/tsconfig.json -[12:00:07 AM] Project 'src/strings/tsconfig.json' is out of date because output file 'src/strings/tsconfig.tsbuildinfo' does not exist +[12:00:14 AM] Project 'src/strings/tsconfig.json' is out of date because output file 'src/strings/tsconfig.tsbuildinfo' does not exist -[12:00:08 AM] Building project '/src/strings/tsconfig.json'... +[12:00:15 AM] Building project '/src/strings/tsconfig.json'... lib/lib.d.ts Default library for target 'es5' src/strings/foo.json Matched by include pattern 'foo.json' in 'src/strings/tsconfig.json' -[12:00:12 AM] Project 'src/main/tsconfig.json' is out of date because output file 'src/main/tsconfig.tsbuildinfo' does not exist +[12:00:19 AM] Project 'src/main/tsconfig.json' is out of date because output file 'src/main/tsconfig.tsbuildinfo' does not exist -[12:00:13 AM] Building project '/src/main/tsconfig.json'... +[12:00:20 AM] Building project '/src/main/tsconfig.json'... lib/lib.d.ts Default library for target 'es5' @@ -110,7 +111,7 @@ console.log(foo_json_1.foo); //// [/src/main/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../strings/foo.json","./index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"4395333385-{\n \"foo\": \"bar baz\"\n}",{"version":"-4651661680-import { foo } from '../strings/foo.json';\n\nconsole.log(foo);","signature":"-3531856636-export {};\n"}],"root":[3],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2],"latestChangedDtsFile":"./index.d.ts"},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","../strings/foo.json","./index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-5425277207-{\n \"foo\": \"bar baz\"\n}",{"version":"-6647471184-import { foo } from '../strings/foo.json';\nconsole.log(foo);\n","signature":"-3531856636-export {};\n"}],"root":[3],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,2],"latestChangedDtsFile":"./index.d.ts"},"version":"FakeTSVersion"} //// [/src/main/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -136,15 +137,15 @@ console.log(foo_json_1.foo); "affectsGlobalScope": true }, "../strings/foo.json": { - "version": "4395333385-{\n \"foo\": \"bar baz\"\n}", - "signature": "4395333385-{\n \"foo\": \"bar baz\"\n}" + "version": "-5425277207-{\n \"foo\": \"bar baz\"\n}", + "signature": "-5425277207-{\n \"foo\": \"bar baz\"\n}" }, "./index.ts": { "original": { - "version": "-4651661680-import { foo } from '../strings/foo.json';\n\nconsole.log(foo);", + "version": "-6647471184-import { foo } from '../strings/foo.json';\nconsole.log(foo);\n", "signature": "-3531856636-export {};\n" }, - "version": "-4651661680-import { foo } from '../strings/foo.json';\n\nconsole.log(foo);", + "version": "-6647471184-import { foo } from '../strings/foo.json';\nconsole.log(foo);\n", "signature": "-3531856636-export {};\n" } }, @@ -176,11 +177,11 @@ console.log(foo_json_1.foo); "latestChangedDtsFile": "./index.d.ts" }, "version": "FakeTSVersion", - "size": 1032 + "size": 1030 } //// [/src/strings/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./foo.json"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"4395333385-{\n \"foo\": \"bar baz\"\n}"],"root":[2],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./foo.json"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-5425277207-{\n \"foo\": \"bar baz\"\n}"],"root":[2],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} //// [/src/strings/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -200,8 +201,8 @@ console.log(foo_json_1.foo); "affectsGlobalScope": true }, "./foo.json": { - "version": "4395333385-{\n \"foo\": \"bar baz\"\n}", - "signature": "4395333385-{\n \"foo\": \"bar baz\"\n}" + "version": "-5425277207-{\n \"foo\": \"bar baz\"\n}", + "signature": "-5425277207-{\n \"foo\": \"bar baz\"\n}" } }, "root": [ @@ -226,7 +227,7 @@ console.log(foo_json_1.foo); ] }, "version": "FakeTSVersion", - "size": 816 + "size": 814 } @@ -237,14 +238,14 @@ Input:: Output:: /lib/tsc --b src/tsconfig.json --verbose --explainFiles -[12:00:19 AM] Projects in this build: +[12:00:26 AM] Projects in this build: * src/strings/tsconfig.json * src/main/tsconfig.json * src/tsconfig.json -[12:00:20 AM] Project 'src/strings/tsconfig.json' is up to date because newest input 'src/strings/foo.json' is older than output 'src/strings/tsconfig.tsbuildinfo' +[12:00:27 AM] Project 'src/strings/tsconfig.json' is up to date because newest input 'src/strings/foo.json' is older than output 'src/strings/tsconfig.tsbuildinfo' -[12:00:21 AM] Project 'src/main/tsconfig.json' is up to date because newest input 'src/main/index.ts' is older than output 'src/main/tsconfig.tsbuildinfo' +[12:00:28 AM] Project 'src/main/tsconfig.json' is up to date because newest input 'src/main/index.ts' is older than output 'src/main/tsconfig.tsbuildinfo' exitCode:: ExitStatus.Success diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js new file mode 100644 index 00000000000..e698ee8fbe2 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js @@ -0,0 +1,85 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "files": [ + "src/hello.json" + ], + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/hello.json' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Part of 'files' list in tsconfig.json + Imported via "./hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js index fc5f5791db0..fd7898bd1d3 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js @@ -17,103 +17,56 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "files": [ + "src/hello.json" + ], + "include": [ + "src/**/*" + ] } Output:: -/lib/tsc --b /src/tsconfig_withIncludeAndFiles.json --v --explainFiles -[12:00:06 AM] Projects in this build: - * src/tsconfig_withIncludeAndFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:07 AM] Project 'src/tsconfig_withIncludeAndFiles.json' is out of date because output file 'src/dist/tsconfig_withIncludeAndFiles.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:08 AM] Building project '/src/tsconfig_withIncludeAndFiles.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/dist/src/hello.json +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/hello.json Part of 'files' list in tsconfig.json Imported via "./hello.json" from file 'src/src/index.ts' src/src/index.ts - Matched by include pattern 'src/**/*' in 'src/tsconfig_withIncludeAndFiles.json' + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' exitCode:: ExitStatus.Success @@ -138,10 +91,10 @@ var hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; -//// [/src/dist/tsconfig_withIncludeAndFiles.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}",{"version":"-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withIncludeAndFiles.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -165,15 +118,15 @@ exports.default = hello_json_1.default.hello; "affectsGlobalScope": true }, "../src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { "original": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -209,6 +162,6 @@ exports.default = hello_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1124 + "size": 1122 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js new file mode 100644 index 00000000000..141fdd0a23e --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js @@ -0,0 +1,83 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/index.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./index.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*", + "src/**/*.json" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json + +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:14 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/index.json +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/index.json + Imported via "./index.json" from file 'src/src/index.ts' + Matched by include pattern 'src/**/*.json' in 'src/tsconfig.json' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var index_json_1 = __importDefault(require("./index.json")); +exports.default = index_json_1.default.hello; + + +//// [/src/dist/index.json] +{ + "hello": "world" +} + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js index 0e7045cf68b..54837b6d576 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js @@ -16,102 +16,55 @@ interface ReadonlyArray {} declare const console: { log(msg: any): void; }; //// [/src/src/index.json] -{"hello":"world"} +{ + "hello": "world" +} //// [/src/src/index.ts] import hello from "./index.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*", + "src/**/*.json" + ] } Output:: -/lib/tsc --b /src/tsconfig_withIncludeOfJson.json --v --explainFiles -[12:00:09 AM] Projects in this build: - * src/tsconfig_withIncludeOfJson.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json -[12:00:10 AM] Project 'src/tsconfig_withIncludeOfJson.json' is out of date because output file 'src/dist/tsconfig_withIncludeOfJson.tsbuildinfo' does not exist +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:11 AM] Building project '/src/tsconfig_withIncludeOfJson.json'... +[12:00:14 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/dist/src/index.json +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/index.json Imported via "./index.json" from file 'src/src/index.ts' - Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json' + Matched by include pattern 'src/**/*.json' in 'src/tsconfig.json' src/src/index.ts - Matched by include pattern 'src/**/*' in 'src/tsconfig_withIncludeOfJson.json' + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' exitCode:: ExitStatus.Success @@ -131,13 +84,15 @@ exports.default = index_json_1.default.hello; //// [/src/dist/src/index.json] -{ "hello": "world" } +{ + "hello": "world" +} -//// [/src/dist/tsconfig_withIncludeOfJson.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/index.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-2379406821-{\"hello\":\"world\"}",{"version":"-6335882310-import hello from \"./index.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/index.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-19435552038-import hello from \"./index.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withIncludeOfJson.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -161,15 +116,15 @@ exports.default = index_json_1.default.hello; "affectsGlobalScope": true }, "../src/index.json": { - "version": "-2379406821-{\"hello\":\"world\"}", - "signature": "-2379406821-{\"hello\":\"world\"}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { "original": { - "version": "-6335882310-import hello from \"./index.json\"\n\nexport default hello.hello", + "version": "-19435552038-import hello from \"./index.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-6335882310-import hello from \"./index.json\"\n\nexport default hello.hello", + "version": "-19435552038-import hello from \"./index.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -205,6 +160,6 @@ exports.default = index_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1117 + "size": 1123 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js new file mode 100644 index 00000000000..309cf5a7e6f --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js @@ -0,0 +1,83 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*", + "src/**/*.json" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' + Matched by include pattern 'src/**/*.json' in 'src/tsconfig.json' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js index 1e204fd0270..92dc7d0ebdd 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js @@ -17,103 +17,54 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*", + "src/**/*.json" + ] } Output:: -/lib/tsc --b /src/tsconfig_withIncludeOfJson.json --v --explainFiles -[12:00:06 AM] Projects in this build: - * src/tsconfig_withIncludeOfJson.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:07 AM] Project 'src/tsconfig_withIncludeOfJson.json' is out of date because output file 'src/dist/tsconfig_withIncludeOfJson.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:08 AM] Building project '/src/tsconfig_withIncludeOfJson.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/dist/src/hello.json +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' - Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json' + Matched by include pattern 'src/**/*.json' in 'src/tsconfig.json' src/src/index.ts - Matched by include pattern 'src/**/*' in 'src/tsconfig_withIncludeOfJson.json' + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' exitCode:: ExitStatus.Success @@ -138,10 +89,10 @@ var hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; -//// [/src/dist/tsconfig_withIncludeOfJson.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}",{"version":"-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withIncludeOfJson.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -165,15 +116,15 @@ exports.default = hello_json_1.default.hello; "affectsGlobalScope": true }, "../src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { "original": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -209,6 +160,6 @@ exports.default = hello_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1124 + "size": 1122 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js new file mode 100644 index 00000000000..c095c98cd2d --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js @@ -0,0 +1,81 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir-non-composite.js new file mode 100644 index 00000000000..9e0d244c4bc --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir-non-composite.js @@ -0,0 +1,75 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "../hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "rootDir": "src" + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json + +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:14 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/hello.json + Imported via "../hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("../hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir.js new file mode 100644 index 00000000000..84471735a90 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir.js @@ -0,0 +1,154 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "../hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "rootDir": "src" + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json + +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/tsconfig.tsbuildinfo' does not exist + +[12:00:14 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/index.js +TSFILE: /src/dist/index.d.ts +TSFILE: /src/tsconfig.tsbuildinfo +lib/lib.d.ts + Default library for target 'es5' +src/hello.json + Imported via "../hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/index.d.ts] +declare const _default: string; +export default _default; + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("../hello.json")); +exports.default = hello_json_1.default.hello; + + +//// [/src/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../lib/lib.d.ts","./hello.json","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-17927595516-import hello from \"../hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./dist","rootDir":"./src","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"FakeTSVersion"} + +//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../lib/lib.d.ts", + "./hello.json", + "./src/index.ts" + ], + "fileNamesList": [ + [ + "./hello.json" + ] + ], + "fileInfos": { + "../lib/lib.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "./hello.json": { + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" + }, + "./src/index.ts": { + "original": { + "version": "-17927595516-import hello from \"../hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + }, + "version": "-17927595516-import hello from \"../hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + } + }, + "root": [ + [ + 3, + "./src/index.ts" + ] + ], + "options": { + "allowSyntheticDefaultImports": true, + "composite": true, + "esModuleInterop": true, + "module": 1, + "outDir": "./dist", + "rootDir": "./src", + "skipDefaultLibCheck": true + }, + "referencedMap": { + "./src/index.ts": [ + "./hello.json" + ] + }, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../lib/lib.d.ts", + "./hello.json", + "./src/index.ts" + ], + "latestChangedDtsFile": "./dist/index.d.ts" + }, + "version": "FakeTSVersion", + "size": 1136 +} + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js new file mode 100644 index 00000000000..7d6cef6f56c --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js @@ -0,0 +1,83 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/hello.json] +{ + "hello": "world" +} + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/index.ts] +import hello from "../../hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json + +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:14 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/src/src/index.js +[12:00:20 AM] Updating unchanged output timestamps of project '/src/tsconfig.json'... + +lib/lib.d.ts + Default library for target 'es5' +hello.json + Imported via "../../hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/src/src/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("../../hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory.js new file mode 100644 index 00000000000..951aaca3be9 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory.js @@ -0,0 +1,152 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/hello.json] +{ + "hello": "world" +} + +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/index.ts] +import hello from "../../hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:12 AM] Projects in this build: + * src/tsconfig.json + +[12:00:13 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist + +[12:00:14 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo +lib/lib.d.ts + Default library for target 'es5' +hello.json + Imported via "../../hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/dist/src/index.d.ts] +declare const _default: string; +export default _default; + + +//// [/src/dist/src/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("../../hello.json")); +exports.default = hello_json_1.default.hello; + + +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../../hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-19695506097-import hello from \"../../hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[2,1,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} + +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../../lib/lib.d.ts", + "../../hello.json", + "../src/index.ts" + ], + "fileNamesList": [ + [ + "../../hello.json" + ] + ], + "fileInfos": { + "../../lib/lib.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "../../hello.json": { + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" + }, + "../src/index.ts": { + "original": { + "version": "-19695506097-import hello from \"../../hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + }, + "version": "-19695506097-import hello from \"../../hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + } + }, + "root": [ + [ + 3, + "../src/index.ts" + ] + ], + "options": { + "allowSyntheticDefaultImports": true, + "composite": true, + "esModuleInterop": true, + "module": 1, + "outDir": "./", + "skipDefaultLibCheck": true + }, + "referencedMap": { + "../src/index.ts": [ + "../../hello.json" + ] + }, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../hello.json", + "../../lib/lib.d.ts", + "../src/index.ts" + ], + "latestChangedDtsFile": "./src/index.d.ts" + }, + "version": "FakeTSVersion", + "size": 1124 +} + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir-non-composite.js new file mode 100644 index 00000000000..2508e3a4411 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir-non-composite.js @@ -0,0 +1,73 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/src/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/src/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/src/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir.js new file mode 100644 index 00000000000..7a4b6eb25e4 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir.js @@ -0,0 +1,150 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/tsconfig.tsbuildinfo' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/src/index.js +TSFILE: /src/src/index.d.ts +TSFILE: /src/tsconfig.tsbuildinfo +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' +src/src/index.ts + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' +exitCode:: ExitStatus.Success + + +//// [/src/src/index.d.ts] +declare const _default: string; +export default _default; + + +//// [/src/src/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + +//// [/src/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../lib/lib.d.ts","./src/hello.json","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} + +//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../lib/lib.d.ts", + "./src/hello.json", + "./src/index.ts" + ], + "fileNamesList": [ + [ + "./src/hello.json" + ] + ], + "fileInfos": { + "../lib/lib.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "./src/hello.json": { + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" + }, + "./src/index.ts": { + "original": { + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + }, + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", + "signature": "6785192742-declare const _default: string;\nexport default _default;\n" + } + }, + "root": [ + [ + 3, + "./src/index.ts" + ] + ], + "options": { + "allowSyntheticDefaultImports": true, + "composite": true, + "esModuleInterop": true, + "module": 1, + "skipDefaultLibCheck": true + }, + "referencedMap": { + "./src/index.ts": [ + "./src/hello.json" + ] + }, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../lib/lib.d.ts", + "./src/hello.json", + "./src/index.ts" + ], + "latestChangedDtsFile": "./src/index.d.ts" + }, + "version": "FakeTSVersion", + "size": 1101 +} + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only.js b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only.js index e8475c22dae..adedac4ecd1 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/include-only.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/include-only.js @@ -17,117 +17,64 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true + }, + "include": [ + "src/**/*" + ] } Output:: -/lib/tsc --b /src/tsconfig_withInclude.json --v --explainFiles -[12:00:06 AM] Projects in this build: - * src/tsconfig_withInclude.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:07 AM] Project 'src/tsconfig_withInclude.json' is out of date because output file 'src/dist/tsconfig_withInclude.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:08 AM] Building project '/src/tsconfig_withInclude.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... -src/src/index.ts:1:19 - error TS6307: File '/src/src/hello.json' is not listed within the file list of project '/src/tsconfig_withInclude.json'. Projects must list all files or use an 'include' pattern. +src/src/index.ts:1:19 - error TS6307: File '/src/src/hello.json' is not listed within the file list of project '/src/tsconfig.json'. Projects must list all files or use an 'include' pattern. 1 import hello from "./hello.json"    ~~~~~~~~~~~~~~ +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' src/src/index.ts - Matched by include pattern 'src/**/*' in 'src/tsconfig_withInclude.json' + Matched by include pattern 'src/**/*' in 'src/tsconfig.json' Found 1 error. exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped -//// [/src/dist/tsconfig_withInclude.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}","-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello"],"root":[3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3],"affectedFilesPendingEmit":[2,3],"emitSignatures":[3]},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}","-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n"],"root":[3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3],"affectedFilesPendingEmit":[2,3],"emitSignatures":[3]},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withInclude.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -151,12 +98,12 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped "affectsGlobalScope": true }, "../src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", - "signature": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello" + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", + "signature": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n" } }, "root": [ @@ -203,6 +150,6 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped ] }, "version": "FakeTSVersion", - "size": 1042 + "size": 1040 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js new file mode 100644 index 00000000000..514c4e98685 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js @@ -0,0 +1,104 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "sourceMap": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/dist/hello.json +TSFILE: /src/dist/index.js.map +TSFILE: /src/dist/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' + Part of 'files' list in tsconfig.json +src/src/index.ts + Part of 'files' list in tsconfig.json +exitCode:: ExitStatus.Success + + +//// [/src/dist/hello.json] +{ + "hello": "world" +} + + +//// [/src/dist/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; +//# sourceMappingURL=index.js.map + +//// [/src/dist/index.js.map] +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4DAAgC;AAChC,kBAAe,oBAAK,CAAC,KAAK,CAAA"} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:17 AM] Projects in this build: + * src/tsconfig.json + +[12:00:18 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/dist/hello.json' + +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js b/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js index 8f1a3f319db..56f5710b96c 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js @@ -17,96 +17,49 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, "sourceMap": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "outDir": "dist", + "skipDefaultLibCheck": true, + "sourceMap": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] } Output:: -/lib/tsc --b src/tsconfig_withFiles.json --verbose --explainFiles -[12:00:07 AM] Projects in this build: - * src/tsconfig_withFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:08 AM] Project 'src/tsconfig_withFiles.json' is out of date because output file 'src/dist/tsconfig_withFiles.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/dist/tsconfig.tsbuildinfo' does not exist -[12:00:09 AM] Building project '/src/tsconfig_withFiles.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/dist/src/hello.json +TSFILE: /src/dist/src/index.js.map +TSFILE: /src/dist/src/index.js +TSFILE: /src/dist/src/index.d.ts +TSFILE: /src/dist/tsconfig.tsbuildinfo lib/lib.d.ts Default library for target 'es5' src/src/hello.json @@ -139,12 +92,12 @@ exports.default = hello_json_1.default.hello; //# sourceMappingURL=index.js.map //// [/src/dist/src/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4DAAgC;AAEhC,kBAAe,oBAAK,CAAC,KAAK,CAAA"} +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4DAAgC;AAChC,kBAAe,oBAAK,CAAC,KAAK,CAAA"} -//// [/src/dist/tsconfig_withFiles.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}",{"version":"-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true,"sourceMap":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/dist/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","../src/hello.json","../src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"outDir":"./","skipDefaultLibCheck":true,"sourceMap":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/dist/tsconfig_withFiles.tsbuildinfo.readable.baseline.txt] +//// [/src/dist/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -168,15 +121,15 @@ exports.default = hello_json_1.default.hello; "affectsGlobalScope": true }, "../src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "../src/index.ts": { "original": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -213,7 +166,7 @@ exports.default = hello_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1141 + "size": 1139 } @@ -223,11 +176,11 @@ Input:: Output:: -/lib/tsc --b src/tsconfig_withFiles.json --verbose --explainFiles -[12:00:19 AM] Projects in this build: - * src/tsconfig_withFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:22 AM] Projects in this build: + * src/tsconfig.json -[12:00:20 AM] Project 'src/tsconfig_withFiles.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/dist/tsconfig_withFiles.tsbuildinfo' +[12:00:23 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/dist/tsconfig.tsbuildinfo' exitCode:: ExitStatus.Success diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir-non-composite.js b/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir-non-composite.js new file mode 100644 index 00000000000..a483868dcc2 --- /dev/null +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir-non-composite.js @@ -0,0 +1,91 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/src/hello.json] +{ + "hello": "world" +} + +//// [/src/src/index.ts] +import hello from "./hello.json" +export default hello.hello + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipDefaultLibCheck": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] +} + + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json + +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/src/index.js' does not exist + +[12:00:12 AM] Building project '/src/tsconfig.json'... + +TSFILE: /src/src/index.js +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' + Part of 'files' list in tsconfig.json +src/src/index.ts + Part of 'files' list in tsconfig.json +exitCode:: ExitStatus.Success + + +//// [/src/src/index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hello_json_1 = __importDefault(require("./hello.json")); +exports.default = hello_json_1.default.hello; + + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:14 AM] Projects in this build: + * src/tsconfig.json + +[12:00:15 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/src/index.js' + +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js b/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js index 8123edee8e9..db28d784ee0 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js @@ -17,96 +17,52 @@ declare const console: { log(msg: any): void; }; //// [/src/src/hello.json] { - "hello": "world" + "hello": "world" } //// [/src/src/index.ts] import hello from "./hello.json" - -export default hello.hello +export default hello.hello -//// [/src/tsconfig_withFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} -//// [/src/tsconfig_withInclude.json] +//// [/src/tsconfig.json] { - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeAndFiles.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} - -//// [/src/tsconfig_withIncludeOfJson.json] -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] + "compilerOptions": { + "composite": true, + "moduleResolution": "node", + "module": "commonjs", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipDefaultLibCheck": true + }, + "files": [ + "src/index.ts", + "src/hello.json" + ] } Output:: -/lib/tsc --b src/tsconfig_withFiles.json --verbose -[12:00:07 AM] Projects in this build: - * src/tsconfig_withFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:10 AM] Projects in this build: + * src/tsconfig.json -[12:00:08 AM] Project 'src/tsconfig_withFiles.json' is out of date because output file 'src/tsconfig_withFiles.tsbuildinfo' does not exist +[12:00:11 AM] Project 'src/tsconfig.json' is out of date because output file 'src/tsconfig.tsbuildinfo' does not exist -[12:00:09 AM] Building project '/src/tsconfig_withFiles.json'... +[12:00:12 AM] Building project '/src/tsconfig.json'... +TSFILE: /src/src/index.js +TSFILE: /src/src/index.d.ts +TSFILE: /src/tsconfig.tsbuildinfo +lib/lib.d.ts + Default library for target 'es5' +src/src/hello.json + Imported via "./hello.json" from file 'src/src/index.ts' + Part of 'files' list in tsconfig.json +src/src/index.ts + Part of 'files' list in tsconfig.json exitCode:: ExitStatus.Success @@ -125,10 +81,10 @@ var hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; -//// [/src/tsconfig_withFiles.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/hello.json","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"6651571919-{\n \"hello\": \"world\"\n}",{"version":"-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} +//// [/src/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../lib/lib.d.ts","./src/hello.json","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"7507174767-{\n \"hello\": \"world\"\n}",{"version":"-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n","signature":"6785192742-declare const _default: string;\nexport default _default;\n"}],"root":[2,3],"options":{"allowSyntheticDefaultImports":true,"composite":true,"esModuleInterop":true,"module":1,"skipDefaultLibCheck":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3],"latestChangedDtsFile":"./src/index.d.ts"},"version":"FakeTSVersion"} -//// [/src/tsconfig_withFiles.tsbuildinfo.readable.baseline.txt] +//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { "program": { "fileNames": [ @@ -152,15 +108,15 @@ exports.default = hello_json_1.default.hello; "affectsGlobalScope": true }, "./src/hello.json": { - "version": "6651571919-{\n \"hello\": \"world\"\n}", - "signature": "6651571919-{\n \"hello\": \"world\"\n}" + "version": "7507174767-{\n \"hello\": \"world\"\n}", + "signature": "7507174767-{\n \"hello\": \"world\"\n}" }, "./src/index.ts": { "original": { - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" }, - "version": "-27703454282-import hello from \"./hello.json\"\n\nexport default hello.hello", + "version": "-6443385642-import hello from \"./hello.json\"\nexport default hello.hello\n", "signature": "6785192742-declare const _default: string;\nexport default _default;\n" } }, @@ -195,7 +151,7 @@ exports.default = hello_json_1.default.hello; "latestChangedDtsFile": "./src/index.d.ts" }, "version": "FakeTSVersion", - "size": 1105 + "size": 1103 } @@ -205,11 +161,11 @@ Input:: Output:: -/lib/tsc --b src/tsconfig_withFiles.json --verbose -[12:00:15 AM] Projects in this build: - * src/tsconfig_withFiles.json +/lib/tsc --b /src/tsconfig.json --v --explainFiles --listEmittedFiles +[12:00:18 AM] Projects in this build: + * src/tsconfig.json -[12:00:16 AM] Project 'src/tsconfig_withFiles.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/tsconfig_withFiles.tsbuildinfo' +[12:00:19 AM] Project 'src/tsconfig.json' is up to date because newest input 'src/src/index.ts' is older than output 'src/tsconfig.tsbuildinfo' exitCode:: ExitStatus.Success diff --git a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js index 063eb070fff..a04dca8b3f1 100644 --- a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js +++ b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js @@ -23,7 +23,7 @@ interface String { charAt: any; } interface Array { length: number; [n: number]: T; } //// [/user/username/projects/myproject/tsconfig.json] -{"compilerOptions":{"resolveJsonModule":true,"composite":true},"include":["./src/*.ts","./src/*.json"]} +{"compilerOptions":{"resolveJsonModule":true,"composite":true,"outDir":"dist"},"include":["./src/*.ts","./src/*.json"]} Info seq [hh:mm:ss:mss] request: @@ -57,6 +57,7 @@ Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json "options": { "resolveJsonModule": true, "composite": true, + "outDir": "/user/username/projects/myproject/dist", "configFilePath": "/user/username/projects/myproject/tsconfig.json" } } @@ -122,7 +123,8 @@ Info seq [hh:mm:ss:mss] event: }, "compilerOptions": { "resolveJsonModule": true, - "composite": true + "composite": true, + "outDir": "" }, "typeAcquisition": { "enable": false, diff --git a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js index aaf3113ae90..29b7bb50eea 100644 --- a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js +++ b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js @@ -23,7 +23,7 @@ interface String { charAt: any; } interface Array { length: number; [n: number]: T; } //// [/user/username/projects/myproject/tsconfig.json] -{"compilerOptions":{"resolveJsonModule":true,"composite":true},"include":["./src/*.ts"]} +{"compilerOptions":{"resolveJsonModule":true,"composite":true,"outDir":"dist"},"include":["./src/*.ts"]} Info seq [hh:mm:ss:mss] request: @@ -56,6 +56,7 @@ Info seq [hh:mm:ss:mss] Config: /user/username/projects/myproject/tsconfig.json "options": { "resolveJsonModule": true, "composite": true, + "outDir": "/user/username/projects/myproject/dist", "configFilePath": "/user/username/projects/myproject/tsconfig.json" } } @@ -120,7 +121,8 @@ Info seq [hh:mm:ss:mss] event: }, "compilerOptions": { "resolveJsonModule": true, - "composite": true + "composite": true, + "outDir": "" }, "typeAcquisition": { "enable": false, diff --git a/tests/projects/importJsonFromProjectReference/main/index.ts b/tests/projects/importJsonFromProjectReference/main/index.ts deleted file mode 100644 index 96fe3ccef3f..00000000000 --- a/tests/projects/importJsonFromProjectReference/main/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { foo } from '../strings/foo.json'; - -console.log(foo); \ No newline at end of file diff --git a/tests/projects/importJsonFromProjectReference/main/tsconfig.json b/tests/projects/importJsonFromProjectReference/main/tsconfig.json deleted file mode 100644 index 22911a0231a..00000000000 --- a/tests/projects/importJsonFromProjectReference/main/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ - "./**/*.ts" - ], - "references": [ - { - "path": "../strings/tsconfig.json" - } - ] -} \ No newline at end of file diff --git a/tests/projects/importJsonFromProjectReference/strings/foo.json b/tests/projects/importJsonFromProjectReference/strings/foo.json deleted file mode 100644 index 90505326a2c..00000000000 --- a/tests/projects/importJsonFromProjectReference/strings/foo.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "foo": "bar baz" -} \ No newline at end of file diff --git a/tests/projects/importJsonFromProjectReference/strings/tsconfig.json b/tests/projects/importJsonFromProjectReference/strings/tsconfig.json deleted file mode 100644 index 6d3c89089ef..00000000000 --- a/tests/projects/importJsonFromProjectReference/strings/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ "foo.json" ], - "references": [] -} \ No newline at end of file diff --git a/tests/projects/importJsonFromProjectReference/tsconfig.json b/tests/projects/importJsonFromProjectReference/tsconfig.json deleted file mode 100644 index ae6564321c3..00000000000 --- a/tests/projects/importJsonFromProjectReference/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "rootDir": "./", - "composite": true, - "resolveJsonModule": true, - "strict": true, - "esModuleInterop": true - }, - "references": [ - { - "path": "./strings/tsconfig.json" - }, - { - "path": "./main/tsconfig.json" - } - ], - "files": [] -} diff --git a/tests/projects/resolveJsonModuleAndComposite/src/hello.json b/tests/projects/resolveJsonModuleAndComposite/src/hello.json deleted file mode 100644 index eeedd400762..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/src/hello.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hello": "world" -} \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/src/index.ts b/tests/projects/resolveJsonModuleAndComposite/src/index.ts deleted file mode 100644 index 997c752d5a6..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import hello from "./hello.json" - -export default hello.hello \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json deleted file mode 100644 index e463caf4879..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/index.ts", "src/hello.json" - ] -} \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json deleted file mode 100644 index dde5eec33c4..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*" - ] -} \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json deleted file mode 100644 index 82da9b398a7..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "files": [ - "src/hello.json" - ], - "include": [ - "src/**/*" - ] -} \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json deleted file mode 100644 index 47279604fa6..00000000000 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "composite": true, - "moduleResolution": "node", - "module": "commonjs", - "resolveJsonModule": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "outDir": "dist", - "skipDefaultLibCheck": true - }, - "include": [ - "src/**/*", "src/**/*.json" - ] -} \ No newline at end of file