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

What's this? #6

Open
chisholmd opened this issue Feb 18, 2020 · 1 comment
Open

What's this? #6

chisholmd opened this issue Feb 18, 2020 · 1 comment

Comments

@chisholmd
Copy link

Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

@andreasbm
Copy link
Owner

Thanks for opening this issue! It would be of great help if you are able to provide some code or details on how to reproduce the problem you are describing.

The error occurs when trying to import a html file as a module file. The following code reproduces it.

const routerSlot = document.querySelector("router-slot");
routerSlot.add([
  {
    path: "wrong-import",
    component: () => import("/path/to/file.html")
  },
  {
    path: "**",
    redirectTo: "wrong-import"
  }
]);

Try to change the file you are importing to a module that exports a custom element as default instead. It could look something like this:

// path/to/file.js
import { LitElement, html } from "https://unpkg.com/lit-element?module";

export default class MyPage extends LitElement {
  render () {
    return html`
      <p>Hello World</p>
    `;
  }
}

customElements.define("my-page", MyPage);

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