Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

Load CJS instead of ESM #157

@rtritto

Description

@rtritto

Description

Instance of parsed ObjectId, using ejson-shell-parser (version >= 1.2.1), is different from bson.ObjectId instance (bson version >= 5.0.0-alpha.0).
Correctly work:

  • CommonJS (type: commonjs) with bson v4 and v5
  • ESM (type: module) with bson v4

Same problem with Timestamp, BSONSymbol, DBRef, MinKey, MaxKey.

Steps to reproduce:

  • yarn init -y
  • yarn set version canary
  • yarn add bson ejson-shell-parser
  • Add "type": "module" in pakcage.json
  • Create index.js file
import { ObjectId } from 'bson' 
import parser from 'ejson-shell-parser'
const out = parser.default('ObjectId()')
console.log(out instanceof ObjectId)
  • yarn node index.js

Versions:

bson >= 5.0.0-alpha.0
ejson-shell-parser >= 1.2.1
Node: 16.17.0

Actual

log is false

Expect

log is true

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