--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Oh, for others to install you will need to put in on a public repo.
(function() {
var root = this;
// body of the module here
}).call(this);var Backbone; if (typeof exports !== 'undefined') { Backbone = exports; } else { Backbone = root.Backbone = {}; }
var _ = root._; if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
if (typeof tokenizer === 'undefined')var tokenizer = require('./tokenizer');
var checker = (function() {var whitespace = 1;var newline = 2;var word = 3;...
if (typeof module !== 'undefined' && module && module.exports)module.exports = checker;
--
<!-- script which defines `require`, `module.exports` --><script src="definitions.js"></script><!-- your class files --><script src="Foo.js"></script><script src="Bar.js"></script>...<!-- your app's code --><script src="app.js"></script>
> you could create one:
> <!-- script which defines `require`, `module.exports` -->
This is essentially what brequire is (client-side CommonJS) -- https://github.com/weepy/brequire. This works and is nicer than the typical browserify usage because it doesn’t bundle all dependencies into a large, single standalone file. Note that browserify now supports this use-case as well.
While this brings some advantages (a module system, dependency management, etc), it often isn’t what client-side developers want. The majority of client-side developers are not node developers. Even if you make all your node-module-handling stuff transparent to client-side users of your code, there is still a price-tag in weight and in complexity for client-side developers who want to read and understand the code that they’re bringing into their project.
If your modules have a ton of fine-grained dependencies or multiple layers of dependencies or a lot of node-specific dependencies, then using brequire or browserify or something similar can make your life easier. But if not – and especially if your goal is maximum adoption of your modules by client-side developers – you may want to consider following the lead of Underscore and Backbone and add a few lines of boilerplate to each file so client-side developers can use your code according to client-side idioms.
-- peter
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/I9NoW70iQTo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
Damn, premature send >_>, anyways:
The best thing about Node was always the promise of code sharing, and that definitely possible. The only problem here is that people think that you need to rewrite your code to node's module pattern in order for it to work in Node.js. This is definitely not the case. Node comes with a great file reading interface and ships a `vm` module that you can use to evaluate code. Armed with this knowledge you can leverage a "module system" that we've been working with for ages as front-end developers and that is globals. And there's nothing wrong with that.
I've always been annoyed by the fact that code that needed to be shared between environments needed to have this awful module bloat in order for it to work. You got node's module system, amd, ES6 imports and next week there's another hipster module system that you need to support. And for this reason i've written load:
https://github.com/3rd-Eden/load
Which basically reads your JavaScript file, loads it in the JavaScript virtual machine, read's out the exposed / added globals and exposes them. That it. No build system needed to make your code work. Just plain o'l JavaScript.
The best thingOn Sunday, July 14, 2013 at 8:09 AM, Ryan Schmidt wrote:
Years before I knew about node, I wrote two client-side JavaScript libraries, one of which uses the other, each providing about half a dozen classes. Now I would like to modernize these libraries to make them most accessible to today's web developers.What is the best way to write my modules so they can be included in any client-side or server-side JavaScript environment?I would like to publish them to npm. To that end, I've started switching them to node-style require() and module.exports, but of course I can't use those files in the browser ("module is not defined") without a build step such as browserify, or adding boilerplate to each file, and I don't want to bloat my library too much.I don't want to mandate that my users use an AMD loader, or a CommonJS loader, or RequireJS or curl.js or anything else; I want my libraries to be compatible with any script loading method of the user's choosing.Avoiding the build step during development would be nice too. I'd like to be able to just include the dozen class files in script tags and use them.----Job Board: http://jobs.nodejs.org/Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-GuidelinesYou received this message because you are subscribed to the GoogleGroups "nodejs" group.To post to this group, send email to nod...@googlegroups.comTo unsubscribe from this group, send email to
For more options, visit this group at---You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.