1

I'm trying to import a component:

 import('./components/'+componentName+'.svelte')
   .then(res => {src = res.default })

but compiler issues an error:

Loading module from “http://localhost...” was blocked because of a disallowed MIME type (“text/html”)

How I can allow this MIME type?

  • https://stackoverflow.com/questions/56431848/dynamically-loading-component-using-import-or-fetch – voscausa Mar 20 '20 at 14:37
  • I've saw it before, but I have the issue with MIME. – user1552003 Mar 20 '20 at 15:17
  • Have you seen the comment below the question: "I had to switch to mjs since import didn't like svelte or html served from server." – voscausa Mar 20 '20 at 15:19
  • Ah, thank you. jsm, etc - never mind that gathering already created files is such a difficult thing – user1552003 Mar 21 '20 at 15:37
  • Svelte components should be served as JS, not HTML... Are you sure the component you're importing is compiled? What's your bundler and config? – rixo Mar 24 '20 at 19:32
  • @rixo : I'm using rollup as bundler. Config as follow: output: { sourcemap: true, format: 'iife', name: 'app', file: 'public/bundle.js' }, plugins: [ svelte({ dev: !production }), resolve({ extensions: ['.svelte', '.js'] }) – user1552003 Mar 25 '20 at 20:06

0 Answers0