Search code examples
javascriptwebpackjspmes6-module-loadertranspiler

Double transpile with ES6 bundler?


My current workflow, which is ES6-like but does not use module loading, is to use a Gulp task that runs my TypeScript code through tsc, producing ES6 output, and then again through Babel, producing ES5 output. I do this because TypeScript does not yet support async/await when outputting ES5 directly.

I would now like to start doing proper ES6 module-loading, which means I need a compatible bundler.

Does JSPM, Webpack, or anyone else support this double-transpiling process?


Solution

  • Webpack supports it - you can chain loaders. It would be sothing like following in webpack loaders configuration:

    {test: /\.ts$/, loaders: ['babel', 'ts-loader']}
    

    More about webpack loaders: https://webpack.github.io/docs/using-loaders.html