One of the most important command-line tools in Node is: npm. Currently, npmjs, serves more than 60k JavaScript modules. And, you can access most of these codebases easily from the browser with browserify.
With browserify, you can run the same code in the browser, that you would run in Node on Unix. This is great, since it allows you to “require” modules from Node, and play with ideas, before you enter the world of the document-object-model (DOM), or the browser.
Let’s first look at the basics. In Node.js, you could write a “hello world” as follows:
$ mkdir lib
$ cat > lib/hello.js
console.log("Hello world.")
$ node lib/hello.js
Hello world.
In order to browsify this server-side script for the browser environment, let’s write:
$ browserify ./lib/hello.js
http://thinkingonthinking.com/unix-in-the-browser/
http://browserify.org/
https://github.com/substack/browserify-handbook
browserify tools - https://github.com/substack/node-browserify/wiki/browserify-tools
browserify transforms - https://github.com/substack/node-browserify/wiki/list-of-transforms
browserify plugins - https://www.npmjs.com/browse/keyword/browserify-plugin
No comments:
Post a Comment