lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
580 stars 75 forks source link

lasso/middleware & koa v2 #161

Open basickarl opened 7 years ago

basickarl commented 7 years ago

https://github.com/koajs/koa

I peeked in the middleware.js file and see that it's been made to comply with express. I tweaked my own version and is working. Just want you to know this!

working for koa (lasso/middleware/serveStatic.js):

    // line 44
    return function(ctx, next) {
        var req = ctx.request,
            res = ctx.response;

In koa ctx is passed instead of express' req and res.

basickarl commented 7 years ago

Currently:

module.js:471
    throw err;
    ^

Error: Cannot find module 'lasso/middleware/koa'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/karl/dev/node/sketch/experiment/koa-babel-lasso/src/index.js:7:1)
    at Module._compile (module.js:570:32)
    at loader (/home/karl/dev/node/sketch/experiment/koa-babel-lasso/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/karl/dev/node/sketch/experiment/koa-babel-lasso/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

I've fully fixed this now, tested on both koa and koa@2. Here is the pull request.

https://github.com/lasso-js/lasso/pull/169

basickarl commented 7 years ago

Currently fixing the send module so that it works with both versions of koa, once that is fixed I'll update lasso. https://github.com/pillarjs/send/pull/120#pullrequestreview-4870245 https://github.com/pillarjs/send/issues/118