Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Bundling Exceeds 100kb Limit #121

Closed
christiannwamba opened this issue Apr 21, 2017 · 3 comments
Closed

Bundling Exceeds 100kb Limit #121

christiannwamba opened this issue Apr 21, 2017 · 3 comments

Comments

@christiannwamba
Copy link
Contributor

Running wt commands works as expected. At this point of my example, I decide to split the files into different modules for maintainability. For this to happen, I will need to use webtask-bundle.

Unfortunately, when webask-bundle tries to do its thing, it creates a large bundle which exceeds the 100kb limit. The following error is thrown:

Uncaught error:  Request body size exceeds 122880
Error: Payload Too Large
    at Request.callback (/usr/local/lib/node_modules/wt-cli/node_modules/superagent/lib
/node/index.js:698:17)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/wt-cli/node_modules/sup
eragent/lib/node/index.js:922:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The weird thing is, the demo just have about 40 lines of codes though it imports express, body-parser, mongoose and webtask-tools.

Excerpt:

var Express = require('express');
var Webtask = require('webtask-tools');
var app = Express();
var mongoose = require('mongoose');

app.use(require('body-parser').json());

app.get('/id', function (req, res) {
    console.log(req.webtaskContext.secrets.MONGO_URL)
    res.json();
});

console.log(require('./routes/allStories')(app));
require('./routes/allStories')(app);

module.exports = Webtask.fromExpress(app);
@ggoodman
Copy link
Contributor

ggoodman commented Apr 24, 2017

Hi @christiannwamba, have you tried using the --bundle flag in wt-cli? Normally, you shouldn't need to use webtask-bundle directly as it will be used under the hood to provide the --bundle functionality.

The reason that webtask-bundle is generating a large bundle is that it needs to be seeded with the correct set of modules to be considered as externals. wt-cli contains the logic to correctly seed externals, given a package.json file.

@NotMyself
Copy link

Hi @christiannwamba,

It looks like @ggoodman responded to your question back in 2017. I am going to close this issue. If you are still experiencing issues. Feel free to respond and reopen it. Thanks for using webtasks!

@stephanmax
Copy link

stephanmax commented Oct 20, 2018

@NotMyself, I am still having this issue:

Uncaught error:  Request body size exceeds 122880
Error: Payload Too Large
    at Request.callback (/Users/stephanmax/project/ephemeral-tweets/node_modules/superagent/lib/node/index.js:706:15)
    at parser (/Users/stephanmax/project/ephemeral-tweets/node_modules/superagent/lib/node/index.js:916:18)
    at IncomingMessage.res.on (/Users/stephanmax/project/ephemeral-tweets/node_modules/superagent/lib/node/parsers/json.js:19:7)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

I have one dependency (the twit package) and am using wt-cli 11.0.0.

However, it works with --bundle-minify, though. Still, since my code is only like 50 locs I think the twit library is bundled in. (ES6 transpilation does not seem to work, though, because I get Compilation failed: Unexpected token import when running the webtask...)

Update: Nevermind, with --bundle-minify it does not find my dependency (Compilation failed: Cannot find module 'twit'). What am I missing?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants