hottowel-angular-typescript
hottowel-angular-typescript copied to clipboard
Commonjs and Webpack
Do you think it is preferable to switch over to Commonjs module code generation in combination with Webpack?
The main benefit I see is that dependencies are tracked through explicit imports within the .ts-files instead of having to wire them up manually in index.html or the tsconfig-files section to maintain execution order. Additionally, Webpack reduces configuration complexity compared to the chaining of several gulp tasks and its system also incorporates the bundling of styles and vendor assets through explicit referencing from within .ts-files.
A major downside I feel is that in the Commonjs pattern you will need to add explicit references in every .ts-file you produce.
@cveld - indeed that's a good question and i've also submitted a related ticket - https://github.com/johnpapa/hottowel-angular-typescript/issues/24
can you elaborate what do you mean by saying: "A major downside I feel is that in the Commonjs pattern you will need to add explicit references in every .ts-file you produce."?
Thanks!
@regevaz well in c# you implicitly get references to all of the stuff in the same namespace. That's not the case with TypeScript and Webpack. Since as soon as you do not explicitly reference (using the import statement) to the ts-files you require, Webpack will not include it in the bundle and the reference will be missing.
thanks for the reply. what are the chances of implementing your request...? :)
Well I think we need to define some kind of mapping from c# assemblies and namespaces towards TypeScript's module system. Somehow I would like to build modules that consist out of multiple TypeScript files and then reference such a module with only one import directive. Maybe it's already possible if I would know how?
Exactly! well, AFAIK, we should wait until Typescript will be more matured :)