You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using TS 1.7 and I'm trying to compile my project to one big file that I will be able to include in my html file.
My project structure looks like this:
-build // Build directory
-src // source root
--main.ts // my "Main" file that uses the imports my outer files
--subDirectories with more ts files.
-package.json
-tsconfig.json
When I build my project I expect the build.js file to be one big file compiled from my source. But ths build.js file is empty and I get all of my files compiled o js files.
Each of my TS files look a bit like this
import {blabla} from "../../bla/blas";
export default class bar implements someThing {
private variable : string;
}
Unfortunately, --module and --outFile is a trap combination for many users that is generally not useful. If you'd like to bundle your application, I'd suggest you remove outFile and use a tool like Browserify or Webpack.
Please consider adding native bundling support to typescript.
The workaround is a huge pain to setup and maintain: Compile all typescript modules to ES6, then transpile to ES5 with Babel using the correct babelrc, presets, etc; then feed the ES5 output to webpack (webpack 1.x doesn't support ES6)
Compile all typescript modules to ES6, then transpile to ES5 with Babel using the correct babelrc, presets, etc; then feed the ES5 output to webpack (webpack 1.x doesn't support ES6)
Mohamed Hegazy (@mhegazy) Good question... I had a few modules that required commonJS interop and that used to work with babel 5; now I moved to babel 6 and updated these modules anyway, so I'm going to fork my setup, remove the babel step and keep you updated.
Edit: It indeed works just fine without babel... and it's 3 times faster now, a welcomed change. Cheers.
After searching for days on how to do this, and being directed here, I also support this motion. A single export file would be great, I don't mind managing my other build steps with bash.
Reacted by Joncom, Chali-Anne Lauzon, Dennis Alund, Gabriele D'Arrigo, Simon Sarris, Victor Glindås, Adrian Leonhard, Anders Lassen, Martin Stemmle and Mathieu PATUREL
I can't be the only thinking wtf, but then again this is Microsoft, so not all that shocked
Reacted by Christopher Beck and Andrej K
Reacted by Nikos, Aluan Haddad, Kevin Beal, Dave Goodchild, Konstantin Kharlambov, Gavin Cannizzaro, Chris, James Skemp, Chris, Brendon Matos and 2 more
Activity
DanielRosenwasser commentedon Dec 27, 2015
Unfortunately,
--moduleand--outFileis a trap combination for many users that is generally not useful. If you'd like to bundle your application, I'd suggest you removeoutFileand use a tool like Browserify or Webpack.vladima commentedon Dec 27, 2015
actually in #5090 we've added support for bunding amd\system modules into one file. Can you give a try to
typescript@nexton npm?DanielRosenwasser commentedon Dec 27, 2015
Thanks for the correction Vladimir Matveev (@vladima), I didn't realize.
AlexGalays commentedon Jan 25, 2016
Please consider adding native bundling support to typescript.
The workaround is a huge pain to setup and maintain: Compile all typescript modules to ES6, then transpile to ES5 with Babel using the correct babelrc, presets, etc; then feed the ES5 output to webpack (webpack 1.x doesn't support ES6)
mhegazy commentedon Jan 25, 2016
Alexandre Galays (@AlexGalays) can you elaborate on why you need the babel step there? i understand the webpack step.
AlexGalays commentedon Jan 26, 2016
Mohamed Hegazy (@mhegazy) Good question... I had a few modules that required commonJS interop and that used to work with babel 5; now I moved to babel 6 and updated these modules anyway, so I'm going to fork my setup, remove the babel step and keep you updated.
Edit: It indeed works just fine without babel... and it's 3 times faster now, a welcomed change. Cheers.
DmitryEfimenko commentedon Mar 8, 2016
I'm a bit confused. Should not compiling multiple files in
amdmode withoutsetting specified result in a file with a singledefine(...)statement?I'm using
gulp-typescriptand have approximately following:Given that folder
feature1had two files (a.ts, andb.ts), the result is:... which to my understanding is not valid anyway. Shouldn't output be something like this:
mhegazy commentedon Mar 8, 2016
why is not it valid?
DmitryEfimenko commentedon Mar 8, 2016
docs for requirejs state:
mhegazy commentedon Mar 8, 2016
Please see http://requirejs.org/docs/api.html#modulename
DmitryEfimenko commentedon Mar 8, 2016
thanks for the right pointer.
quantuminformation commentedon Dec 20, 2016
After searching for days on how to do this, and being directed here, I also support this motion. A single export file would be great, I don't mind managing my other build steps with bash.
rochapablo commentedon Jan 5, 2017
+1
cwbeck commentedon Jul 28, 2017
I can't be the only thinking wtf, but then again this is Microsoft, so not all that shocked
quantuminformation commentedon Jul 28, 2017
At the moment I have a happy truce by using webpack + https://github.com/s-panferov/awesome-typescript-loader
quantuminformation commentedon Jul 28, 2017
That loader uses tsc bare metal commands.