Code Monkey home page Code Monkey logo

atom-babel6-transpiler's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

atom-babel6-transpiler

This project implements an Atom package transpiler that transpiles your package's files with Babel 6.

Usage

  1. Install the package
  2. Add an atomTranspilers entry to your package.json
  3. Install Babel presets and plugins, and configure Babel as you wish

In detail:

1. First, install the package from the npm registry:

npm install --save atom-babel6-transpiler

2. Next, modify your package.json to include a reference to the transpiler for any files you want Babel to process as described in the Atom Flight Manual. For example, to process every file ending in .js in your package, you could use:

{
  ...
  "atomTranspilers": [
    {
      "glob": "**/*.js",
      "transpiler": "atom-babel6-transpiler"
    }
  ]
}

3. Finally, install Babel and all the presets and plugins you want to use as normal. For a simple example, if you wanted to use the ES2015 and React presets, you might run:

npm install --save babel-preset-es2015 babel-preset-react

and then create a .babelrc file to configure Babel to use them:

{
  "presets": ["es2015", "react"]
}

You may also specify options in your package.json inside the optional options object; the subkey babel, if it exists, will be passed as options to babel.transform. Note that if you don't want Babel to search up the directory hierarchy for a .babelrc file, you need to add the "babelrc": false option to the settings. Otherwise Babel may mistakenly use a user's .babelrc from elsewhere on the filesystem when trying to build your package.

{
  // ...
  "atomTranspilers": [
    {
      "glob": "**/*.js",
      "transpiler": "atom-babel6-transpiler",
      "options": {
        "babel": {
          "presets": ["es2015", "react"],
          "babelrc": false
        }
      }
    }
  ]
}

Options

You may specify the following options as values of the options object in your package.json:

Option Default Description
setBabelEnv false, true or a string Sets the BABEL_ENV environment variable. When true, sets it to "development" when atom.inDevMode() or atom.inSpecMode() is true and "production" otherwise. When given as a string, uses the value of the environment variable of that name instead. The feature returns BABEL_ENV to its prior value after transpilation finishes.
babel {} Options to pass as the second argument to babel.transform (the same options you can put in a .babelrc).
cacheKeyFiles [] An array of files to include when determining whether or not to use the cache. For example, to force a recompile anytime your .babelrc changes, add .babelrc to this array.

Other Details

Source Maps

To enable source maps within Atom, set the Babel sourceMaps option to "inline" in your Babel configuration.

Babel Environment

Babel supports an option called env that allows you to configure Babel on a per-environment basis. The Babel environment is controlled via an environment variable called BABEL_ENV; this module automatically sets the environment variable to "development" if Atom is in dev mode (atom.inDevMode() returns true) and "production" otherwise.

atom-babel6-transpiler's People

Contributors

arcanemagus avatar binarymuse avatar darangi avatar smashwilson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atom-babel6-transpiler's Issues

Babel 7 support?

Yes, I realize the name of this is atom-babel6-transpiler ๐Ÿ˜›.

Should Babel 7 support be implemented here, or a new package created for that?

From a super quick look it seems like the only change would be making this line:

const babel = require('babel-core')

Be:

    const babel = require('@babel/core')

My package commands aren't available when using this package

I'd like to transition away from using the /** @babel */ comment approach to using the one provided by this repo but it simply isn't working. I have created a test package to demonstrate this. The test command simply isn't available via the command palette, even though no errors are thrown when reloading the window. Furthermore, the package is clearly being loaded in some way since adding console log statements outside of the default export in the main.js file does successfully log to the console.

For comparison, this branch of the same package does make the test command available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.