Upgrade Guide
Upgrading to v4.3
Minor Breaking Changes
loaders.gl/core- Improved loader type inference:load(),parse(), etc now infer correct option and return types even when an array of loaders is passed. This can lead to previously undetected type errors now being reported and breaking your build, requiring you to fix the errors.loaders.gl/core- internal tile index inSourceclasses has changed fromtileIndex.zoomtotileIndex.z. Should not impact most applications.
Deprecations
loaders.gl/core-registerLoaders()is deprecated. Loader registration erases types and it is preferable that applications manage loader registration themselves if needed.
Recommendations
- For improved type checks, make sure you do not erase types of arrays of Loader objects: Replace
const loaders: Loader[] = [CSVLoader, JSONLoader];withconst loaders = [CSVLoader, JSONLoader] as const satisfies Loader[];orconst loaders: Loader[] = [CSVLoader, JSONLoader] as const;.
Upgrading to v4.2
@loaders.gl/mvt
Deprecations
loaders.gl/mvt- options.gis.formatis deprecated. Useoptions.mvt.shape` instead.
Upgrading to v4.2
Recommendations
- For improved type checks, it is now possible to add
dataTypeandbatchTypefields to any custom loader objects.
Upgrading to v4.1
Breaking Changes
@loaders.gl/wkt-WKBLoader/TWKBLoader/HexWKBLoader- The defaultshapeis nowgeojson-geometryrather thanbinary-geometry. If you were relying onbinary-geometry, just add add ashape: 'binary-geometry'option, as inload(..., WKBLoader, {wkb: {shape: 'binary-geometry}}).
Deprecations
@loaders.gl/wkt- Thegeometryshape is deprecated, and now calledgeojson-geometry.
Upgrading to v4.0
Node.js v18+
When using loaders.gl on Node.js your application should import the @loaders.gl/polyfills module before calling any loaders.gl functions.
Typed Loaders
Loaders now return typed data. This addition of types into previously untyped code can generated type errors in existing applications. These type errors can just be a result of the typescript compiler making sure your application knows what it is doing, but they can also mean that you have been making wrong or unsafe assumptions about what is being returned from the loader in question. We recommend you review the errors rather than just defeat them with comments as some may be valid and should be fixed in the application.
Shape of Returned Data
Some loaders can return multiple formats, often controlled with the loader options shape parameter. Note that many returned data types now also include a shape field which contain a string value the specifies the shape of the data. This goal is that this should result in a "discriminated union". Switching on the returnedData.shape field will then allow typescript to correctly determine which type of data was returned.
Apache Arrow JS
loaders.gl now imports apache-arrow v13 which is a major upgrade but Apache Arrow JS v9 introduces breaking change (compared with Apache Arrow v4 which is used by loaders.gl v3.x_).
If your application is using the Apache Arrow API directly to work with Apache Arrow tables returned from loaders.gl, note that the Apache Arrow v9 API contains a number of breaking changes.
On the upside, the new Apache Arrow API is more modular and "tree shakeable" (meaning that only the Apache Arrow functionality your application is actually using is included in your application bundle).
Since Apache Arrow JS does yet not come with upgrade notes, you can refer to the loaders.gl Arrow documentation.
Table Schemas
If you are referencing table schemas returned by loaders, they will no longer be Apache Arrow schemas, but instead equivalent "serialized" lower-overhead loaders.gl schemas. You can recover Arrow schemas as follows
import {deserializeArrowSchema} from '@loaders.gl/arrow';
const table = load(url, ParquetLoader);
const arrowSchema = deserializeArrowSchema(table.schema);
Polyfills
If you were relying on @loaders.gl/polyfills module to install a global fetch()
function under Node.js that supported fetching from local files.
loaders.gl v4 uses the built-in fetch in Node.js v18+ (which doesn't support fetching from local files), so fetch from local files, you now need to use fetchFile() instead.
import {fetchFile} from '@loaders.gl/core';
const response = await fetchFile('/path/to/local/file');
...
Note that fetchFile is called by all core load() functions unless the fetch function is overridden through
loader options.
Details: The expectation is that loaders.gl v4.0+ will be used with Node.js version 18 and higher,
which now provide a built-in browser-compatible fetch() function by default.
This new built-in Node.js fetch function does not support reading from the file system,
and loaders.gl v4.0 aligns with this practice.
Loader module changes, in order of estimated impact to applications:
@loaders.gl/images
loadImage()has moved toloaders.gl/textures.
@loaders.gl/gltf
GLTFLoader- no longer post processes data. Applications need to import and call thepostProcessGLTFfunction after calling the loader to get the same result.
@loaders.gl/crypto
- All hashes now require an encoding parameter. To get previous behavior, just specify
.hash...(..., 'base64').
@loaders.gl/arrow
- Batches now contain a Table with a single
RecordBatch(instead of just aRecordBatch).
@loaders.gl/geopackage
options.geopackage.shapereplaces all other format specification optiojs, such asoptions.gis.formatoptions.geopackage.shape: 'tables', The default data format returned is nowtableswhich returns the typeTables<ObjectRowTable>, where thedataof each table is an array of GeoJSON features. (TheTablesandObjectRowTabletypes are exported from@loaders.gl/schema.) You can useoptions.geopackage.shape: 'geojson-table'.
@loaders.gl/klm
options.kml.shapereplaces all other mechanisms for specifying format of returned data (.formatetc), and aligns with thegeojson-tabletable shape as this is compatible with a GeoJSONFeatureCollection.options.gpx.shapesame changes asoptions.shape.kmloptions.tcx.shapesame changes asoptions.shape.kml
Upgrading to v3.4
@loaders.gl/wms
This module is still marked as experimental and had some breaking changes.
WMSServiceclass- The
srsparameters has been renamed tocrsin alignment with the most recent WMS 1.3.0 conventions.
- The
- ``WMSCapabilities
type (returned byWMSServiceandWMSCapabilitiesLoader`)WMSCapabilities.layeris nowWMSCapabilities.layersWMSCapabilities.boundingBoxis nowWMSCapabilities.geographicBoundingBox(in generic lng/lats) andWMSCapabilities.boundingBoxes(array of bounding boxes in supported projections)
Upgrading to v3.2
@loaders.gl/geopackage
- The default data format returned is now
options.gis.format: 'tables', which returns the typeTables<ObjectRowTable>, where thedataof each table is an array of GeoJSON features. (TheTablesandObjectRowTabletypes are exported from@loaders.gl/schema.) You can useoptions.gis.format: 'geojson'to return an object mapping table names to an array of GeoJSON features.
Upgrading to v3.0
Platform Support Updates
- Node.js 10 is no longer supported (LTS maintenance of Node.js 10 ended in May 2021).
- The
moduleentry point in the published module is no longer transpiled to ES5 as modern JavaScript is supported now support recent evergreen browsers resulting bundle size reduction and better performance. Themainentry point is still fully transpiled toes5, you can select this entry point using e.g. themainFieldoption in webpack.
Worker Concurrency
Default number of worker threads for each loader has been reduced from 5 to 3 on non-mobile devices and to 1 on mobile devices to reduce memory use. Generally, increasing the number of workers has diminishing returns.
@loaders.gl/core
- Passing
fetchoptions (such asheaders) toload()andparse()etc. should now be done via theoptions.fetchoptions object (e.g.options.fetch.headers). Specifyingfetchoptions on the root options object was deprecated in v2.3 and is no longer supported in v3.0.
@loaders.gl/compression
- The
TransformAPI in v2.3 has been replaced withCompressionclasses that handle both compression and decompression. Please refer to the documentation.
@loaders.gl/crypto
- The
TransformAPI in v2.3 has been replaced withHashclasses that handle both compression and decompression. Please refer to the documentation.
@loaders.gl/csv
- The format of parsed data (i.e. whether table rows are objects or arrays) is now controlled by
options.csv.shapeinstead of being dynamically selected based on whether the CSV file has a header row. The defaultshapeis nowobject-row-table. Default column names are generated if no header row is present. This is a breaking change when loading CSV files without header rows. - Duplicate column names will have a counter suffix added to ensure that they are unique. In rare cases this could be a breaking change.
@loaders.gl/gltf
GLTFScenegraphis updated to provide modifying capabilities. Signatures of some methods have been changed to use named parameters (rather than positional parameters).- The deprecated
GLBBuilderclass andencodeGLTFSyncfunctions have now been removed.
@loaders.gl/basis
- Module has been moved to
@loaders.gl/textures.
@loaders.gl/images
- The texture API
loadImage,loadImageArray,loadImageCubehas been moved to the new@loaders.gl/texturesmodule, and have been renamed toloadImageTexture*. - The binary image API has been consolidated in a single function
getBinaryImageMetadata(): - A number of previously deprecated exports have been removed:
| Export | Replacement |
|---|---|
isBinaryImage(arrayBuffer) | Boolean(getBinaryImageMetadata(arrayBuffer)) |
getBinaryImageMIMEType(arrayBuffer) | getBinaryImageMetadata(arrayBuffer)?.mimeType |
getBinaryImageSize(arrayBuffer) | getBinaryImageMetadata(arrayBuffer)?.{width, height} |
HTMLImageLoader | Use ImageLoader with options {image: type: 'image'} |
getDefaultImageType() | N/A |
getSupportedImageType(imageType?) NA |
@loaders.gl/kml
- The
KMLLoader,GPXLoader, andTCXLoadernow require a value foroptions.gis.format. Previously, the lack of a value would return data in "raw" format, i.e. not normalized to GeoJSON. To return GeoJSON-formatted data, useoptions.gis.format: 'geojson'. Other options arebinaryandraw. - The
kml.normalizeoption has been deprecated. Whenoptions.gis.formatisgeojson, coordinates will always be in longitude-latitude ordering.
@loaders.gl/loader-utils
createWorker()now creates a generic worker. For loader workers use the newcreateLoaderWorker()function.
@loaders.gl/tiles-3d-loader
- Added
featureIdsattribute to i3s tile content. It is an array of feature ids which specify which feature each vertex belongs to. Can be used for picking functionality.
@loaders.gl/tables
- The (undocumented)
@loaders.gl/tablesmodule has been renamed to@loaders.gl/schema.
Upgrading to v2.3
@loaders.gl/core:
selectLoader()is now async and returns aPromisethat resolves to a loader.selectLoaderSync()is available for situations when calling an async function is inconvenient.- Passing
fetchoptions toload()andparse()etc. should now be done via theoptions.fetchsub-options object. fetch options on the root object are now deprecated.
@loaders.gl/kml:
- The
KMLAsGeoJsonLoaderhas been removed, useKMLLoader, withoptions.gis.format: 'geojson'.
Upgrading to v2.2
@loaders.gl/core
selectLoaderis no longer experimental. If you were using the experimental export, replace_selectLoaderwithselectLoader. Also note that argument order has changed and now aligns withloadandparseparseInBatchesSynchas been removed, all batched parsing is now performed asynchronously.
Some iterator utilities that are mostly used internally have been changed.
| Function | Replacement / Status |
|---|---|
makeChunkIterator | combined into makeIterator |
makeStreamIterator | combined into makeIterator |
textDecoderAsyncIterator | makeTextDecoderIterator |
lineAsyncIterator | makeLineIterator |
numberedLineAsyncIterator | makeNumberedLineIterator |
getStreamIterator | Deprecated in 2.1, now removed in 2.2 |
contatenateAsyncIterator | Deprecated in 2.1, now removed in 2.2 |
@loaders.gl/csv
- Header auto-detection now requires
options.csv.headerto be set to'auto'instead ofundefined.'auto'is the new default value for this option, so this change is unlikely to affect applications.
@loaders.gl/json
- The experimental
json._rootObjectBatchesoption is now deprecated. Use the top-levelmetadata: trueoption instead. Note that thebatchTypenames have also changed, see the JSONLoader docs for details.
@loaders.gl/ply
The experimental streaming _PLYStreamingLoader has been removed. Use the non-streaming PLYLoader instead.
@loaders.gl/images
The new function getBinaryImageMetadata() replaces isBinaryImage(), getBinaryImageSize() and getBinaryImageMIMEType(). The old functions are now deprecated, but still available.
Upgrading to v2.1
@loaders.gl/core
Some iterator helper functions have been renamed, the old naming is now deprecated.
| Old Name | New Name |
|---|---|
getStreamIterator | makeStreamIterator |
contatenateAsyncIterator | concatenateChunksAsync |
@loaders.gl/json
- Experimental exports have been removed
JSONParser,StreamingJSONParser,ClarinetParser.
@loaders.gl/images
The experimental ImageLoaders for individual formats introduced in 2.0 have been removed, use ImageLoader for all formats.
@loaders.gl/images
getImageData(image)now returns an object with{data, width, height}instead of just thedataarray. This small breaking change ensures that the concept of image data is consistent across the API.ImageLoader:options.image.type: Thehtmlandndarrayimage types are now deprecated and replaced withimageanddatarespectively.
@loaders.gl/3d-tiles
Tileset3DLoader and Tile3DLoader are replaced by Tiles3DLoader, which supports loading both a 3D tileset file and a tile. Check loaders.gl/3d-tiles for loaded data format.
Upgrading to v2.0
Version 2.0 is a major release that consolidates functionality and APIs, and a number of deprecated functions have been removed.
Some general changes:
- All exported loader and writer objects now expose a
mimeTypefield. This field is not yet used by@loaders.gl/corebut is available for applications (e.g. seeselectLoader). - All (non-worker) loaders are now required to expose a
parsefunction (in addition to any more specializedparseSync/parseText/parseInBatchesfunctions). This simplifies using loaders without@loaders.gl/core, which can reduce footprint in small applications.
@loaders.gl/core
| Removal | Replacement |
|---|---|
TextEncoder | Use global TextEncoder instead and @loaders.gl/polyfills if needed |
TextDecoder | Use global TextDecoder instead and @loaders.gl/polyfills if needed |
createReadStream | fetch().then(resp => resp.body) |
parseFile | parse |
parseFileSync | parseSync |
loadFile | load |
@loaders.gl/images
| Removal | Replacement |
|---|---|
ImageHTMLLoader | ImageLoader with options.images.format: 'image' |
ImageBitmapLoader | ImageLoader with options.images.format: 'imagebitmap' |
decodeImage | parse(arrayBuffer, ImageLoader) |
isImage | isBinaryImage |
getImageMIMEType | getBinaryImageMIMEType |
getImageSize | getBinaryImageSize |
getImageMetadata | getBinaryImageMIMEType + getBinaryImageSize |
Loader Objects
- Loaders can no longer have a
loadAndParsemethod. Remove it, and just make sure you defineparseon your loaders instead.
@loaders.gl/gltf
The GLTFLoader now always uses the new v2 parser, and the original GLTFParser has been removed.
| Removal | Replacement |
|---|---|
GLBParser | GLBLoader |
GLBBuilder | GLBWriter |
GLTFParser | GLTFLoader |
GLTFBuilder | GLTFWriter |
packBinaryJson | N/A |
unpackBinaryJson | N/A |
Note that automatic packing of binary data (aka "packed JSON" support) was only implemented in the v1 GLTFLoader and has thus also been removed. Experience showed that packing of binary data for .glb files is best handled by applications.
GLTFLoader option changes
The foillowing top-level options are deprecated and will be removed in v2.0
| Removed Option | Replacement | Descriptions |
|---|---|---|
gltf.parserVersion | N/A | No longer needs to be specied, only the new gltf parser is available. |
fetchLinkedResources | gltf.fetchBuffers, gltf.fetchImages | |
fetchImages | gltf.fetchImages | |
createImages | N/A | Images are now always created when fetched |
decompress | gltf.decompressMeshes | Decompress Draco compressed meshes (if DracoLoader available). |
DracoLoader | N/A | Supply DracoLoader to parse, or call registerLoaders(pDracoLoader]) |
postProcess | gltf.postProcess | Perform additional post processing before returning data. |
uri | baseUri | Auto-populated when loading from a url-equipped source |
fetch | N/A | fetch is automatically available to sub-loaders. |
@loaders.gl/draco
| Removal | Replacement |
|---|---|
DracoParser | DracoLoader |
DracoBuilder | DracoWriter |
Loader Objects
- Loaders no longer have a
loadAndParseremoved. Just defineparseon your loaders.
Upgrading from v1.2 to v1.3
- As with v1.1,
GLTFLoaderwill no longer return aGLTFParserobject in v2.0. A new optionoptions.gltf.parserVersion: 2is provided to opt in to the new behavior now.
Upgrading from v1.0 to v1.1
A couple of functions have been deprecated and will be removed in v2.0. They now emit console warnings. Start replacing your use of these functions now to remove the console warnings and ensure a smooth future upgrade to v2.0.
Also, Node support now requires installing @loaders.gl/polyfills before use.
@loaders.gl/core
- Removal: Node support for
fetchFilenow requires importing@loaders.gl/polyfillsbefore use. - Removal: Node support for
TextEncoder, andTextDecodernow requires importing@loaders.gl/polyfillsbefore use. - Deprecation:
TextEncoderandTextDecoderwill not be exported fromloaders.gl/corein v2.0.
@loaders.gl/images
- Removal: Node support for images now requires importing
@loaders.gl/polyfillsbefore use.
@loaders.gl/gltf
- Deprecation:
GLBParser/GLBBuilder- These will be merged into GLTF classes.. - Deprecation:
GLTFParser/GLTFBuilder- The newGLTFclass can hold GLTF data and lets application access/modify it. - Deprecation:
GLTFLoaderwill no longer return aGLTFParserobject in v2.0. Instead it will return a pure javascript object containing the parse json and any binary chunks. This object can be accessed through theGLTFclass. Setoptions.GLTFParsertofalseto opt in to the new behavior now.
v1.0
First official release of loaders.gl.