Component exposed in ember addon is not recognised in ember app - ember.js

I have an addon that records integration tests for ember:
https://github.com/QuantumInformation/ember-cli-test-recorder
However I find that when I import it into an ember cli project via npm and then use the component it exposes like so in appplication.hbs:
<h2 id="title">Welcome to Ember.js</h2>
{{outlet}}
{{test-recorder currentRouteName=currentRouteName}}
I get the following at runtime:
`Uncaught Error: Assertion Failed: A helper named 'test-recorder' could not be found
Note that the component works fine in the dummy app and this addon used to work in version 1.10 of ember.
Using ember cli 0.2.5 for both addon and ember project in this case

Running ember install ember-cli-test-recorder solved this for me.
For some reason just running npm install ember-cli-test-recorder wasn't enough.

Related

Packaging an ember addon in app.js instead of vendor.js

Is there a way to bundle an ember addon in app.js instead of vendor.js. Addons seem to get packaged into vendor.js by default with no hooks to customize this. In this case both the app and the addon is authored by the same person.

How to import addon into its dummy app in Ember?

I am new to Ember and have started to build an addon. Currently, I want to build the addon and implement it in an application inside its dummy application (path: tests/dummy/app).
My addon has a component which I want available in the dummy project.
How can we include the addon inside the dummy project ?
(I am using ember version: 1.13.0)
In your addon, if you define addon/components/my-component.js and you re-export it in app/components/my-component.js, then you should be able to use it normally in the dummy app like {{my-component}}.
Note that the ember-cli component generator handles the file locations for you. e.g running $ ember g component my-component would yield the files I mentioned above.
Also, you addon project should also be generated using ember-cli using $ ember addon addon-name.

Ember build for production not building properly

I am building my ember app in production environment and deploying it on my local wamp server(apache server). But when I copy the file and open the app using url, the handlebar template application.hbs or index.hbs is not rendered.
I am building my project using
ember build --environment production --output-path dist/
But when I open the path 127.0.0.1/path-to-my-project
I get following error in console.
Uncaught Error: Could not find module `ember-data/-private\system\references\record` imported from `ember-data/-private/system/references`
vendor-192d3eef66f0205b64b4acf903f80f63.js:1
I am getting this error when building in production environment,building in development environment is working fine
I checked the documentation and sources available online, but couldn't find the cause for this error.
Please Help...
On Windows, it's mixing / and \s. See:
https://github.com/emberjs/data/pull/4205
If you're using the latest Ember, the solution is to upgrade to Ember-Cli 2.4.2 and use Ember Data 2.4.0.

How do I include an Ember addon in an addon that I'm writing?

I'm writing an addon and I want to use ember-moment as a dependency. I've installed it in the addon but, when I run my app, I get the following error:
Uncaught Error: Assertion Failed: A helper named 'moment-from-now' could not be found
I've also tried importing a helper from ember-moment:
import momentFromNow from 'ember-moment/computeds/from-now';
and that fails with:
Could not find module `ember-moment/computeds/from-now`
FYI, I'm using npm link to export the addon and import it into the project.
Place the addon (ember-moment) in the dependencies section of your addon's package.json, not the devDependencies section.

How should I import Bower dependencies from an Ember-cli addon into the consuming application?

I am successfully importing a jQuery plugin via Bower to be used in a component in an Ember-cli addon. However, this only works is because I defined a Bower dependency on this plugin in both the addon and the consuming application.
This seems like I'm doing it wrong. Why should the consuming application have to declare a dependency on a resource that should be provided with the addon?
The crux of the matter seems to be the app context when building. I can omit the Bower dependency in the consuming application if I use the following import statement in the addon's index.js file:
app.import('node_modules/my-ember-cli-addon/bower_components/jquery.stickyHooters/dist/jquery.stickyHooters.min.js');
... but this breaks when I build the addon as a stand-alone application. In that case, this path is required:
app.import('bower_components/jquery.stickyHooters/dist/jquery.stickyHooters.min.js');
How this is intended to work?
Declaring the Bower dependency in two places seems counter-intuitive
I don't know how detect the app context in the index.js of the addon
Checkout ember-cli homepage on default blueprints. It describes how you can import a bower component package upon installing your addon.