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

babel-plugin-transform-define

Package Overview
Dependencies
Maintainers
27
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-define - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

6

CHANGELOG.md
# Changelog
## 2.0.1
* *Bug*: Support ES module identifiers [#69](https://github.com/FormidableLabs/babel-plugin-transform-define/pull/69), [#70](https://github.com/FormidableLabs/babel-plugin-transform-define/pull/70) (*[@jdlm-stripe][]*)
## 2.0.0 (2019-10-23)

@@ -81,1 +85,3 @@

Initial Release
[@jdlm-stripe]: https://github.com/jdlm-stripe

@@ -66,2 +66,24 @@ "use strict";

/**
* Checks if the given identifier is an ES module import
* @param {babelNode} identifierNodePath The node to check
* @return {boolean} Indicates if the provided node is an import specifier or references one
*/
const isImportIdentifier = (identifierNodePath) => {
const name = get(identifierNodePath, ["node", "name"]);
const containerType = get(identifierNodePath, ["container", "type"]);
if (containerType === "ImportDefaultSpecifier" || containerType === "ImportSpecifier") {
return true;
}
// Check if the identifier references a module import of the same name
const binding = identifierNodePath.scope.getBinding(name);
if (binding && binding.kind === "module") {
return true;
}
return false;
};
const memberExpressionComparator = (nodePath, value) => nodePath.matchesPattern(value);

@@ -83,2 +105,8 @@ const identifierComparator = (nodePath, value) => nodePath.node.name === value;

Identifier(nodePath, state) {
// Don't transform import idenifiers. This is meant to mimic webpack's
// DefinePlugin behavior.
if (isImportIdentifier(nodePath)) {
return;
}
processNode(state.opts, nodePath, t.valueToNode, identifierComparator);

@@ -85,0 +113,0 @@ },

2

package.json
{
"name": "babel-plugin-transform-define",
"description": "Babel plugin that replaces member expressions and typeof statements with strings",
"version": "2.0.0",
"version": "2.0.1",
"contributors": [

@@ -6,0 +6,0 @@ "Eric Baer <me@ericbaer.com> (https://github.com/baer)",

@@ -10,4 +10,4 @@ <h1 align="center">babel-plugin-transform-define</h1>

</a>
<a href='http://travis-ci.org/FormidableLabs/babel-plugin-transform-define'>
<img src='https://secure.travis-ci.org/FormidableLabs/babel-plugin-transform-define.svg?branch=master' />
<a href='http://travis-ci.com/FormidableLabs/babel-plugin-transform-define'>
<img src='https://travis-ci.com/FormidableLabs/babel-plugin-transform-define.svg?branch=master' />
</a>

@@ -14,0 +14,0 @@ </p>

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