-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visual Studio 2015: TypeScriptCompiler always generates empty concatenated target file #4225
Comments
Are the files in your compilation actually putting anything into the global scope (these are what end up in the --out target file) or are they all external/ES6 modules? See #1544 |
Yes, I think so (please refer to the following screenshot). In Visual Studio it doesn't seem like there is a filter on what input files the TypeScript compiler is using, so I assume it's taking them all. Given that case, main.ts should contain a gobal that's requiring all the others: However, I'm trying to create a library, supposed to be deployed as a single file. So is there an option to have the --out option concatenate all input files in correct sequence, disregarding any global objects requiring them? Just adding them all? As far as I understand, in Visual Studio 2015 there is no option to tell which files to concatenate into a joined file. It just takes all available TypeScript files in the project. Nonetheless, to cope with this problem I could create a custom build step, using only the share of my library files as input to the TypeScript compiler. Or I could create a separate project for my library files and test the resulting, concatenated file in a separate Visual Studio TypeScript project. However, what I particularly want the TypeScript compiler to do is to automatically give corresponding names to each define() call (either within the resulting, concatenated file or to each single transpiled file) and to sort the defines in the concatenated file according to their internal dependency so things can get safely started at runtime even if the file is only partially loaded. The functionality required is similar to the Require Optimizer functionality. I'm not sure whether the sorting is necessary, though. But in any case I would want TSC to give names to the defines so I just can concatenate them into a single file (either using TSC itself or using some external concatenation tool) without problem or additional effort. |
I have now created a concise Visual Studio 2015 project demonstrating the issue. You may find it here. This project should run flawlessly, but it doesn't. I'd like to add that I believe it would be very feasible to be able to set a source folder array to the "concatenate transpiled files into a single file" option so not all files in the project are getting concatenated into one single file but only a selection of them. The preferred syntax is: [ "./TypeScript/*.ts": "./js/combined.js" // glob either ends with wildcard or directory to search
, "./Lib/*.ts": "./js/Lib.js" // syntax is: "source files": "concatenated into destination file"
, "./Test/TypeScript": "./Test/js/main.js"
] All TypeScript files not found by this array shall be transpiled and written separately, either to the optional TSC destination folder or to the same folder of the TypeScript source file. Here's a screenshot of the new sample project: |
This is working as intended. All your files are modules (formerly called external modules). main.ts uses an import statement, Base.ts and Derived.ts use export= statements. This means they each define their own module scope. The --out (and new --outFile) flag only concatenates globally scoped code into a single file, which you have none of, so you get an empty file. We have an issue tracking adding support for an error/warning if you use --out and get an empty file since it's likely a mistake. We don't currently support combining multiple external modules into a single file with a compiler flag but we have some work in progress on that front, like #4434 |
If I configure the TypeScript compiler in project settings (project type: "HTML application With TypeScript") to create a single concatenated target file, it always creates an empty file only. The resulting file never contains anything except "//# sourceMappingURL=SwingPanel.js.map" (see attached image).
The text was updated successfully, but these errors were encountered: