babel-plugin-inline-replace-variables
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -21,2 +21,5 @@ 'use strict'; | ||
var replacement = state.opts[path.node.name]; | ||
if (path.parent.type === 'MemberExpression') { | ||
return; | ||
} | ||
if (replacement !== undefined) { | ||
@@ -23,0 +26,0 @@ var type = typeof replacement === 'undefined' ? 'undefined' : _typeof(replacement); |
{ | ||
"name": "babel-plugin-inline-replace-variables", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "babel plugin to inline replace variables", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,4 +9,7 @@ /** | ||
visitor: { | ||
Identifier (path, state) { | ||
Identifier(path, state) { | ||
const replacement = state.opts[path.node.name] | ||
if (path.parent.type === 'MemberExpression') { | ||
return; | ||
} | ||
if (replacement !== undefined) { | ||
@@ -13,0 +16,0 @@ const type = typeof replacement |
@@ -10,3 +10,3 @@ /** | ||
describe('babel-plugin-inline-replace-varibles', () => { | ||
describe('simple', () => { | ||
describe(`transform`, () => { | ||
@@ -36,1 +36,28 @@ it(`__SERVER__ should be replaced to true`, () => { | ||
}); | ||
describe('member expression', () => { | ||
describe(`transform`, () => { | ||
it(`__SERVER__ should NOT be replaced to true`, () => { | ||
babel.transform(` | ||
if (foo.bar.__SERVER__) { | ||
console.log('this is server, version: %s', __VERSION__) | ||
} else { | ||
alert('this is browser') | ||
} | ||
`, { | ||
plugins: [[plugin, { | ||
__SERVER__: true, | ||
__VERSION__: "v1.2.3" | ||
}]] | ||
}).code | ||
.should.be.equal(` | ||
if (foo.bar.__SERVER__) { | ||
console.log('this is server, version: %s', 'v1.2.3'); | ||
} else { | ||
alert('this is browser'); | ||
}`) | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5595
112