makeLazyLoader causes error when project is bundled with Webpack

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I just upgraded from NPM package "mongodb": "3.1.10" to version 3.1.11 (and also 3.1.12) and found that I can no longer bundle my application with Webpack as I used to.

      When I start my Node.js app and and call MongoDB driver functions it throws this error:

      Cannot find module '//../mongo_client'

      During building with Webpack I get warnings like this:

      WARNING in ./node_modules/mongodb/lib/utils.js 701:12-31
      Critical dependency: the request of a dependency is an expression
       @ ./node_modules/mongodb/lib/admin.js
       @ ./node_modules/mongodb/index.js
       @ ./src/services/mongodb/index.ts @ ./src/index.ts

      My best guess at the moment is that if there are dynamic require in the code, Webpack includes all files from the directory down to make sure that the lazy-loaded modules will be found at runtime. Because the required file appears to be a directory up (../mongo_client) it will not be included or linked in the bundle and therefore not found at runtime.

      I wanted to make you aware of this issue. I don't know how common my approach is and how many users may be affected. Maybe it isn't the best idea to bundle a back-end Node app including all dependencies and I will review this approach.

              Assignee:
              Katherine Walker (Inactive)
              Reporter:
              Nick Zahn
              None
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: