From 5e7d57ea2c28ec07730aa4504b5c3902d513d978 Mon Sep 17 00:00:00 2001 From: Josh Lee Date: Mon, 20 May 2024 11:39:18 -0400 Subject: [PATCH 1/2] use `with` for json modules instead of `assert` See https://github.com/maplibre/maplibre-gl-js/pull/4092 --- build/generate-docs.ts | 2 +- build/generate-style-spec.ts | 2 +- src/expression/expression.test.ts | 2 +- src/index.ts | 2 +- src/migrate.test.ts | 2 +- src/reference/latest.ts | 2 +- src/validate/validate_raster_dem_source.test.ts | 2 +- src/validate/validate_raster_dem_source.ts | 2 +- src/validate/validate_sky.test.ts | 2 +- src/validate/validate_sky.ts | 2 +- src/validate/validate_terrain.test.ts | 2 +- src/validate/validate_terrain.ts | 2 +- src/visit.ts | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/generate-docs.ts b/build/generate-docs.ts index b002d1395..b6ccacc9d 100644 --- a/build/generate-docs.ts +++ b/build/generate-docs.ts @@ -1,4 +1,4 @@ -import v8 from '../src/reference/v8.json' assert { type: 'json' }; +import v8 from '../src/reference/v8.json' with { type: 'json' }; import fs from 'fs'; import jsonStringify from 'json-stringify-pretty-compact'; diff --git a/build/generate-style-spec.ts b/build/generate-style-spec.ts index b9a5258a6..a891dd459 100644 --- a/build/generate-style-spec.ts +++ b/build/generate-style-spec.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as properties from '../src/util/properties'; -import spec from '../src/reference/v8.json' assert {type: 'json'}; +import spec from '../src/reference/v8.json' with {type: 'json'}; function unionType(values) { if (Array.isArray(values)) { diff --git a/src/expression/expression.test.ts b/src/expression/expression.test.ts index b8b9f77bf..d45d9bbc7 100644 --- a/src/expression/expression.test.ts +++ b/src/expression/expression.test.ts @@ -1,6 +1,6 @@ import {createPropertyExpression, Feature, GlobalProperties, StylePropertyExpression} from '../expression'; import definitions from './definitions'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; import {createExpression, ICanonicalTileID, StyleExpression, StylePropertySpecification} from '..'; import ParsingError from './parsing_error'; import {VariableAnchorOffsetCollection} from './values'; diff --git a/src/index.ts b/src/index.ts index bbd11d7a5..744199d2b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -69,7 +69,7 @@ export type StylePropertySpecification = { default?: VariableAnchorOffsetCollectionSpecification; }; -import v8Spec from './reference/v8.json' assert {type: 'json'}; +import v8Spec from './reference/v8.json' with {type: 'json'}; const v8 = v8Spec as any; import latest from './reference/latest'; import derefLayers from './deref'; diff --git a/src/migrate.test.ts b/src/migrate.test.ts index 07c0b9a68..fe5b6522a 100644 --- a/src/migrate.test.ts +++ b/src/migrate.test.ts @@ -1,6 +1,6 @@ import migrate from './migrate'; import * as spec from '.'; -import v8 from './reference/v8.json' assert {type: 'json'}; +import v8 from './reference/v8.json' with {type: 'json'}; import validate from './validate_style'; describe('migrate', () => { diff --git a/src/reference/latest.ts b/src/reference/latest.ts index 8a97acf73..bfd17bd5d 100644 --- a/src/reference/latest.ts +++ b/src/reference/latest.ts @@ -1,3 +1,3 @@ -import spec from './v8.json' assert { type: 'json' }; +import spec from './v8.json' with { type: 'json' }; export default spec as any; diff --git a/src/validate/validate_raster_dem_source.test.ts b/src/validate/validate_raster_dem_source.test.ts index 1f86191b8..aeb8c4415 100644 --- a/src/validate/validate_raster_dem_source.test.ts +++ b/src/validate/validate_raster_dem_source.test.ts @@ -1,5 +1,5 @@ import validateSpec from './validate'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; import validateRasterDEMSource from './validate_raster_dem_source'; import {RasterDEMSourceSpecification} from '../types.g'; diff --git a/src/validate/validate_raster_dem_source.ts b/src/validate/validate_raster_dem_source.ts index 6b1b8a3f6..b0679f1f7 100644 --- a/src/validate/validate_raster_dem_source.ts +++ b/src/validate/validate_raster_dem_source.ts @@ -1,7 +1,7 @@ import ValidationError from '../error/validation_error'; import getType from '../util/get_type'; import type {RasterDEMSourceSpecification, StyleSpecification} from '../types.g'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; import {unbundle} from '../util/unbundle_jsonlint'; interface ValidateRasterDENSourceOptions { diff --git a/src/validate/validate_sky.test.ts b/src/validate/validate_sky.test.ts index a2af8343c..d3407e10a 100644 --- a/src/validate/validate_sky.test.ts +++ b/src/validate/validate_sky.test.ts @@ -1,6 +1,6 @@ import validateSky from './validate_sky'; import validateSpec from './validate'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; import {SkySpecification} from '../types.g'; describe('Validate sky', () => { diff --git a/src/validate/validate_sky.ts b/src/validate/validate_sky.ts index 774218873..f6e7bc555 100644 --- a/src/validate/validate_sky.ts +++ b/src/validate/validate_sky.ts @@ -1,6 +1,6 @@ import ValidationError from '../error/validation_error'; import getType from '../util/get_type'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; import {SkySpecification, StyleSpecification} from '../types.g'; interface ValidateSkyOptions { diff --git a/src/validate/validate_terrain.test.ts b/src/validate/validate_terrain.test.ts index a92f8a704..ba204e2bd 100644 --- a/src/validate/validate_terrain.test.ts +++ b/src/validate/validate_terrain.test.ts @@ -1,6 +1,6 @@ import validateSpec from './validate'; import validateTerrain from './validate_terrain'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; describe('Validate Terrain', () => { test('Should return error in case terrain is not an object', () => { diff --git a/src/validate/validate_terrain.ts b/src/validate/validate_terrain.ts index f5c608715..ad6a5c91b 100644 --- a/src/validate/validate_terrain.ts +++ b/src/validate/validate_terrain.ts @@ -1,7 +1,7 @@ import ValidationError from '../error/validation_error'; import getType from '../util/get_type'; import type {StyleSpecification, TerrainSpecification} from '../types.g'; -import v8 from '../reference/v8.json' assert {type: 'json'}; +import v8 from '../reference/v8.json' with {type: 'json'}; export default function validateTerrain( options: {value: TerrainSpecification; styleSpec: typeof v8; style: StyleSpecification; validateSpec: Function} diff --git a/src/visit.ts b/src/visit.ts index 6c1ae3292..5ab60c026 100644 --- a/src/visit.ts +++ b/src/visit.ts @@ -1,4 +1,4 @@ -import Reference from './reference/v8.json' assert {type: 'json'}; +import Reference from './reference/v8.json' with {type: 'json'}; import type {StylePropertySpecification} from '.'; import type { StyleSpecification, From d45f57b69615e40fa733b966fe87fe56f98dc619 Mon Sep 17 00:00:00 2001 From: Josh Lee Date: Mon, 20 May 2024 12:40:22 -0400 Subject: [PATCH 2/2] Add a changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fb5d66b5..12b32ac43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - _...Add new stuff here..._ ### 🐞 Bug fixes -- _...Add new stuff here..._ +- Change `assert` to `with` in JSON modules. Requires Node.js 18.20.0 or later, and supports Node.js 22.0.0 or later - [#675](https://github.com/maplibre/maplibre-style-spec/pull/675) ## 20.2.0