dlr-eoc / ukis-frontend-libraries

A collection of angular ui-components, services, interfaces... to help you create geospatial mapping applications for the web.
Apache License 2.0
17 stars 4 forks source link

Demo maps throw error: TS2591: Cannot find name 'Buffer' #96

Closed MichaelLangbein closed 3 years ago

MichaelLangbein commented 3 years ago

Describe the bug

Running the demo-maps project in ukis-frontend-libraries fails with the error-message:

error TS2591: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig.
190           data.content.map(c => Buffer.from(c, 'base64').toString('ascii'));

To Reproduce

Steps to reproduce the behavior:

  1. Run 'npm run start'
  2. See error

Versions

App

Device:

Additional context

The error is quickly fixed by adding "types": ["node"] to demo-map's tsconfig.app.json. But: we cannot expect every user of our libraries to alter their tsconfig for us. Instead it would likely make sense to use a browser- and node-compatible version of Buffer, like this one, as suggested here

boeckMt commented 3 years ago

I think this is only in our not build system and the fix you propose is already in https://github.com/dlr-eoc/ukis-frontend-libraries/pull/95/commits/491986936009b61060c98c798163a4cbc87f75e9

The build libs should use /feross/buffer through browserify like described here https://github.com/feross/buffer#the-buffer-module-from-nodejs-for-the-browser

With browserify, simply require('buffer') or use the Buffer global and you will get this module.

MichaelLangbein commented 3 years ago

Well, perfect, if this is already handled than this issue can be closed. Thanks!