npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ember-decorators/babel-transforms

v5.2.0

Published

Configures the consuming ember-cli app's or addon's Babel transpiler for decorators.

Downloads

9,731

Readme

@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

# latest version
ember install "@ember-decorators/babel-transforms"

# latest 2.x version
ember install "@ember-decorators/babel-transforms@^2"

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. :wink:

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.