Open sanjarcode opened 10 months ago
Related:
import countryTable from "./data/countries.json" with { type: "json" };
A more specific proposal of the above is in place to solve this. Will be released in 2024 hopefully. Current support is almost zero. See
Syntax is the same, with
require
works.import
works too, but might needassert JSON
.fetch('./path-to-file')
is simplest way that works for all browsers. FYI,import
(with assert JSON) works on Chrome, but fails on Firefox or Safari.import data from "data.json"
works fine.On web, prefer using this wrapper