1.0.3 • Published 7 years ago

babel-plugin-auto-constant v1.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

Auto Constant!

This space aged babel plugin allows you to create constants whose value is the named expression by simply writing the expression without const or assigning a value:

E.g. instead of:

const FOO_UPDATE_IN_FLIGHT = 'FOO_UPDATE_IN_FLIGHT';

simply write:

FOO_UPDATE_IN_FLIGHT;

... which compiles the same to:

var FOO_UPDATE_IN_FLIGHT = 'FOO_UPDATE_IN_FLIGHT';

Exporting

If you want to export, add two underscores to the end of your expression:

FOO_LOADED__

...which will compile to

var FOO_LOADED = exports.FOO_LOADED = 'FOO_LOADED';

Note if you are only exporting constants, make sure to export a default or any value so that Babel will define the __esModule property on exports