demo · v139

JSON Module Import

JSON module imports (import x from "./d.json" with {type: "json"}) only succeed if the server's Content-Type is a JSON MIME type. Pre-v139 Chromium accepted only the obvious ones; v139 follows mimesniff and accepts anything ending in +json — which is what custom-typed APIs send. Try a MIME string and see whether each browser version would accept it.

classifier result

try a sample

the rule

// mimesniff.spec.whatwg.org § JSON MIME type
// A JSON MIME type is any MIME type whose:
//   subtype is "json"   — application/json, text/json
//   OR
//   subtype ends in "+json" — application/feed+json, image/svg+json, etc.

function isJsonMime(ct) {
  const [type, subtype] = ct.toLowerCase().split(";")[0].split("/");
  return subtype === "json" || subtype.endsWith("+json");
}

see also