Git Product home page Git Product logo

Comments (6)

aemkei avatar aemkei commented on September 22, 2024

Looks like browserify can't include bytebuffer correctly. I see this in the final osm-read-pbf.js:

{"bytebuffer":"bytebuffer","fs":undefined,"path":undefined}]}

from osm-read.

nrenner avatar nrenner commented on September 22, 2024

Seems like my hack to include the minified files is no longer working with the latest browserify:

browserify ./lib/pbfParser.js --bare -x bytebuffer -x long -r ./node_modules/protobufjs/node_modules/bytebuffer/ByteBuffer.min.js:bytebuffer -r ./node_modules/protobufjs/node_modules/bytebuffer/node_modules/long/dist/Long.min.js:long -s=pbfParser -o osm-read-pbf.js

As a workaround you can use:

browserify ./lib/pbfParser.js --bare -s=pbfParser -o osm-read-pbf.js

Need to see what I can do about this.

from osm-read.

aemkei avatar aemkei commented on September 22, 2024

Thanks! The workaround works for now.
BTW: This is an amazing project and I'm looking forward to see OSM data in Node and the browser…

from osm-read.

nrenner avatar nrenner commented on September 22, 2024

The reason for wanting to require the already minified files is that ByteBuffer.min.js and Long.min.js are built with Google Closure Compiler in advanced mode, which supposedly might also improve runtime performance e.g. by function inlining.

But now I have done some quick manual testing and could not observe a significant performance improvement. I also wanted to look into compiling across all modules instead of using the individual builds, but don't know if that would be worth the effort. So for now I'm simply using minifyify on the sources.

Here is the build workaround used for testing:

  browserify -r ./node_modules/protobufjs/node_modules/bytebuffer/dist/ByteBufferAB.min.js:bytebuffer -x long -o bytebuffer.js
  browserify -r ./node_modules/protobufjs/node_modules/bytebuffer/node_modules/long/dist/Long.min.js:long -o long.js
  browserify ./lib/pbfParser.js --bare -x bytebuffer -x long -s=pbfParser -o osm-read-pbf.js

  <script src="long.js"></script>
  <script src="bytebuffer.js"></script>
  <script src="osm-read-pbf.js"></script>

from osm-read.

wolfgangvonludwigsburg avatar wolfgangvonludwigsburg commented on September 22, 2024

I did follow your workaround so far,
but I end up with:

Uncaught TypeError: Cannot read property 'decode' of undefined (in osm-read-pbf.js):

function readBlobHeaderContent(fd, position, size, callback) {
=> return reader.readPBFElement(fd, position, size, fileFormat.BlobHeader.decode, callback);
}

Looks like:

var fileFormat = require('./proto/fileformat.js');

does'nt instantiate correctly ... (i.e. missing Member '.BlobHeader')

Would you please upload (e.g. to './dist') any working files from your functional workaround:
long.js, bytebuffer.js, osm-read-pbf.js
so I can check against my configuration ...

PLEASE ... ;-)
Thank you.

from osm-read.

nrenner avatar nrenner commented on September 22, 2024

Sorry about this. Moving forward, I now have merged the pending PR #31. This fixes the build, so npm run browserify now works again.

I also have committed the osm-read-pbf.js to the repo. It contains all that is needed, so you should be ready to go.

from osm-read.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.