Skip to content

@rollup/plugin-commonjs breaks when using require as shorthand object property #763

@chmelevskij

Description

@chmelevskij
  • Rollup Plugin Name: @rollup/plugin-commonjs
  • Rollup Plugin Version: 17.0.0
  • Rollup Version: 2.36.1
  • Operating System (or Browser): MacOS BigSur
  • Node Version: v14.13.1
  • Link to reproduction (⚠️ read below): replit github

Expected Behavior

Plugin should correctly handle shorthand properties with require in them.

Actual Behavior

It seems to replace it with helper which brakes the parsing.

Additional Information

This originally popped up for me when using vm2. It would try to replace shorthand require with commonjsHelpers.commonjsRequire which would give error like the one below, when babel would try to transpile it.


  1242 | const HOST = {
  1243 |        version: parseInt(process.versions.node.split('.')[0]),
> 1244 |        commonjsHelpers.commonjsRequire,
       |                       ^
  1245 |        process,
  1246 |        console,
  1247 |        setTimeout,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions