tight-sprite
tight-sprite copied to clipboard
Cannot use project with browserify / frontend tools
Not sure what's up with the installation and why heya-ctr is really needed (there are probably more robust & well tested binary/quick sort libs on npm?), but I'm getting this error trying to use either entry point:
Uncaught Error: Cannot find module '../main'
at s (_prelude.js:1)
at _prelude.js:1
at binarySearch.js:1
at Array.map (<anonymous>)
at aTmpl (binarySearch.js:1)
at Object.435 (binarySearch.js:2)
at s (_prelude.js:1)
at _prelude.js:1
at Object.453.heya-ctr/algos/binarySearch (search.js:4)
at s (_prelude.js:1)
Too bad since this seems like it could be a really handy module! Thanks for writing it anyways. :smile:
This is a node.js-based project. It is mostly used as a grunt plugin in an asset pipeline. I have no idea how browserify helps in any of that. The project is to produce image bitmap sprites for the browser, not in the browser. Could you share more on what you are trying to achieve, and the exact setup to reproduce the problem?
Right now I'm using bin-pack to do real-time sprite sheeting in the browser (client-side) rather than having to do it as an offline step. This is useful, for example, when packing dynamic light maps into a single texture for the GPU with WebGL. However, your module seems like it could pack much more efficiently than bin-pack and other existing modules, which is why I hoped it could be used as a drop-in replacement.
Browserify (like webpack) is just a way to utilize these npm modules in client-side code without all the grunt/gulp tasks. For example, pack.js:
const binPack = require('bin-pack');
const result = binPack([ { width: 120, height: 100 }, ... ]);
console.log(result);
Running browserify from shell:
browserify pack.js --debug > bundle.js
Now the bundle.js script contains my app as well as all the required dependencies (bin pack), and can be put into a browser <script> tag.
IC. So how can I repro the problem the easy way? Is it enough to require() a tight-sprite module and run it through browserify?
Note to myself: browserify is a static code converter. It is likely having a problem with dynamic UMD prologues used by heya-ctr, or any other library. If we can verify that this is the problem, to fix it is a simple matter of running heya-ctr through heya-globalize to make all request() calls static.