Loading topic
import and export, JSON syntax and JSON.parse, and how to run JavaScript in a browser or Node.js. Here you will build a working model of what the engine creates when a JSON file takes part in a module graph. Later chapters cover the attribute syntax and 2 min readimport and export statements and JSON syntax. It covers the grammar of import attributes: where the clause goes, what it may contain, and which forms the parser rejects.2 min readwith { type: "json" } syntax from the previous chapter. The question here is why JavaScript makes you write the attribute at all, when a file ending in .json already looks like it says what it i3 min readimport and export syntax and how the with { type: "json" } clause works in a static import. It covers what a JSON module exports and why some import forms that look reasonable fail.2 min readimport ... with { type: "json" } and that a JSON module exposes its parsed value only as the default export. You should also be comfortable with Promises and async/await.2 min readimport declarations work and how a JSON module exposes its parsed value as the default export. It uses the config.json file from earlier chapters:2 min readwith { type: "json" } and that a JSON module has only a default export. Here you will expose JSON data through a plain JavaScript module, so other code can import it without repeating attributes.2 min readwith { type: "json" } syntax and dynamic import() from earlier chapters, and that you can run code in Node.js or a browser.2 min readwith { type: "json" } clause works on static and dynamic imports. You will learn to recognize the older assert syntax, understand why it was replaced, and convert a codebase to the current form.2 min readwith { type: "json" } syntax, the default-export-only rule, and the difference between ES modules and CommonJS in Node.js. It covers how Node.js decides a file is JSON, which versions support which syntax, and how JSON imports relate to require().2 min readasync/await and JSON.parse. JSON modules are one way to load JSON data. In many cases a plain3 min readtsconfig.json, and have run at least one bundler such as Vite, webpack, or esbuild. It also assumes you have read the earlier chapters on the with { type: "json" } clause and the default-export-only rule.2 min readwith { type: "json" } syntax, why the type attribute exists, and how a JSON module exposes its data as a default export. Here you will see that the same mechanism is built to support more than JSON, and that support for each extra type depends on the hos2 min read