twit
twit copied to clipboard
Webpack Compatibility
It looks like this isn't compatible with Webpack.
Consider:
// index.js
// The minimum required file
const Twit = require('twit')
// OR
import Twit from 'twit'
// webpack.config.js
module.exports = {
entry: {
main: './index.js'
},
output: {
filename: 'bundle.js',
path: __dirname
},
target: 'node',
module: {
loaders: [
{ test: /\.js$/, loader: 'babel', exclude: /node_modules/ },
{ test: /\.json$/, loader: 'json' }
]
}
}
node node_modules/.bin/webpack && node bundle.js
returns:
module.exports = function() { throw new Error("define cannot be used indirect"); };
^
Error: define cannot be used indirect
at Object.module.exports [as define] (/Users/joe/ratticusscript/bundle.js:33865:38)
at Object.module.exports (/Users/joe/ratticusscript/bundle.js:33615:2)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:32779:23)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:32372:15)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:16366:15)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:8697:22)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.hasOwn (/Users/joe/ratticusscript/bundle.js:6423:20)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:71:16)
at __webpack_require__ (/Users/joe/ratticusscript/bundle.js:20:30)
at Object.<anonymous> (/Users/joe/ratticusscript/bundle.js:49:14)
Seems related to this issue over in Webpack: https://github.com/webpack/webpack/issues/138 Something about a dependency on validate.js?
I'm using this with webpack - maybe it has to do with your config.
@hoodsy can you share a link to your config? still seeing errors in a different project.
Try adding this to webpack.config.js
node: {
console: false,
fs: 'empty',
net: 'empty',
tls: 'empty'
}
Did you figure this out joe?