ember-strict-resolver

1.3.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i ember-strict-resolver

Weekly Downloads

321

Version

1.3.0

License

MIT

Unpacked Size

11.9 kB

Total Files

10

Last publish

Collaborators

  • stefanpenner
  • gabrielcsapo