Skip to content

Replace all instances of Object.freeze(value) with value

License

Notifications You must be signed in to change notification settings

discord/babel-plugin-strip-object-freeze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-strip-object-freeze

Replace all instances of Object.freeze(value) with value

If you use Object.freeze() a lot in development to enforce constraints, you may want to use this plugin to strip those Object.freeze() calls in production for performance if they are not important.

Install

npm install --save-dev babel-plugin-strip-object-freeze

Usage

It's recommended that you only use this plugin in a production build.

// babel.config.js
let presets = [ ... ]
let plugins = [ ... ]

if (process.env.NODE_ENV === "production") {
  plugins.push("babel-plugin-strip-object-freeze")
}

module.exports = { presets, plugins }

Example

Input:

Object.freeze(value)

Output:

value

About

Replace all instances of Object.freeze(value) with value

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published