GeezerVison is showing github.com — How to use jsforce ver1.6.0 by webpack · Issue #381 · jsforce/jsforce
How to use jsforce ver1.6.0 by webpack #381
Description
I have used jsforce ver1.5.1 in my project.
Recently I tryed to update jsforce 1.6.0 but I failed to bundle the source using webpack.
Error messeage is below.
ERROR in .//jsforce/lib/cli/cli.js
Module not found: Error: Cannot resolve module 'repl' in ** node_modules path **
@ .//jsforce/lib/cli/cli.js 40:86-101
ERROR in .//commander/index.js
Module not found: Error: Cannot resolve module 'child_process' in ** node_modules path **
@ .//commander/index.js 6:12-36
How should I do?
Activity
stomita commented on Mar 23, 2016
It seems webpack is not correctly handling package's metadata field browser, so it will lookup module which is unavailable in browser environment. Use browserify for building browser module instead.
sgroschupf commented on May 1, 2016
Hi Stomita,
I have the same problem here.
Can you be more clear about what to do to resolve this. I can not switch my build to browsify, since I have a more complex project.
Any help would be appreciated.
dirajkumar commented on May 5, 2016
@stomita I'm having similar issue. Can you please let me how to use webpack and jsforce together?
stomita commented on May 5, 2016
dirajkumar commented on May 6, 2016
@stomita You're the best. When is the next release date? I'm really looking forward to it. Thanks a lot again.
stomita commented on May 9, 2016
@dirajkumar @sgroschupf ver 1.6.3 is out and it has webpack bundling support. You need webpack.config.js with loader json-loader explicitly to create bundle without error.
module.exports = {
//...
module: {
loaders: [
{ test: /\.json$/, loader: "json" }
]
}
};
In the bundling script you can do simply call require('jsforce'):
var jsforce = require('jsforce');
// you can simply create a connection instance
var conn = new jsforce.Connection();
// or you can use browser client object (which is only available in browser env).
jsforce.browser.init({
clientId: 'your oauth2 client id is here',
redirectUri: 'your oauth2 redirect uri is here'
});
jsforce.browser.login();
jsforce.browser.on('connect', function(conn) {
// ...
});
Or you can use require('jsforce/core') to reduce the bundle size
// this only loads core script (without api modules)
var jsforce = require('jsforce/core');
// load chatter api module explicitly
require('jsforce/lib/api/chatter');
var conn = new jsforce.Connection();
console.log(conn.bulk) // undefined
console.log(conn.analytics) // undefined
console.log(conn.chatter) // [object]Reacted by Jon Crenshaw and rChaser53
Metadata
Metadata
Development
No branches or pull requestsIssue actions