Git Product home page Git Product logo

broccoli-ember-auto-register's Introduction

broccoli-ember-auto-register

Build Status

Automatically register Ember CLI addon files, making them usable from outside an Ember CLI app.

Installation

npm install --save-dev broccoli-ember-auto-register

Usage

var autoRegister = require('broccoli-ember-auto-register');
var registerTree = autoRegister(sourceTree, {
  moduleName: 'my-addon/register',
  modulePrefix: 'my-addon',
  outputFile: 'register.js'
});

The above will recursively walk sourceTree, adding a container.register call for each file it finds. So, for example, if there is a file named components/x-foo.js, the following will be written to the output file:

container.register('component:x-foo', require('my-addon/components/x-foo')['default']);

The topmost directory is used as the type. So if we were to come across a file named controllers/foo/edit.js, the following would be generated:

container.register('controller:foo/edit', require('my-addon/controllers/foo/edit')['default']);

In the interest of keeping this plugin small and focused, it does not attempt to filter the files. If you would like to exclude certain files, such as .gitkeep, you can do so with broccoli-static-compiler like so:

var autoRegister = require('broccoli-ember-auto-register');
var pickFiles = require('broccoli-static-compiler');
var registerTree = autoRegister(pickFiles(sourceTree, {
  srcDir: '/app',
  files: ['**/*.{handlebars,hbs,js}'],
  destDir: '/'
}), { modulePrefix: 'my-addon' });

The above would only include .handlebars, .hbs, or .js files under app/.

Options

  • moduleName: What to call the module that exports the initialization function. By default this is modulePrefix + '/register'.
  • modulePrefix: Prefix to be added to all require statements. Usually this is the same as the name of your addon.
  • outputFile: Where to write the resulting file. By default this is 'register.js'.

broccoli-ember-auto-register's People

Contributors

omghax 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.