Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use project with browserify / frontend tools #2

Open
mattdesl opened this issue Aug 10, 2017 · 4 comments
Open

Cannot use project with browserify / frontend tools #2

mattdesl opened this issue Aug 10, 2017 · 4 comments
Assignees
Labels

Comments

@mattdesl
Copy link

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. 😄

@uhop uhop self-assigned this Aug 10, 2017
@uhop uhop added the question label Aug 10, 2017
@uhop
Copy link
Owner

uhop commented Aug 10, 2017

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?

@mattdesl
Copy link
Author

mattdesl commented Aug 10, 2017

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.

@uhop
Copy link
Owner

uhop commented Aug 10, 2017

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?

@uhop
Copy link
Owner

uhop commented Aug 11, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants