iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.09k stars 293 forks source link

[Bug - Dependencies] Missing Buffer dependency #2200

Open Desplandis opened 11 months ago

Desplandis commented 11 months ago

Your Environment

Context

Using itowns as a dependency causes bundling (e.g. with webpack) and runtime errors due to a missing buffer module. This error comes from shpjs (as well as its dependency safe-buffer) which assumes a node runtime context where Buffer is part of the "standard library".

This causes additional hassle to library users (by definition in a browser context) which:

By the way, this problem does not arise on our own examples due to a "luck" factor. The buffer polyfill is part of our list of dependencies since puppeteer (from devDependencies) depends on it. You could see it with npm list --all.

Steps to Reproduce (for bugs)

You could reproduce this issue:

Expected Behavior

Using itowns as a dependency shall work out-of-the-box and not cause bundling and runtime errors due to buffer.

Actual Behavior

Runtime and bundling errors in projects using itowns

Possible Cause/Fix/Solution

Add the buffer polyfill as part of itowns dependencies.