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

top-level-await causes component loading to break #1678

Open
Tracked by #1773
NullVoxPopuli opened this issue Nov 22, 2023 · 1 comment
Open
Tracked by #1773

top-level-await causes component loading to break #1678

NullVoxPopuli opened this issue Nov 22, 2023 · 1 comment

Comments

@NullVoxPopuli
Copy link
Collaborator

NullVoxPopuli commented Nov 22, 2023

Error occurred:

- While rendering:
  -top-level
    application

[runtime.js:4857](http://localhost:4200/assets/@glimmer/runtime.js)

Uncaught Error: Attempted to load a component, but there wasn't a component manager associated with the definition. The definition was: Promise
    getInternalComponentManager manager.js:425
    lookupComponent Ember

Repro: https://github.com/NullVoxPopuli/embroider-repro-top-level-await

application.hbs

{{page-title "TopLevelAwait"}}


<Demo />

{{outlet}}

The in-app component:

// app/components/demo.js
import Component from '@glimmer/component';

// could be any library tho
import { two } from './top-level-await';

export default class Demo extends Component {
  two = two;
}
{{this.two}}

{{yield}}
// app/components/top-level-await.js
export const two = 2;

// This could be anything, in a library, etc.
// top-level await is a spec-feature
await new Promise((resolve) => resolve());
@ef4
Copy link
Contributor

ef4 commented Nov 22, 2023

This needs importSyncImplmementation = 'eager' which in turn really needs strict es modules if we want that to work across the ecosystem.

If you patch the repro to use eager, you hit other problems, like

  • ember-fetch contains broken code that was lazy before but becomes eager and crashes
  • when using eager mode, embroider seems to treat require() in ember-resolver as a build-time require when it should still be a run-time require. This seems like a possible legit embroider bug.

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

2 participants