Socket
Socket
Sign inDemoInstall

karma-typescript-es6-transform

Package Overview
Dependencies
184
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    karma-typescript-es6-transform

Plugin for transforming ES2015 javascript code to to ES5 syntax.


Version published
Weekly downloads
13K
decreased by-6.12%
Maintainers
2
Install size
17.5 MB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 01 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc