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

Import doesn't seem to work at all #27

Open
dave-kennedy opened this issue Nov 6, 2024 · 1 comment · May be fixed by #28
Open

Import doesn't seem to work at all #27

dave-kennedy opened this issue Nov 6, 2024 · 1 comment · May be fixed by #28

Comments

@dave-kennedy
Copy link

dave-kennedy commented Nov 6, 2024

This should work, right?

<is-land on:visible import="/js/my-component.js">
  <my-component>
    Hello, World!
  </my-component>
</is-land>
export default class MyComponent extends HTMLElement {
  constructor() {
    super();
    console.log('MyComponent.constructor');
  }

  connectedCallback() {
    console.log('MyComponent.connectedCallback');
    const div = document.createElement('div');
    div.innerHTML = 'Test!';
    this.append(div);
  }
}

customElements.define('my-component', MyComponent);

It seems the component is never imported. No errors either. Just... nothing happens.

The only occurrences of "import" in the source is here:

    let imports = await Promise.all(parents.map(p => p.wait()));
    // return innermost module import
    if(imports.length) {
      return imports[0];
    }
@dave-kennedy
Copy link
Author

Grr... I figured it out. I need to include is-land-autoinit.js on the page in addition to is-land.js. The docs indicate this is only needed for certain frameworks. I'll submit a PR to clarify when I get a chance.

@dave-kennedy dave-kennedy linked a pull request Nov 7, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant