3 ms·
import {sum} from './sum.js' with {type: 'comptime'}; is an unfortunate abuse of the `type` import attribute. `type` is the one spec-defined attribute and it's
by spankalee 1y ago
import {sum} from './sum.js' with {type: 'comptime'};
is an unfortunate abuse of the `type` import attribute. `type` is the one spec-defined attribute and it's supposed to correspond to the mime-type of the imported module, thus the two web platform supported types are "json" and "css". The mime-type of the imported file in this case is still `application/javascript`, so if this module had a type it would be "js".
It would have been better to choose a different import attribute altogether.
- alpinisme 1y agoYou’re projecting the mimetype idea from two examples but the proposal is intentionally agnostic about what type might be used for: > This proposal does not specify behavior for any particular attribute key or value. The JSON modules proposal will specify that type: "json" must be interpreted as a JSON module, and will specify common semantics for doing so. It is expected the type attribute will be leveraged to support additional module types in future TC39 proposals as well as by hosts.