karma-typescript-es6-transform

    5.5.3 • Public • Published

    karma-typescript-es6-transform

    Npm Version Npm Total Downloads Travis Status Appveyor Status

    Karma-Typescript ❤️ 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

    Install

    npm i karma-typescript-es6-transform

    DownloadsWeekly Downloads

    8,422

    Version

    5.5.3

    License

    MIT

    Unpacked Size

    13.2 kB

    Total Files

    5

    Last publish

    Collaborators

    • erikbarke
    • monounity