Giter VIP home page Giter VIP logo

babel-transforms's Introduction

@ember-decorators/babel-transforms

Build Status npm version Greenkeeper badge dependencies Status devDependencies Status

Enables your app or addon to use decorators for ES6 classes.

Installation

For apps

ember install @ember-decorators/babel-transforms

For addons

Tests and dummy app only

If you're developing an addon and only intend to use decorators in your tests and / or dummy app (tests/dummy), just install this addon as a regular devDependency:

ember install @ember-decorators/babel-transforms

You can now use decorators in your tests/* directories, but not in your addon directory.

Internal use only

If you're developing an addon that only uses decorators interally, e.g. you don't export any decorators that the user is supposed to use, then it's sufficient to install this addon with the -S flag, so it is added as a dependency as opposed to the default devDependency

ember install -S @ember-decorators/babel-transforms

In addition to tests/*, you can now use decorators in your addon directory. However, do not make them public API, i.e. do not expect the user of you addon to be able to use these decorators.

Exporting decorators for the user

If you want to not only employ decorators internally, but also make them public API, so that users of your addon can use your decorators, then the consuming app or addon has to be properly configured for decorator usage.

This means, that users of your addon are required to add @ember-decorators/babel-transforms to their project as well. You can either instruct them to do so in your installation instructions and link them here or automatically add the dependency in the default blueprint using addAddonToProject:

// blueprints/<your-addon-name>/index.js
module.exports = {
  normalizeEntityName() {}, // no-op since we're just adding dependencies

  afterInstall() {
    return this.addAddonToProject('@ember-decorators/babel-transforms'); // is a promise
  }
};

You can also add it as a dependency (as opposed to the default devDependency):

// blueprints/<your-addon-name>/index.js
module.exports = {
  normalizeEntityName() {}, // no-op since we're just adding dependencies

  afterInstall() {
    return this.addAddonToProject({
      name: '@ember-decorators/babel-transforms',
      blueprintOptions: { save: true }
    }); // is a promise
  }
};

Also, don't forget to add @ember-decorators/babel-transforms to your own addon in the first place. ๐Ÿ˜‰

ember install -S @ember-decorators/babel-transforms

Configuration

You can configure this addon in you ember-cli-build.js file:

/* eslint-env node */
'use strict';

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
  const app = new EmberAddon(defaults, {
    '@ember-decorators/babel-transforms': {
      disable: false
    }
  });

  return app.toTree();
};

The only option is disable, which defaults to false. If you set disable to true, Babel will not get configured for decorators.

babel-transforms's People

Contributors

alexlafroscia avatar buschtoens avatar dfreeman avatar ember-tomster avatar pzuraq avatar rwjblue avatar stefanpenner avatar turbo87 avatar tylerturdenpants avatar

Watchers

 avatar  avatar  avatar

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.