Giter VIP home page Giter VIP logo

ember-strict-resolver's Introduction

ember-strict-resolver

Build Status

Fast, concise, zero fun resolver for ember apps.

installation

ember install ember-strict-resolver

Usage

in app/resolver.js

export { default } from 'ember-strict-resolver';

For additional improvements when fully using the ember-strict-resolver monkey patching the registry to no longer cache and simply returning the values passed like the following can be produce extra performance.

// disable the normalization cache as we no longer normalize, the cache has become a bottle neck.
Ember.Registry.prototype.normalize = function (i) { return i; }

Migration

Migrating away from use the ember-resolver/classic can be done in piecemeal by supporting a sub-set of the old resolution formats.

noramlize is needed, because without it you will get errors related to failing to be able to inject services that were never noramlized in the registry.

// app/resolver.js

import Resolver from 'ember-strict-resolver';

export default class extends Resolver {
  legacyMappings = {
    'service:camelCaseNotSupported': 'service:camel-case-not-supported'
  };

  resolve(_fullName) {
    return super.resolve(this.legacyMappings[_fullName] || _fullName);
  }
  
  normalize(_fullName) {
    return this.legacyMappings[_fullName] || _fullName;
  }
}

This will allow you file PRs with libraries that currently do not support the strict resolver in its entirety.

In the event that you have a component that is failing to resolve correctly with the error Attempted to lookup "helper:nameOfVariable". Use "helper:name-of-variable" instead. please convert your template to use explicit-this. The template lint can be enabled by turning on no-implicit-this.

An example of what this looks like is the following

// addon/components/templates/foo.hbs

<div>
  {{fullName}}
</div>

This will result in the error, Attempted to lookup "helper:fullName". Use "helper:full-name" instead.. The fix for this would be to decide if this is a argument being passed into foo or if this is a local property.

fullName is coming from an invocation of Foo like the following:

<Foo
  @fullName="The Teamster"
/>

Then the fix for your template would be:

// addon/components/templates/foo.hbs

<div>
  {{@fullName}}
</div>

If fullName is a property on your component the fix would be:

// addon/components/templates/foo.hbs

<div>
  {{this.fullName}}
</div>

Development of the addon

  • git clone <repository-url> this repository
  • cd strict-resolver
  • yarn install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

ember-strict-resolver's People

Contributors

gabrielcsapo avatar stefanpenner avatar tmquinn avatar ember-tomster avatar

Watchers

James Cloos 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.