nodejs / nodejs/cjs-module-lexer

Extending exports object detections

Open
#58 20 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

edge case wontfix
Dominant language
JavaScript
Stars
262
Forks
31
Avg merge
9d 2h
Merged PRs (30d)
5

Description

Object expressons like:

    module.exports = {
      render: _render2['default'],
      shallow: _shallow2['default'],
      mount: _mount2['default'],
      ShallowWrapper: _ShallowWrapper2['default'],
      ReactWrapper: _ReactWrapper2['default'],
      configure: _configuration.merge,
      EnzymeAdapter: _EnzymeAdapter2['default']
    };

would still be beneficial to fully support reading their properties.

The challenge is doing this without a full parser that can't handle eg object expression / brace ambiguity details.

One idea is that it could be possible to use a , parser with no knowledge of object assign / expression ambiguity but purely based on matching the first , that happens at the same depth of brace tracking (including all brace types) which might be a way to dodge the harder parsing issues while supporting arbitrary expressions.

Will leave this open as a tracking issue for that kind of support.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the object-expression examples and the proposed same-depth comma and brace-tracking approach. Done means named properties in these exports are fully supported without requiring a full parser, including arbitrary expressions and nested brace types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.