Skip to content

replace: objectGuards not working #1178

Closed

Description

@privatenumber

Input

index.js

if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
	console.log('production');
}

Expected Behavior

@rollup/plugin-replace README says the output should be:

if ('object' !== 'undefined' && 'production' === 'production') {
  console.log('production');
}

Actual Behavior

typeof process is not replaced.

Output

if (typeof process !== 'undefined' && "production" === 'production') {
	console.log('production');
}

Additional Information

There is no regression. Looks like the feature was merged when it was not working: #1084 (comment)

Activity

  1. stale commented on Jul 12, 2022

    @stale

    Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

  2. niba1122 commented on Aug 24, 2022

    @niba1122

    I met same problem and maybe actual issue.
    Internal patterns for typeof (e.g. typeof process !==) does not work because of delimiters ['\\b', '\\b(?!\\.)'] added by #1088.

  3. privatenumber commented on Aug 24, 2022

    @privatenumber
    Author

    I don't think it was ever working:

    There is no regression. Looks like the feature was merged when it was not working: #1084 (comment)

  4. stale commented on Apr 27, 2025

    @stale

    Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ

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

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