Skip to content

Unable to detect exports from bundled webpack output #88

Open
@SimenB

Description

Title is probably inaccurate 😅

I recently added bundling to Jest, and it seems the output makes the lexer not detect exports correctly.

Specifically, it picks up the exports. stuff that is not exported, but not the exports within Object.definedProperty which actually are.

Quickest reproduction I have is to clone Jest, run yarn && yarn build:js then this:

const fs = require('fs');
const {parse} = require('cjs-module-lexer');

const source = fs.readFileSync(require.resolve('jest-watcher'), 'utf8');

console.log(parse(source));

This prints

{
  exports: [
    'default',
    'KEYS',
    'printPatternCaret',
    'printRestoredPatternCaret'
  ],
  reexports: []
}

Running the parser on the published version (29.7.0) gives this:

{
  exports: [
    '__esModule',
    'BaseWatchPlugin',
    'JestHook',
    'PatternPrompt',
    'Prompt',
    'TestWatcher'
  ],
  reexports: [ './constants', './lib/patternModeHelpers' ]
}

The reexports are of course gone as it's bundled, but we're also seeing that the lexer has detected only the resolved re-exports?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions