The `geostyler-geojson-parser` package provides an implementation of the GeoStyler data parser specification specifically for GeoJSON. It enables conversion between standard GeoJSON objects and GeoStyler's internal style representation, facilitating the styling of geographic data. The current stable version is 2.0.0, released recently after a significant architectural change that embraced ECMAScript Modules (ESM). While the project's release cadence has been irregular, v2.0.0 signifies a modernization effort for its module distribution. Key differentiators include its tight integration within the broader GeoStyler ecosystem, offering a consistent API for managing styles across various data formats, and robust handling of diverse GeoJSON structures into a unified style object. It is a fundamental component for applications that need to dynamically style GeoJSON data based on GeoStyler definitions.
npm install geostyler-geojson-parserVerified import paths — ran on the pinned version, not inferred.
This snippet demonstrates how to instantiate the `GeoJsonParser` and use its `readStyle` method to convert a GeoJSON object into a GeoStyler `Style` object, and `writeStyle` for the reverse conversion. This showcases typical usage for styling workflows.
Migrate your project to use ES modules (`import`/`export`) or configure your bundler (e.g., Webpack, Rollup) to correctly handle ESM modules. For Node.js, ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions for ESM code.
Update your import paths to directly reference the package name, e.g., `import { GeoJsonParser } from 'geostyler-geojson-parser';`. The package exports are now configured to be resolved from the root.Upgrade your Node.js environment to version 20.6.0 or newer to ensure full compatibility and prevent unexpected runtime errors.
Switch to `import` statements and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json` or using `.mjs` file extensions for files containing `import`/`export`).
Remove `/dist/GeoJsonParser` from your import path. The correct import should be `import { GeoJsonParser } from 'geostyler-geojson-parser';`.For ESM, use `import { GeoJsonParser } from 'geostyler-geojson-parser';`. If you are strictly in a CommonJS environment, check if a specific CommonJS build is provided or consider a dynamic import (`import('geostyler-geojson-parser')`). Otherwise, ensure you are correctly accessing the named export, e.g., `const GeoJsonParser = require('geostyler-geojson-parser').GeoJsonParser;` (though this might still fail if the package is truly ESM-only for its primary exports).No dependency data recorded yet.