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.2 to 1.2.0

5

lib/index.js

@@ -20,6 +20,9 @@ 'use strict';

Identifier: function Identifier(path, state) {
var replacement = state.opts[path.node.name];
if (path.parent.type === 'MemberExpression') {
return;
}
if (path.isPure()) {
return;
}
var replacement = state.opts[path.node.name];
if (replacement !== undefined) {

@@ -26,0 +29,0 @@ var type = typeof replacement === 'undefined' ? 'undefined' : _typeof(replacement);

4

package.json
{
"name": "babel-plugin-inline-replace-variables",
"version": "1.1.2",
"version": "1.2.0",
"description": "babel plugin to inline replace variables",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"type": "git",
"url": "github.com/wssgcg1213/babel-plugin-inline-replace-variables"
"url": "https://github.com/wssgcg1213/babel-plugin-inline-replace-variables"
},

@@ -15,0 +15,0 @@ "keywords": [

@@ -10,6 +10,9 @@ /**

Identifier(path, state) {
const replacement = state.opts[path.node.name]
if (path.parent.type === 'MemberExpression') {
return;
}
if (path.isPure()) {
return;
}
const replacement = state.opts[path.node.name]
if (replacement !== undefined) {

@@ -16,0 +19,0 @@ const type = typeof replacement

@@ -61,2 +61,24 @@ /**

});
});
describe('non-globals', () => {
describe(`transform`, () => {
it(`__SERVER__ should NOT be replaced to true`, () => {
babel.transform(`
function foo(__SERVER__) {
console.log('this is a normal argument', __SERVER__)
}
`, {
plugins: [[plugin, {
__SERVER__: true,
__VERSION__: "v1.2.3"
}]]
}).code
.should.be.equal(`
function foo(__SERVER__) {
console.log('this is a normal argument', __SERVER__);
}`)
});
});
});
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