Ember app use addon installed as transitive dependency


Ember app use addon installed as transitive dependency



Can an Ember app use an addon that is installed as a transitive dependency? I have a local Ember addon that lists ember-angle-bracket-invocation-polyfill as a dependency in package.json. When I install the addon into an Ember app using ember install path/to/addon, I'm unable to use ember-angle-bracket-invocation-polyfill. Any help is appreciated!


ember-angle-bracket-invocation-polyfill


dependency


package.json


ember install path/to/addon


ember-angle-bracket-invocation-polyfill




1 Answer
1



An addon could add dependencies as part of it's installation process. This is usually done in the default blueprint. The default blueprint is a blueprint having the exact same name as the addon. It's automatically run after addon installation by ember-cli. This is the main reason why addons should be installed by ember install <addon-name> and not only by adding it as a dependency using npm or yarn.


ember install <addon-name>



Ember-cli provides different methods to add a dependency depending on it's type. As ember-angle-bracket-invocation-polyfill is an ember addon, addAddonsToProject() should be used for your case. It expects an object having a array with addon names under packages key.


ember-angle-bracket-invocation-polyfill


addAddonsToProject()


packages



For your example the blueprint would look like:


// blueprints/your-addon-name/index.js
module.exports = {
normalizeEntityName() {}, // no-op since we're just adding dependencies

afterInstall() {
// Add addons to package.json and run defaultBlueprint
return this.addAddonsToProject({
// a packages array defines the addons to install
packages: [
// name is the addon name, and target (optional) is the version
{name: 'ember-angle-bracket-invocation-polyfill'}
]
});
}
};



More information Working with dependencies chapter of ember-cli docs.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined

Opening a url is failing in Swift