Typescript: [Transforms] Ported 6319: Support 'target':'es5' with 'module':'es6' to allow dead code elimination

Created on 14 Jun 2016  路  7Comments  路  Source: microsoft/TypeScript

Original issue #6319

Bug Transforms Fixed

Most helpful comment

Got it working by adding

 "moduleResolution": "node",

All 7 comments

I've been experimenting with webpack 2 and angular 2, and found that using babels es2015-webpack preset enabled dead code removal.

But I was disappointed when typescript didn't allow me to output es2015 modules with es5 output.

I think it's a good thing that typescript only handles compilation and not bundling.
By allowing us to output what ever we want from the compiler. It will make it easier for us to use whatever bundling software that is available at the moment.

@leon, support for --target es5 and --module es6 is already available in typescript@next; give it a try.

This issue is tracking porting the change to the transforms branch.

That's great! Cheers 馃嵒

@mhegazy with a working ng2 app that was using module: "commonjs" I tried changing to module: "es2015".
The app compiles and works, but the compiler is warning me about all node_modules imports, that they don't exist.

[default] /Users/leon/Documents/dashboard/client/src/app.ts:1:62 
    Cannot find module '@angular/core'.

Is there anything else I need to do to get the compiler to find all the typings that come with angular, rxjs and other npm packages?

Ps.
Sorry if this is the wrong forum for this question. Tell me if you want it as it's own issue.

Got it working by adding

 "moduleResolution": "node",

that is the correct fix. moduleResolution defaults to node if you are using module: commonjs, and needs to be specified explicitly for other module systems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gaelan picture Gaelan  路  231Comments

jonathandturner picture jonathandturner  路  147Comments

tenry92 picture tenry92  路  146Comments

kimamula picture kimamula  路  147Comments

xealot picture xealot  路  150Comments