Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not require parent addon to include ember-cli-htmlbars #73

Merged

Conversation

gabrielcsapo
Copy link
Contributor

Summary

When adding ember-template-imports to my addon to parse template imports it required a hard dependency on ember-cli-htmlbars which resulted in the following error if I didn't add it to my project.

Cannot read properties of undefined (reading 'templateCompilerPath')


Stack Trace and Error Report: /tmp/error.dump.acbe9ab57e7c9f4a0e92b7c7d81184ae.log

Result: false

With this change it will use the templateCompiler provided by ember-source which passes tests and doesn't require me to add a hard dependency on ember-cli-htmlbars.

package.json Outdated Show resolved Hide resolved
Comment on lines +26 to +29
// Used in ember-cli-htmlbars to get the location of templateCompiler without traversing this.addons (https://github.com/ember-cli/ember-cli-htmlbars/blob/6860beed9a357d5e948abd09754e8a978fed1320/lib/ember-addon-main.js#L264)
let ember = this.project.findAddonByName('ember-source');

this.templateCompilerPath = ember.absolutePaths.templateCompiler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note here: this is public API from Ember's perspective for determining the path to the template compiler. Basically:

const emberAddon = require('ember-source');
const templateCompiler = require(emberAddon.absolutePaths.templateCompiler);

ember-addon-main.js Outdated Show resolved Hide resolved
@rwjblue rwjblue added the enhancement New feature or request label Oct 25, 2022
@rwjblue rwjblue changed the title chore: improve templateCompiler lookup to not require addon path to contain ember-cli-htmlbars Do not require parent addon to include ember-cli-htmlbars Oct 25, 2022
@rwjblue rwjblue merged commit 246b21d into ember-cli:master Oct 25, 2022
@gabrielcsapo gabrielcsapo deleted the gabrielcspao/template-compiler-logic branch October 25, 2022 18:52
@ef4
Copy link
Collaborator

ef4 commented Nov 16, 2022

I think this means we should also remove the peerDependency on ember-cli-htmlbars, yes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants