1. karma-typescript-es6-transform
Plugin for transforming ES2015 javascript code to to ES5 syntax.
karma-typescript-es6-transform
Package: karma-typescript-es6-transform
Created by: monounity
Last modified: Mon, 01 May 2023 19:18:12 GMT
Version: 5.5.4
License: MIT
Downloads: 52,226
Repository: https://github.com/monounity/karma-typescript

Install

npm install karma-typescript-es6-transform
yarn add karma-typescript-es6-transform

karma-typescript-es6-transform

Npm Version
Npm Total Downloads
Travis Status
Appveyor Status

Karma-Typescript :heart: ES2015

This plugin uses the Babel compiler to transform ES2015 (aka ES6) code to ES5 syntax, making the code browser compatible when running tests with karma-typescript.

Installation

$ npm install --save-dev karma-typescript-es6-transform

Configuration

In the karma-typescript section of karma.conf.js:

 karmaTypescriptConfig: {
    bundlerOptions: {
        transforms: [
            require("karma-typescript-es6-transform")()
        ]
    }
}

Babel core options

By default, the options presets: [["@babel/preset-env"]] and filename: TransformContext.filename are passed to the Babel compiler.

Custom options can be passed to the compiler in the first argument when calling the plugin:

 karmaTypescriptConfig: {
    bundlerOptions: {
        transforms: [
            require("karma-typescript-es6-transform")({
                presets: [
                    ["@babel/preset-env", {
                        targets: {
                            chrome: "60"
                        }
                    }]
                ]
            })
        ]
    }
}

Passing custom presets or filename options will override the default settings.

ES2015 syntax detection

The javascript code passed to the plugin is statically analyzed by recursively traversing
the AST, looking for these ES2015 keywords: class, const, export, import, let.
If any keyword or a fat arrow function is found the code will be transformed to ES5 syntax.

Licensing

This software is licensed with the MIT license.

© 2016-2021 Erik Barke, Monounity

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code