emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

canary: Can't use `{{some.yielded.component arg="foo"}}` syntax #17154

Closed buschtoens closed 5 years ago

buschtoens commented 6 years ago

Latest canary dec37c32654b2a2ccae190611e9eca72f2277f29 breaks when yielded / contextual components are directly invoked with arguments using just the path expression without the {{component}} helper:

{{#some-component as |foo|}}
  {{foo.bar}} <-- works
  {{component foo.bar someArg="test"}} <-- works
  {{foo.bar someArg="test"}} <-- breaks
{{/some-component}}
Uncaught Error: Compile Error: -assert-implicit-component-helper-argument is not a helper
    at opcode-compiler.js:284
    at Compilers.compile (opcode-compiler.js:38)
    at LazyOpcodeBuilder.OpcodeBuilder.expr (opcode-compiler.js:1573)
    at args (opcode-compiler.js:1760)
    at LazyOpcodeBuilder.OpcodeBuilder.replayable (opcode-compiler.js:2012)
    at LazyOpcodeBuilder.OpcodeBuilder.dynamicComponent (opcode-compiler.js:1758)
    at opcode-compiler.js:647
    at Inlines.compile (opcode-compiler.js:406)
    at LazyCompiler.AbstractCompiler.compileInline (opcode-compiler.js:799)
    at LazyOpcodeBuilder.StdOpcodeBuilder.compileInline (opcode-compiler.js:1260)

However, this only happens in production builds. I assume that this is because of the DEBUG flag, which will be false in production.

https://github.com/emberjs/ember.js/blob/dec37c32654b2a2ccae190611e9eca72f2277f29/packages/%40ember/-internals/glimmer/lib/helpers/-assert-implicit-component-helper-argument.ts#L7-L36

This was working fine in v3.6.0-beta.1, so it happened somewhere here: v3.6.0-beta.1...dec37c3.

buschtoens commented 6 years ago

Btw can I somehow directly influence this @glimmer/env DEBUG flag? I would prefer my CI tests to run against an environment that is as close to production as possible.

rwjblue commented 6 years ago

Can you share a reproduction repo? I'm trying to determine if the template compilation is happening in the correct environment...

buschtoens commented 6 years ago

Sure, I'll prep one later in the evening.

rwjblue commented 6 years ago

Thank you!

buschtoens commented 6 years ago

Interestingly, it seems like it isn't that simple. I can't directly reproduce the error, but I'll dig deeper in the next days.

https://github.com/buschtoens/repro-implicit-component-helper-argument

devinus commented 5 years ago

After hours of debugging, I gave up and added a helper that takes care of the problem in production. It's obvious there's some compilation issue, but I couldn't track down where.

import { warn } from '@ember/debug';
import { helper } from '@ember/component/helper';

function helperFn(params) {
  const [node, error] = params;
  warn(error);
  return node;
}

// https://github.com/emberjs/ember.js/issues/17154
Object.defineProperty(helperFn, 'name', {
  value: '-assert-implicit-component-helper-argument',
});

export default helper(helperFn);
mwasilewski commented 5 years ago

I would love to add some helpfull info there, but I can only say that I have same issue :(

chancancode commented 5 years ago

This should be fixed now! please comment if you still running into this and we can reopen!

broerse commented 5 years ago

@chancancode if now have this error on https://github.com/broerse/ember-cli-blog if I update to ember-cli 3.9.0