Closed aemkei closed 9 years ago
Looks like browserify can't include bytebuffer
correctly. I see this in the final osm-read-pbf.js
:
{"bytebuffer":"bytebuffer","fs":undefined,"path":undefined}]}
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.
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…
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>
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.
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.
It is not possible to run the
example/pbf.html
.I followed the instructions and run
npm run browserify
to create the fileosm-read-pbf.js
. When opening the example HTML it will throw the following errors: