Skip to content

Commit

Permalink
Use JSON import attribute (#694)
Browse files Browse the repository at this point in the history
See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with

This requires bumping our target to ES2022 from ES2020. caniuse.com
shows that the adoption is roughly the same for the two targets.
  • Loading branch information
Eric-Arellano authored Jan 1, 2025
1 parent e992b88 commit b663015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/js/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ export function processRawCoreEntry(
export default async function readData(options: {
includeMultipleReforms: boolean;
}): Promise<Record<PlaceId, ProcessedCoreEntry>> {
const rawData = (await import("../../data/core.json")) as unknown as Record<
PlaceId,
RawCoreEntry
>;
const rawData = (await import("../../data/core.json", {
with: { type: "json" },
})) as unknown as Record<PlaceId, RawCoreEntry>;
return Object.fromEntries(
Object.entries(rawData).map(([placeId, entry]) => [
placeId,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"noEmit": true,
"allowImportingTsExtensions": true,
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
"target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "es2022" /* Specify what module code is generated. */,
"target": "ES2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "ESNext" /* Specify what module code is generated. */,
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
"resolveJsonModule": true /* Enable importing .json files. */,
"allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
Expand Down

0 comments on commit b663015

Please sign in to comment.