GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

New issue
Copy link
New issue
Copy link
Closed
Closed
How to use jsforce ver1.6.0 by webpack#381
Copy link

Description

@rchaser53
rchaser53
opened on Mar 13, 2016
Issue body actions

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

  1. stomita
    added
    question
    on Mar 23, 2016
  2. stomita commented on Mar 23, 2016

    @stomita
    stomita
    on Mar 23, 2016
    Contributor
    More actions

    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.

  3. stomita
    closed this as completedon Mar 23, 2016
  4. sgroschupf commented on May 1, 2016

    @sgroschupf
    sgroschupf
    on May 1, 2016
    More actions

    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.

  5. dirajkumar commented on May 5, 2016

    @dirajkumar
    dirajkumar
    on May 5, 2016
    More actions

    @stomita I'm having similar issue. Can you please let me how to use webpack and jsforce together?

  6. stomita commented on May 5, 2016

    @stomita
    stomita
    on May 5, 2016
    Contributor
    More actions

    @sgroschupf @dirajkumar I'll investigate and will include the webpack support in next patch release.

  7. stomita
    added
    enhancement
    on May 5, 2016
  8. stomita
    reopened this on May 5, 2016
  9. dirajkumar commented on May 6, 2016

    @dirajkumar
    dirajkumar
    on May 6, 2016
    More actions

    @stomita You're the best. When is the next release date? I'm really looking forward to it. Thanks a lot again.

  10. stomita commented on May 9, 2016

    @stomita
    stomita
    on May 9, 2016
    Contributor
    More actions

    @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
  11. rchaser53
    closed this as completedon Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.