• Packages
  • Themes
  • Documentation
  • Blog
  • Discuss
Sign in

transpile

Easily transpile code between languages in a standard way.
  • #transpile
  • #refactor
  • #convert
danielbayley
0.1.4 445
2
  • Repo
  • Bugs
  • Versions
  • License
Flag as spam or malicious

apm

Transpile code in Atom

Easily transpile code between languages within Atom in a standard way.

Transpile selected blocks of code in the editor, or else the current buffer, in which case the appropriate target grammar will automatically be applied on success.

Relevant files can also be converted directly in Tree view, but will transpile to a new adjacent file by default.

Transpiler commands are context aware to prevent unnecessary menu clutter, and are grouped into a single Transpile submenu.

Plugins

Plugin From To
transpile-js2coffee JavaScript CoffeeScript
transpile-decaf CoffeeScript JavaScript
transpile-lebab ES5 ES6/2015
transpile-cson CSON/JSON JSON/CSON
transpile-pug HTML Pug

API

Creating a plugin is as simple as possible. See the base example below, or the multiple existing packages for examples of how to implement your own.

// package.json 
"providedServices": {
  "transpile": {
    "versions": {
      "1.0.0": "activate"
    }
  }
},

This provides your transpiler as a service for this base package to build on.

# index.coffee 
module.exports =
  activate: ->
    name: 'transpile-plugin'
    from:
      scopeName: 'source.coffee'
      fileTypes: ['.coffee','[data-name*=coffee]','Cakefile']
    to:
      scopeName: 'source.js'
      ext: '.js' # Optional 
 
    transpile: (source) => #, indent, editor) 
      {transpile} = require 'transpiler'
      transpile source #, { options: indent } 

Notice that the from.fileTypes [array] can contain either file .extensions, complete file names, or a valid CSS attribute selector.

Your transpile: method should simply return the transpiled code, and will be supplied with the source code, along with the following [optional] arguments:

  • An indentation 'string' provided as a potential option to pass on to the underlying transpiler, since formatting should be preserved if possible.
  • The current Texteditor {object} instance.

Multiple transpilers can also be bundled in the same package; transpile-decaf for example provides a choice between decaf or decaffeinate, whereas transpile-cson can transpile between both CSON and JSON.

Install

apm install transpile or search “transpile” under Packages within Atom.

License

MIT © Daniel Bayley

I think this package is bad news.

Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
with by