Package Exports
- babel-plugin-inline-replace-variables
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (babel-plugin-inline-replace-variables) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
babel-plugin-inline-replace-variables
It replace an Identifier to a literial (LVal), if you want to transfrom a identifier to another identifier, you can see: babel-plugin-replace-identifiers
Usage
npm i babel-plugin-inline-replace-variables --save-dev
configure in .babelrc(should transfer to json format) or any babel queries:
{
plugins: [
['inline-replace-variables', {
"__SERVER__": true,
"__VERSION__": "v1.2.3"
}]
]
}
EFFECT:
if (__SERVER__) {
console.log('this is server, version: %s', __VERSION__)
} else {
alert('this is browser')
}
will be transformed to
if (true) {
console.log('this is server, version: %s', "v1.2.3")
} else {
alert('this is browser')
}
tip:
Version 1.0.1 fix the misspelling of 'varibles' to 'variables'
so babel-plugin-inline-replace-varibles
is deprecated, you should instead it of babel-plugin-inline-replace-variables
CONTACT: https://github.com/wssgcg1213