Skip to content

replace: objectGuards not working #1178

@privatenumber

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)

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