Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3389

No longer possible to bundle statically

    • Type: Icon: Task Task
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Not Needed

      As of NPM MongoDB version 3.X, it is no longer possible to build the library server-side. Many library source files in this version have a require syntax that now includes a function call passing (require) which makes the library impossible to build. Many projects use Webpack to build the server-side code. So at this point I would believe that a server-side build involving Webpack is no longer possible due to the syntax of the require function in many files in the library? I may be totally off here, not sure...

       

      It would seem the line of issue would be the following, which is located in many places such as connection/utils.js, core/utils.js, and core/index.js.:

      const require_optional = require('optional-require')(require);

       

      See error when trying to compile here:

       

       [SERVICES] WARNING in ./node_modules/mongodb/lib/core/connection/utils.js
      [SERVICES] 3:53-60 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
      [SERVICES] @ ./node_modules/mongodb/lib/core/connection/utils.js
      [SERVICES] @ ./node_modules/mongodb/lib/core/cursor.js
      [SERVICES] @ ./node_modules/mongodb/lib/cursor.js
      [SERVICES] @ ./node_modules/mongodb/index.js
      [SERVICES] @ C:/Storage/Git/mrtis/shared/node/database/MongoConnection.js
      [SERVICES] @ ./server/serverProcess.js
      [SERVICES]
      [SERVICES] WARNING in ./node_modules/mongodb/lib/core/utils.js
      [SERVICES] 4:52-59 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
      [SERVICES] @ ./node_modules/mongodb/lib/core/utils.js
      [SERVICES] @ ./node_modules/mongodb/lib/bulk/common.js
      [SERVICES] @ ./node_modules/mongodb/index.js
      [SERVICES] @ C:/Storage/Git/mrtis/shared/node/database/MongoConnection.js
      [SERVICES] @ ./server/serverProcess.js
      [SERVICES]
      [SERVICES] WARNING in ./node_modules/mongodb/lib/core/index.js
      [SERVICES] 4:53-60 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
      [SERVICES] @ ./node_modules/mongodb/lib/core/index.js
      [SERVICES] @ ./node_modules/mongodb/index.js
      [SERVICES] @ C:/Storage/Git/mrtis/shared/node/database/MongoConnection.js
      [SERVICES] @ ./server/serverProcess.js
       
      

       

       

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            ops@mrtis.net Ryan Scully
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: