loader icon indicating copy to clipboard operation
loader copied to clipboard

Import non-JS code from the import declaration

Open Constellation opened this issue 10 years ago • 5 comments

I'd like to ask people working on loaders about how to import non-JS code. My main interest is, how to load WASM code :) If we already have a consensus, sorry.

  • extension based? (import "~~~~~.wasm")
  • add some protocol? (import "wasm://code")
  • content type based?
  • etc.

Constellation avatar Sep 25 '15 18:09 Constellation

@Constellation we haven't talk about this yet. I like to think that we can solve all these with the content type, hinting to the server the capabilities of the browser, and let the server to decide what version of the code to send down the wire, but that's just a personal opinion at this point. I will be happy to raise this question, and get the champions to weight in.

caridy avatar Sep 25 '15 19:09 caridy

What about on the server, in node?

briandipalma avatar Sep 25 '15 20:09 briandipalma

@briandipalma the way node handles content evaluation is based upon file type, the spec is currently compatible with Node's way of doing things

bmeck avatar Dec 01 '15 22:12 bmeck

It would be nice if (in a future version) the Loader spec had some opinion on this sort of thing. Ideally Loaders are not interested in only JavaScript but would be used to load everything in browser. This would make it possible to override the way <link>s are imported, the way fonts are loaded, etc.

matthewp avatar Dec 07 '15 17:12 matthewp

@matthewp loader allows you to "fetch" any url (it is not opinionated about that), in fact you have the hooks to do whatever you want to produce the final url. After that, it will just delegate to the underlaying fetching mechanism (http fetch) unless you have a hook for that as well. Then you have the the rest of the hooks to produce something meaningful for the user-land, which could be anything (literally anything). I don't think Loader spec will have any opinion on that regard. If you want to load some CSS content to inject it manually, you should be able to do so with a custom translate/instantiate that exports the CSS blob. If, in the other hand, you want to just insert the <link> you can use a custom fetch mechanism for css url.

I do agree that in the future, browser's default loader might implement some default behavior to facilitate

caridy avatar Dec 07 '15 19:12 caridy