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

bson node es6 module import issue inside react app

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 6.8.0
    • Component/s: BSON
    • 3
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      Using bson module 6.8.0 inside a nextjs app (with app router) produces the following error:
      ```

      Unhandled Runtime Error

      Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `StaticGenerationSearchParamsBailoutProvider`.

      ```

      Reproduce

      • Use `npx create-next-app` with app router and typescript
      • Install __ bson module `npm i bson`
      • Create a source file test.ts where to import BSON and export a function that uses BSON.deserialize()
      • Import that test.ts inside a React Component that uses the previously exported function that uses BSON.deserialize()

      Something's wrong around module import/export somewhere. I'll try to publish a public github with this minimal reproduction scenario.

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            seb.trash@gmail.com Sébastien PERIN
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: