Static Hosts Can Silently Break JSON Import Attributes in Browsers
A developer found that importing a JSON file with the with { type: 'json' } attribute worked locally but threw an error after deployment, even though the code was unchanged. The feature lets the module loader treat a JSON file as data rather than code, and it has shipped in Chrome, Firefox, and Safari, though Baseline does not yet count it as widely available. The article warns that the older assert syntax is now non-standard and that named imports from JSON modules are not valid, since JSON offers only a default export. The real cause of the failure, the article explains, lies in how the hosting server responds to the request, particularly the content-type header it sends back.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in