-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugin/replace): fix
object_guards
option (#2322)
### Description [@rollup/plugin-replace](https://www.npmjs.com/package/@rollup/plugin-replace)'s docs give this example for `objectGuards` option: ```js replace({ values: { 'process.env.NODE_ENV': '"production"' } }); ``` ```js // Input if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') { console.log('production'); } // Without `objectGuards` if (typeof process !== 'undefined' && 'production' === 'production') { console.log('production'); } // With `objectGuards` if ('object' !== 'undefined' && 'production' === 'production') { console.log('production'); } ``` Rolldown's version was not following this behavior. The example above was transformed to: ```js if (typeof process !== "undefined" && true) { console.log("production"); } ``` This PR fixes that. The implementation now is almost identical to [Rollup's implementation](https://github.com/rollup/plugins/blob/master/packages/replace/src/index.js).
- Loading branch information
1 parent
84cb2a2
commit 3899128
Showing
2 changed files
with
19 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters