Ts-loader: webpack 4 things to do

Created on 14 Jan 2018  路  8Comments  路  Source: TypeStrong/ts-loader

List of things that we need to do to make ts-loader compatible with webpack 4:

Most helpful comment

He is actively working on it (https://github.com/TypeStrong/ts-loader/pull/710) :+1:

All 8 comments

any news?

He is actively working on it (https://github.com/TypeStrong/ts-loader/pull/710) :+1:

@johnnyreilly Is the new Weback 4 "sideEffects" supposed to work wtih typescript?

It seems that I can only get it to work with babel-loader, and not with ts-loader.

(trying to use import {isString} from 'lodash-es';without pulling in the entire lodash during build).

AFAIK there's nothing required for loaders to do. Let me know if you know otherwise.

@johnnyreilly It seems you have to pipe it through babel in order for it to tree-shake. I am using the following webpack configuration for the prod env:

[{

    // We are piping through babel to get Webpack 4 Tree Shaking support with { 'sideEffects' : false }
    loader: 'babel-loader'
}, {
    loader: 'ts-loader',
    options: ({
        transpileOnly: true,

        // Since we are piping trough babel we have to target es2016
        compilerOptions: {
            target: "es2016",
            module: "es2015"
        },
    })
}]

Webpack does the tree shaking, not Babel (Babel merely doesn't modify the import/export statements), you can have tree shaking even without Babel 馃槂

@cecilemuller I guess in the context of es5 exporting with typescript

Was this page helpful?
0 / 5 - 0 ratings