-
Notifications
You must be signed in to change notification settings - Fork 277
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
Consider adding package.json + npm support #4
Comments
Good call. +1 on adding Do you think it's beneficial / appropriate to include all the addon files concatenated together with XRegExp? If you wouldn't mind writing the script for it, it would save me some research and prolly get done sooner since I need to mostly step away from this project for a couple weeks. |
I can appreciate this move. You're welcome to steal the script I wrote, here: https://github.com/walling/xregexp/blob/master/package.sh I release it under MIT and 2-clause BSD license. :-) You would need to add support for other loaders, but I think it should be quite easy as seen in When you're ready we can move the NPM package to your NPM user, so you can publish the new versions when released. |
Rather than the Then, @walling’s script could be used to concatenate the files together. I’m not sure how exporting the plugins should work though… Perhaps @jdalton or @unscriptable know? |
Nice approach, @mathiasbynens. |
Note that |
@slevithan I was just gonna open an issue about making native |
@jdalton Great suggestion. Commit a94c925 brings an Can you point me to information about MooTool's |
@slevithan Sorry for the delay.... here is the links to Moo2 (Milk.js): https://github.com/mootools/Milk |
@slevithan here is a small Milk.js example with its generic methods and then installing them to the define(['Base/Utility/Array'], function(Array_) {
// ..
// invokes `myMethod` on each object in the array
Array_.invoke([obj1, obj2, obj3], 'myMethod');
// dump these methods to `Array.prototype`
Array_.install();
[obj1, obj2, obj3].invoke('myMethod');
}); |
@slevithan Here is my html5.js usage: // install support extensions with an options object
html5.install({
// allow IE6 to use CSS expressions to support `[hidden]`
// and `audio[controls]` styles
'expressions': true,
// overwrite the document's `createElement` and `createDocumentFragment`
// methods with `html5.createElement` and `html5.createDocumentFragment` equivalents.
'methods': true,
// add support for printing HTML5 elements
'print': true,
// add default HTML5 element styles
// (optional if `expressions` option is truthy)
'styles': true
});
// or with an options string
html5.install('print styles');
// or using a shortcut to install all support extensions
html5.install('all'); I also have |
I've made several commits to address the two separate issues discussed here. @jdalton Thanks for the examples and the pretty API! XRegExp now has @mathiasbynens @walling I've added Is this not enough? Did I get something wrong? Which enviros will this specifically support or not support? Feedback is welcome, of course. |
I prefer I would also prefer that the NPM module is including all XRegExp addons by default. From the looks of What do you all think about this? I'm open for comments. |
@walling // expose Benchmark
if (freeExports) {
// in Node.js or RingoJS v0.8.0+
if (typeof module == 'object' && module && module.exports == freeExports) {
(module.exports = Benchmark).Benchmark = Benchmark;
}
// in Narwhal or RingoJS v0.7.0-
else {
freeExports.Benchmark = Benchmark;
}
}
// via an AMD loader
else if (freeDefine) {
define('benchmark', function() {
return Benchmark;
});
}
// in a browser or Rhino
else {
// use square bracket notation so Closure Compiler won't munge `Benchmark`
// http://code.google.com/closure/compiler/docs/api-tutorial3.html#export
window['Benchmark'] = Benchmark;
} So in Node devs can do var Benchmark = require(...); But if they choose to use the more widely supported var Benchmark = require(...).Benchmark; it will work too. |
Woot nice! I dig the |
@slevithan I noticed you opt'ed to install |
That seems very robust, but if it's feasible (i.e., if enough of the latest versions of the most popular loaders support a standard interface), I'd really like to support only the single most standard/popular method and keep the supporting code down to a minimum.
Yeah, I struggled with that one, too. In the end, I used
Yes, that's only for backward compatibility, since not installing natives automatically is a major breaking change. I plan to remove the automatic installation in XRegExp 2.0 (the next version after the forthcoming v1.6). But then, I've recently been leaning toward skipping 1.6 and jumping straight to 2.0, especially since the next release will have the . . . OK, it's decided--I'm jumping to v2.0. No installing optional features automatically. :-) The mounting change list warrants bumping the major number anyway. |
Yes, I'm willing. Any chance you could write the patch for
Always glad to hear how it's used. You might be interested to know that the current HEAD version of Unicode Base (v1.0.0-dev) adds two major features vs v0.6: support for aliases (e.g., |
See the referenced pull request. By the way I'm looking forward to the Unicode updates. :-) |
@slevithan, I made a notice on my NPM module GitHub project that people should switch to See "If you already use this module" on https://github.com/walling/xregexp#readme. |
I also wrote a notice for at least one known user of the NPM module: vjeux/jsMatch#2 |
Cool cool. Merged. :-) See my question about I'll leave this issue open for a few days in case anyone has further feedback. |
@slevithan btw I settled on |
Good to know. I'm sticking with it, too. :) |
FYI, in commit b694fc5 I started using @walling In the same commit I made some tweaks to the node-qunit based testing. If you're able to confirm that it still works as expected, I'd really appreciate it, since I'm unable to run Node.js locally at the moment. |
This would take the burden off @walling, who maintains https://github.com/walling/xregexp.
We could write a simple script that concatenates all files together in the right order. It could be used as a post-commit hook.
The only thing that would need to change in the XRegExp source code is the way
XRegExp
is being exposed. @walling simply usesmodule.exports
for this, which works fine in Node.js — but with just a few more lines we could support exporting to Narwhal, RingoJS, Rhino, and AMD loaders like RequireJS as well. I do this in Punycode.js as follows: https://github.com/bestiejs/punycode.js/blob/a6e30c4e2ce7a9a569bc2c84a3435bd5612be59f/punycode.js#L493-510The text was updated successfully, but these errors were encountered: