Superagent: Webpack bundle for server side execution not working with superagent

Created on 4 Jun 2015  路  8Comments  路  Source: visionmedia/superagent

I get warnings while bundling and a crash when running a webpack bundle with target 'node'.

webpack.config.js:

export default {
    name: 'server',
    target: 'node',
    ...
}

Bundling warnings:

WARNING in ./~/superagent/~/formidable/lib/incoming_form.js
Critical dependencies:
3:43-50 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/superagent/~/formidable/lib/incoming_form.js 3:43-50

WARNING in ./~/superagent/~/formidable/lib/file.js
Critical dependencies:
3:43-50 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/superagent/~/formidable/lib/file.js 3:43-50

WARNING in ./~/superagent/~/formidable/lib/json_parser.js
Critical dependencies:
3:43-50 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/superagent/~/formidable/lib/json_parser.js 3:43-50

WARNING in ./~/superagent/~/formidable/lib/querystring_parser.js
Critical dependencies:
3:43-50 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/superagent/~/formidable/lib/querystring_parser.js 3:43-50

Crash when bundle is run:

    var fs = require('fs');
             ^
TypeError: undefined is not a function

Most helpful comment

You can try to fix that issue by adding

plugins: [
    new webpack.DefinePlugin({ "global.GENTLY": false })
],

to your webpack config

All 8 comments

sounds like some webpack issue. Maybe ask them to help

I'm having this same issue. Seeing this when i try using superagent. Any luck with this issue? @vlinder

You can try to fix that issue by adding

plugins: [
    new webpack.DefinePlugin({ "global.GENTLY": false })
],

to your webpack config

That is what solved my problem.

@tdeheurles do you mind sharing the rest of your config? I'm still running into this issue

I'll try to find... I鈥檓 not sure the project is fine. I can鈥檛 remind but maybe it鈥檚 the one where I finished with babel-cli ...

@davis sorry, have looked to my commit and I can鈥檛 find ... Do you run targeting node ?

I got around it by removing some lines from the bundle after building. Inconvenient, but works for now. Thanks though!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kornelski picture kornelski  路  4Comments

shreychaturvedi123 picture shreychaturvedi123  路  9Comments

littlee picture littlee  路  8Comments

djechlin picture djechlin  路  6Comments

ropez picture ropez  路  7Comments