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

Support on-fly browserification with node-browserify #30

Closed
ghost opened this issue Dec 11, 2011 · 4 comments
Closed

Support on-fly browserification with node-browserify #30

ghost opened this issue Dec 11, 2011 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 11, 2011

Would be great if this npm package could be compatible with browserify so we don't have to use the minified version.

https://github.com/substack/node-browserify

At the moment I get an error when using the load() function.

@ixti
Copy link
Contributor

ixti commented Dec 11, 2011

In fact we use node-browserify to build a browserified version internally. Here's what we are doing (from Makefile):

browserify:
    if test ! `which browserify` ; then npm install browserify ; fi
    cp -r support/browserify/ ${TMP_DIR}
    browserify index.js -o ${TMP_DIR}/50_js-yaml.js
    cat ${TMP_DIR}/* > js-yaml.js
    rm -rf ${TMP_DIR}
    cp js-yaml.js demo/js/

In other words, we browserify js-yaml with node-browserify and then prepend and append to the result some portions of JavaScript that make us possible to add some browser-specific hacks and enclose everything to provide only one variable into global scope - jsyaml.

Please, explain which error you get exactly?

@ghost
Copy link
Author

ghost commented Dec 11, 2011

I installed js-yaml locally and I'm trying to require() it with browserify:

jsyaml = require "js-yaml"
console.log jsyaml.load "name:Johnny Luu"

It says:

Uncaught ReferenceError: jsyaml is not defined

So at the moment I'm better of to just include the "js-yaml.min" file.

Would be simpler to use the npm package in the browser since you can upgrade it (through package.json) once both for server and browser.

@ixti
Copy link
Contributor

ixti commented Dec 11, 2011

Hm. That's strange. If somebody will point why that might happen - we'll be glad to fix it. And will appreciate patches. But due to limited sources and time we can't handle this issue in the closest future. But the idea is really awesome!

@ghost
Copy link
Author

ghost commented Dec 11, 2011

Just tried it out again it actually worked!

I just forgot to require() it in another place of my app.

However, it takes browserify 10-15 seconds to concatenate all js-yaml files. But perhaps that is something browserify should get better at.

I'm glad that it worked. No need to keep the minified browser file up to date anymore! :)

Other people have this problem as well: browserify/browserify#90

@ghost ghost closed this as completed Dec 11, 2011
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant