Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-inline-replace-variables

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-inline-replace-variables - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

3

lib/index.js

@@ -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);

2

package.json
{
"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');
}`)
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc