ember-polyfills / ember-angle-bracket-invocation-polyfill

MIT License
76 stars 33 forks source link

Errors on helpers with v1.1.0 #12

Closed knownasilya closed 6 years ago

knownasilya commented 6 years ago

I get this error:

vendor.js:71725 Uncaught TypeError: Cannot read property 'manager' of null
    at RuntimeResolver.runtimeResolver._lookupComponentDefinition (vendor.js:71725)
    at RuntimeResolver.lookupComponentDefinition (vendor.js:40540)
    at CompileTimeLookup.lookupComponentDefinition (vendor.js:38443)
    at refineInlineSyntax (vendor.js:40373)
    at Inlines.compile (vendor.js:19102)
    at vendor.js:18871
    at Compilers.compile (vendor.js:18738)
    at CompilableTemplateImpl.compile (vendor.js:19508)
    at OutletComponentManager.getLayout (vendor.js:37035)
    at Object.evaluate (vendor.js:23286)

The component it tries to evaluate is page-title, but that addon supports using just title which is transformed via AST. See my comment in that project https://github.com/tim-evans/ember-page-title/issues/123#issuecomment-395131883

I'm testing converting it to an explicit page-title.

knownasilya commented 6 years ago

Converting it to page-title directly still errors, see the error here: https://gloucesterma.mapgeo.alpha1.appgeo.com/dashboard/

Looks like helpers with a - are treated as components? So the {{title was a red herring since it was always converted to {{page-title any ways. Interesting thing is that it doesn't error locally when running on my machine. The only think I'm doing differently in alpha is using EMBER_ENV=alpha when building.

knownasilya commented 6 years ago

Didn't notice that 1.1.0 was out, trying that now..

Nope, still an issue.

knownasilya commented 6 years ago

Ah, alpha was already using 1.1 but local was 1.0.2, so the issue is somewhere in the update from 1.0.2 to 1.1.0.

rwjblue commented 6 years ago

Can you give me the template that I can use to test?

knownasilya commented 6 years ago

@rwjblue here's a repro https://github.com/knownasilya/ab-repro template is here https://github.com/knownasilya/ab-repro/blob/master/app/templates/application.hbs

rwjblue commented 6 years ago

Thank you very much for putting together an awesome reproduction, it made tracking things down super easy!

lifeart commented 6 years ago

Seen same issue on "ember-source": "~3.1.0" Can reproduce this problem only on prod build, ind dev build - all ok

image

rwjblue commented 6 years ago

Can you create a reproduction repo which demonstrates the problem (if so please create a new issue so we can track things down and get it fixed...)

lifeart commented 6 years ago

@rwjblue this is my code issue, sorry for bothering you :( I have dynamic component name resolution logic like

function componentName(modelName, viewType) { 
    return `meta-attribute/${modelName}/x-${viewType}`;
}

if component having this name resolved in app - all ok, if not - I see this issue.

Prod/Non-prod behavour - is my logic how to get modelName.

I have logic like let modelName = model.constructor.name but in prod, constructor class may have short name (due to minification). (meta->g)

Issue solved for me by let modelName = model.constructor.modelName .

To prevent users from tricky debugging, error stack may be little bit usable, for example it may contain error like - I'm trying to render unresolved componenent "componentName".

rwjblue commented 6 years ago

Great job tracking this down! Seems like we could write a test that emulates the issue you are seeing (so that we can track it down). I’m thinking of essentially a test like this one but using {{component ‘does-not-exist’}} and asserting empty DOM. Would you mind sending a PR with that test?

lifeart commented 6 years ago

Done, but this is not ember-angle-bracket-invocation-polyfill issue. Non prod builds users have pretty meaningful error like:

Uncaught Error: Assertion Failed: Could not find component named "does-not-exist" (no component or template with that name was found)

But, this issue may be in prod builds due to removed checks.

https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/glimmer/lib/resolver.ts#L126 https://github.com/emberjs/ember.js/blob/master/packages/@ember/-internals/glimmer/tests/integration/components/contextual-components-test.js#L745