hottowel-angular-typescript icon indicating copy to clipboard operation
hottowel-angular-typescript copied to clipboard

Commonjs and Webpack

Open cveld opened this issue 8 years ago • 5 comments

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 avatar Apr 05 '16 08:04 cveld

@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 avatar Aug 01 '16 12:08 regevaz

@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.

cveld avatar Aug 03 '16 09:08 cveld

thanks for the reply. what are the chances of implementing your request...? :)

regevaz avatar Aug 03 '16 10:08 regevaz

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?

cveld avatar Aug 03 '16 19:08 cveld

Exactly! well, AFAIK, we should wait until Typescript will be more matured :)

regevaz avatar Aug 04 '16 06:08 regevaz