JSON Modules Land in Chrome 91

Dr. Axel Rauschmayer examines the JSON modules proposal, which ships in Chrome 91 and, so far, nowhere else. The syntax mirrors an ES Modules-style import, except a type is asserted at the end of the statement.

import configData from './config-data.json' assert {type: 'json'};

That compactness has been a long time coming. The path ran from the days when cross-browser quirks in XMLHttpRequest made an Ajax library a near-certain dependency, through the fetch API and its still-required boilerplate, and finally to a single line for JSON data.

Pulling in JSON should feel like a one-liner, and with this proposal it does. The dynamic URL is a welcome touch as well.