Git Product home page Git Product logo

ember-cli-shims's Introduction

Ember CLI Shims

Greenkeeper badge

Note: this project is deprecated. If you are using these shims in your project you should migrate to the new modules api outlined in RFC 176 as soon as you can. More information on this topic in the Ember 2.16 release blog post.

Note that you won't be able to drop this dependency from your app's package.json file until all your addons have upgraded to ember-cli-babel >= 6.6.0.

About

Ember CLI Shims (ECS) contain all the shims used in Ember CLI.

Note: The ember-data shim has been removed as of v0.1.0. The latest Ember-Data no longer has a bower dependency; ember-cli-shims >= v0.1.0 is only intended for use with Ember-Data v2.3.0 and up.

Usage

Simply import any of the shims as an ES6 module:

import Component from 'ember-component';
import run from 'ember-runloop';
import injectService from 'ember-service/inject';

Some of the shims have named exports (instead of/in addition to a default export):

import { assert, copy } from 'ember-metal/utils';
import { debounce } from 'ember-runloop';
import { isEmpty } from 'ember-utils';

Shims

The app-shims file provides a complete reference of all modules currently supported by this library.

Why?

Historically, Ember has recommended that developers reference core classes & utilities (ie Component, Route, isEmpty) via the root Ember namespace. This leads to the entire Ember module being imported into nearly every file:

import Ember from 'ember';

export default Ember.Component.extend({
  foo: Ember.inject.service(),
  bar: Ember.computed.readOnly('foo.bar')
});

It would be preferable to have different parts of Ember available as separate modules, allowing developers to only import what they need. This is the direction the framework is moving in, but the modules are not yet available. This has led to a common pattern of ES6 destructuring assignment to enable writing future-proof code:

import Ember from 'ember';

const { Component, computed, inject } = Ember;

export default Component.extend({
  foo: inject.service(),
  bar: computed.readOnly('foo.bar');
});

However, this library provides shims to mimic the future modules that Ember may provide, enabling developers to avoid destructuring and instead import the namespaces as modules today.

import Component from 'ember-component';
import computed from 'ember-computed';
import injectService from 'ember-service/inject';

export default Component.extend({
  foo: injectService(),
  bar: computed.readOnly('foo.bar');
});

That way, as true modules become available in the Ember ecosystem, we can merely remove the shims from ECS upstream, requiring little to no refactoring on the part of developers who have opted-in to this pattern early. Ultimately, the goal of this library is to be replaced completely once Ember itself is an npm package/addon and exports its own modules.

License

Ember CLI Shims is MIT Licensed.

ember-cli-shims's People

Contributors

amk221 avatar bantic avatar cbroeren avatar chriskrycho avatar cibernox avatar daltones avatar dhaulagiri avatar duggiefresh avatar ef4 avatar elwayman02 avatar fsmanuel avatar greenkeeper[bot] avatar hankfanchiu avatar jayphelps avatar locks avatar marten-dockyard avatar mitchlloyd avatar rwjblue avatar stefanpenner avatar thorsteinsson avatar tomdale avatar tricknotes avatar turbo87 avatar twokul avatar wagenet avatar xiphiasuvella avatar zeppelin 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.