thefrontside / ember-let

Create variable bindings inside your handlebars templates
MIT License
52 stars 16 forks source link

Block let not working in Addon #26

Closed yankeeinlondon closed 7 years ago

yankeeinlondon commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

Hmm. A few questions:

yankeeinlondon commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

yarigpopov commented 7 years ago

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 commented 7 years ago

@chilicoder what version of ember are you using?

yarigpopov commented 7 years ago

@Robdel12 2.9.1

rwjblue commented 7 years ago

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

yarigpopov commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

With 0.5.4 my tests work as expected

cowboyd commented 7 years ago

πŸ‘

yarigpopov commented 7 years ago

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

cowboyd commented 7 years ago

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

yankeeinlondon commented 7 years ago

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.