rgrove / combohandler Goto Github PK
View Code? Open in Web Editor NEWA simple Yahoo!-style combo handler in Node.js.
License: MIT License
A simple Yahoo!-style combo handler in Node.js.
License: MIT License
I wonder if this module will be replaced by YLS/RLS in the future?
I need a custom combo handler for serving my private modules. Is this the only current solution?
Rumor has it Express 3.x and Combo Handler don't get along. Need to look into this.
YUI-Stockpile supports a custom template to build the combo url thru the loader that does not rely on the querystring
(few reasons behind that [1]). E.g:
comboBase: "/combo~",
comboSep: "~"
I see few options here:
comboSep
and comboBase
, and use those to parse the url[1] http://www.yuiblog.com/blog/2012/11/06/managing-your-javascript-modules-with-yui-3-stockpile-2/
The example root configuration file found at https://github.com/rgrove/combohandler#root-configuration does not seem to work. Instead, I had to provide a file without the nested roots
object, such as:
{
"/yui3": "/local/path/to/yui3"
}
The CSS url rewrite does not seem to work.
Here is my web directory:
C:\work\if\server\web>dir
Volume in drive C has no label.
Volume Serial Number is 82A9-DF6B
Directory of C:\work\if\server\web
01/10/2014 06:06 AM <DIR> .
01/10/2014 06:06 AM <DIR> ..
01/02/2014 07:15 AM <DIR> css
01/10/2014 06:06 AM <JUNCTION> if [C:\work\jetty\webapps\if]
01/02/2014 07:49 AM <DIR> js
01/04/2014 11:58 AM <DIR> lib
01/10/2014 06:05 AM <JUNCTION> yui [C:\work\jetty\webapps\yui]
01/10/2014 06:06 AM <JUNCTION> yui-gallery [C:\work\jetty\webapps\yui-gallery]
0 File(s) 0 bytes
8 Dir(s) 35,535,917,056 bytes free
C:\work\if\server\web>
_dirname
is C:\work\if\server
The project loads yui/datatable-sort/assets/skins/sam/datatable-sort.css, which contains the following line:
url(../../../../assets/skins/sam/sprite.png)
Try 1:
app.get('/combo',
combo.combine({
rootPath: __dirname + '/web/',
basePath: '/web'
}),
combo.respond);
The combined css rewrites the aforementioned url directive to
url(C:\web\yui\assets\skins\sam\sprite.png)
Try 2:
app.get('/combo',
combo.combine({
rootPath: __dirname + '/web/',
webRoot: __dirname
}),
combo.respond);
Which yields exactly the same url directive:
url(C:\web\yui\assets\skins\sam\sprite.png)
Of course, it does not work.
Strange enough YUI 3.1.1 seed makes the following request, appending an unnecessary & to the URL:
Their service ignores the ampersand, even when it is inserted multiple times, and fulfils successfully the request.
Given this behaviour is part of Yahoo's service, would you be willing to relax the validation, perhaps by removing the following lines from combohandler.js
:
if (fileTypes.indexOf('') > -1) {
// Most likely a malformed URL, which will just cause
// an exception later. Short-cut to the inevitable conclusion.
return next(new BadRequest('Truncated query parameters.'));
}
Looks like combohandler doesn't serves binary files (images for example) properly, even though proper mime-type is provided via config. I.E. images are served broken due to pollution of original file.
Using node v0.10.18.
It's funny how unit tests and code coverage only help so much. While I noodle about a more comprehensive integration test method, with these changes combohandler
will actually work in a customized capacity.
"Classic" combo requests for YUI library follow the "module_name/module_name.js" pattern. "Shorthand" requests will omit the doubled part of the request.
Classical: combo?3.13.0/yui/yui.js
Shorthand: combo?3.13.0/yui.js
This should be achievable with some route config to enable handling missing files gracefully.
Hello,
I've ran into some serious issues with this node module regarding the handling of CSS file loading and URL rewriting; When there are skin files included within YUI, it will attempt to pull from a machine's absolute directory(at least, on Windows). Another issue is anything with a data: path in a CSS URL would also have an error as well as the absolute path to the directory itself in a CSS URL.
I am on a Windows 8.1 machine btw, if that helps at all.
I fixed these but am not 100% certain the fix will apply to Unix/Linux machines. Haven't had an opportunity to test yet.
Please see the js fiddles I've created with the files that address these issues and apply them to the node NPM directory. Otherwise these files must be replaced every time npm install is run to fix.
cssUrls.js fixes: http://jsfiddle.net/9t1t14rz/
combohandler.js fixes: http://jsfiddle.net/b4zc8m3n/
Thanks for your time and for the great extension!
-Rob
Express middleware used via app.use()
requires a function, this commit bc842d9 made combo.combine()
always return an array.
comboloader has been working great for me, for use with yui2 and yui3. Compared to the yui php combo loader, it works out of the box.
However I do see one problem. When the config includes a non-existent path comboloader goes into a spin, spewing out error messages along with high cpu use. This continues until I manually kill the process.
Including the logs:
aaditya➜lib/node/combohandler(master✗)» spark2 -v [13:31:01] ... starting ... detected config.js ... loading config `/usr/local/lib/node/.npm/combohandler/0.1.2/package/./config.js' ... --roots { '/combo/static/vendor/lib/yui3': '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/3.4.0x', '/combo/static/vendor/lib/yui2': '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/2.9.0', '/combo/static/vendor/lib/epsilon': '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/epsilon', '/combo/static/vendor/lib/d1/d2/gallery': '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/gallery', '/combo/2in3/static/vendor/lib/2in3': '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/2in3' } ... detected app.js ... starting with (1) workers ... child spawned 87224 node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: ENOENT, No such file or directory '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/3.4.0x' at Object.lstatSync (fs.js:396:18) at Object.realpathSync (fs.js:627:23) at Object.combine (/usr/local/lib/node/.npm/combohandler/0.1.2/package/index.js:22:21) at /usr/local/lib/node/.npm/combohandler/0.1.2/package/lib/server.js:33:26 at Object. (/usr/local/lib/node/.npm/combohandler/0.1.2/package/app.js:2:18) at Module._compile (module.js:407:26) at Object..js (module.js:413:10) at Module.load (module.js:339:31) at Function._load (module.js:298:12) at require (module.js:351:19) ... Child Died (87224), respawning... ... child spawned 87225 node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: ENOENT, No such file or directory '/Users/aaditya/work/id/src/id/vaitarna/vaitarna/public/static/vendor/lib/3.4.0x' at Object.lstatSync (fs.js:396:18) at Object.realpathSync (fs.js:627:23) at Object.combine (/usr/local/lib/node/.npm/combohandler/0.1.2/package/index.js:22:21) at /usr/local/lib/node/.npm/combohandler/0.1.2/package/lib/server.js:33:26 at Object. (/usr/local/lib/node/.npm/combohandler/0.1.2/package/app.js:2:18) at Module._compile (module.js:407:26) at Object..js (module.js:413:10) at Module.load (module.js:339:31) at Function._load (module.js:298:12) at require (module.js:351:19) ... Child Died (87225), respawning... ... child spawned 87226 node.js:134 throw e; // process.nextTick error, or 'error' event on first tick
It would be useful to support combining files which reside in different root paths in one HTTP request.
app.get('/js', combo.combine({rootPath: [
__dirname + '/public/js',
__dirname + '/shared/js'
]}), function (req, res) {
res.send(res.body, 200);
});
http://example.com/js?models/photo.js&widget/lightbox.js
One tricky aspect of this is having ambiguous file paths when a file of the same path resides in both roots.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.