Skip to content

Unexpected token with ?. #166

@xavdid

Description

@xavdid

I'm not sure if the problem is here (or in a subpackage, like detective, but I noticed this library tripping over semi-recent ES syntax. I'm not sure what the best fix is - if there's something on my end I can configure with browserify or if there's something in one of the related packages that needs to be updated to support newer syntax.

Either way, thanks a bunch!

Reproduction

t.js:

require("fs");

let o = {};
console.log(o?.a?.b);
$ module-deps t.js

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: Parsing file t.js: Unexpected token (4:14)
    at Deps.parseDeps (.../module-deps/index.js:519:15)
    at getDeps (.../module-deps/index.js:447:44)
    at /module-deps/index.js:430:38
    ...

This was on Node.js 14, where the ?. syntax works as expected:

$ node t.js
undefined

Package Versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions