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

Block let not working in Addon #26

Closed
yankeeinlondon opened this issue Oct 10, 2016 · 23 comments
Closed

Block let not working in Addon #26

yankeeinlondon opened this issue Oct 10, 2016 · 23 comments

Comments

@yankeeinlondon
Copy link

Version of ember-let: 0.5.2

Ember Version / Ember CLI Version:

Ember Version: 2.9.0-beta.5
Ember CLI Version: 2.9.0-beta.2

Expected Behavior

In a template in an an addon I am using:

{{#each _items as |item|}}
      {{#let (or item.id (concat id '-' (auto-id 10))) as |itemId|}}
        {{component (concat 'ui-' type '-item')
          id=itemId
          value=item
          size=size
          selected=(includes _selected itemId)
          disabled=(includes _disabled itemId)
          onClick=(action 'onClick')
          onHover=(action 'onHover')
          onFocus=(action 'onFocus')
        }}
      {{/let}}
 {{/each}}

In this same addon I have included ember-let in the "dependencies" section of package.json. This combination works fine for the dummy app of the addon but when I consume this addon I get the error: Assertion Failed: A helper named "let" could not be found. The stacktrace is meaningless but I'm not using this addon at all in the consuming app so I think the description above should adequately make this reproducible.

Ember Twiddle / Example repo / Failing test:

Not really reproducible in Twiddle due to the Addon-to-Addon-to-App nature of this defect.

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

Hmm. AST transforms aren't quite as simple as custom babel options (unfortunately). Where is the template snippet you mentioned (is it in addon/ or app/ of the addon)?

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

Also, inline {{let is so much cooler 😈 (completely unrelated to your question though).

{{#each _items as |item|}}
      {{let itemId=(or item.id (concat id '-' (auto-id 10)))}}

      {{component (concat 'ui-' type '-item')
        id=itemId
        value=item
        size=size
        selected=(includes _selected itemId)
        disabled=(includes _disabled itemId)
        onClick=(action 'onClick')
        onHover=(action 'onHover')
        onFocus=(action 'onFocus')
      }}
 {{/each}}

It literally transpiles to what you had originally (so its exactly the same scoping), but I find it much nicer...

@yankeeinlondon
Copy link
Author

yankeeinlondon commented Oct 10, 2016

It's in the /addon directory but the /app folder imports it into a local namespace.

p.s. I agree inline is cooler but unfortunately it wasn't working on an earlier version of 2.9.x so I jumped to the "working" but "not as cool" block implementation. :)

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

Hmm. A few questions:

  • Can you do npm ls ember-let from the project and let us know what it says? (I'm worried the project might have an older version or something causing the one in 0.5.2 provided by the addon to not be used or something...)
  • Where are you consuming the addon (another addon or a project directly)?
  • Can you tell us if this block is getting executed (likely via breakpoint in vendor.js)?

@yankeeinlondon
Copy link
Author

image

image

The code section you're highlighting does not get executed when running the dummy app for ui-list addon but that's because it's only running Ember 2.7.3. The consuming application -- which is running 2.9.0-beta.5 -- doesn't seem to have any reference to ember-let that I can see:

2016-10-10_16-23-51

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

Hmm. I'm slightly confused.

In the description of the issue, you mentioned:

In this same addon I have included ember-let in the "dependencies" section of package.json.

But in the screenshot above of ui-list's dependencies I don't see ember-let. Are you certain you didn't add it to devDependencies? Can you confirm?

@yankeeinlondon
Copy link
Author

well i'm confused too ... if you look at the image at the top that is a direct cut-and-paste from the package.json of ui-list and indeed the dummy app does have it as part of the vendor tree. But I'd expect it to be available to the containing App as well under vendor yet it is not.

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

@ksnyde - unless I'm just completely missing it, I do not see ember-let in the dependencies listed in this image. I suspect it is in devDependencies of that addon, which would make it available to the addons dummy app but not consuming apps....

@yankeeinlondon
Copy link
Author

@rwjblue let me jump back to that branch and re-check ... I swear it was but I swear a lot (and not all of it's healthy). 😛

@yankeeinlondon
Copy link
Author

So the partially-good news is that I'm not completely hallucinating ...

image

results in the containing App complaining:

2016-10-10_17-23-05

Of course the bad news is it still looks like an error.

@yankeeinlondon
Copy link
Author

Now that said, it was easy enough for me to work around this in my addon (and eliminate a dependency in the process). I kind of need to get through today before a big context shift tomorrow. I had thought that this situation I'm running into would be pretty reproducible when I entered it but if you're not finding it so I'd be happy to close this.

@rwjblue
Copy link
Contributor

rwjblue commented Oct 10, 2016

Hehe, I haven't tried it myself yet. I'm just armchair debugging at this point. 😺

@yarigpopov
Copy link

I have similar error in some of my tests
I have ember-let 0.4.0 in my devDependencies.
In my acceptance tests the helper initializes
screen shot 2016-12-09 at 12 40 07
screen shot 2016-12-09 at 12 40 24
and in inegration test of the component that uses let inside initializer doesn't executes

@Robdel12
Copy link
Collaborator

Robdel12 commented Dec 9, 2016

@chilicoder what version of ember are you using?

@yarigpopov
Copy link

@Robdel12 2.9.1

@rwjblue
Copy link
Contributor

rwjblue commented Dec 9, 2016

Screenshot seems to indicate an older version. We don't use an initializer any more.

@yarigpopov
Copy link

its "ember-let 0.4.0"

from ember-sparkles. only with this version I could manage to run them on v2.9.1

Now I'm trying to make them run in 2.10.. but no luck)

Anyways.. I just shared a symptom. maybe will help to find the cause.

@Robdel12
Copy link
Collaborator

Robdel12 commented Dec 9, 2016

Would it be possible to upgrade ember-sparkles? They're using the latest released version of ember-let: https://github.com/LocusEnergy/ember-sparkles/blob/master/package.json#L46

@yarigpopov
Copy link

With 0.5.4 my tests work as expected

@cowboyd
Copy link
Member

cowboyd commented Dec 12, 2016

👍

@cowboyd cowboyd closed this as completed Dec 12, 2016
@yarigpopov
Copy link

@cowboyd but i'm not the topicstarter. maybe we should wait until his report)

@cowboyd
Copy link
Member

cowboyd commented Dec 12, 2016

Excellent point. I'll re-open if @ksnyde is still having trouble.

@yankeeinlondon
Copy link
Author

Ha! Forgot that I was the one who openned this. I had been watching the comments come in and was just happy to hear this seems to have been addressed. My focus is elsewhere at the moment but if for any reason I run back into this I'll give a shout out.

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

No branches or pull requests

5 participants