question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non dynamic component in template considered unsafe unless called with <this.component />

See original GitHub issue

I’m trying to get an ember 3.26 app to work with embroider with

staticAddonTestSupportTrees: true,
staticAddonTrees: true,
staticHelpers: true,
staticComponents: true,

When building the app I get errors for all template files that contain call normal non-dynamic components like this:

ERROR in ./templates/login.hbs
Module Error (from ../../../../../../../../Users/user/ember-web/node_modules/thread-loader/dist/cjs.js):
Unsafe dynamic component: cannot statically analyze this expression in templates/login.hbs
 @ ./assets/ember-web.js 1481:13-44

The template in question looks like this:

{{page-title "Login"}}

{{#if this.showBranding}}
  <div class="login split">
    <div class="split__page">
      <LoginForm class="bright-form bright" />
    </div>
  </div>
{{else}}
  <div class="login centered">
    <div class="centered__page">
      <LoginForm class="bright-form bright" />
    </div>
  </div>
{{/if}}

But the above Unsafe dynamic component error does not happen if I call the component with this. in front of the component name.

{{page-title "Login"}}

{{#if this.showBranding}}
  <div class="login split">
    <div class="split__page">
      <this.LoginForm class="bright-form bright" />
    </div>
  </div>
{{else}}
  <div class="login centered">
    <div class="centered__page">
      <this.LoginForm class="bright-form bright" />
    </div>
  </div>
{{/if}}

Invocation with <this.component/> doesn’t render anything. Is this a bug or am I doing something wrong? Thanks))

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ef4commented, Feb 9, 2022

Yeah it’s already possible to use webpack-dev-server which provides hot reloading by the default. But it requires a bunch of mucking around. Work is underway to package that up and document it.

1reaction
x8BitRaincommented, Feb 9, 2022

I was using ember-ast-hot-reload at the same time, removing the package fixed the issue, thanks))

Read more comments on GitHub >

github_iconTop Results From Across the Web

Here is what you need to know about dynamic components in ...
Dynamic template evaluation is of course not the main culprit of AngularJS being viewed as a slow framework, but it certainly contributed to...
Read more >
Vue dynamic component template not working for promise
However, the created hook seems to call loader() twice (the second call is unnecessary). That could be simplified:
Read more >
MTobisch/ngx-dynamic-hooks - GitHub
Automatically insert live Angular components into dynamic strings (based on their selector or any pattern of your choice) and render the result in...
Read more >
Component - Angular
Decorator that marks a class as an Angular component and provides configuration metadata ... If provided, do not supply a template file using...
Read more >
Vue dynamic component should have a ... - Rule | DeepScan
If a dynamic component does not have an is attribute, Vue considers it as an unknown custom element. If a dynamic component has...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found