denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.58k stars 650 forks source link

Importing modules using import maps in the client #2193

Open dkolba opened 10 months ago

dkolba commented 10 months ago

Is it supported to use <script type="importmap"> within a component during development?

I always get An import map is added after module script load was triggered. in the browser console while running in dev mode. Import maps seem to expect to be loaded before everything else on the page and fresh_dev_client.js is always the very first script being loaded.

        <script
          type="importmap"
          dangerouslySetInnerHTML={{
            __html: '{ "imports": { "a": "/a.js"} }',
          }}
        />
        <script
          type="module"
          dangerouslySetInnerHTML={{
            __html: `
              import { a } from "a";
            `,
          }}
        />