Socket
Socket
Sign inDemoInstall

brackets-babel-module-formatter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brackets-babel-module-formatter - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

39

index.js

@@ -1,4 +0,10 @@

var util = require('babel-core/lib/util');
var t = require('babel-core/lib/types');
/* eslint-env node */
/* eslint no-unused-vars:[2, {"vars": "all", "args": "none"}] */
"use strict";
// var util = require("babel-core/lib/util");
var t = require("babel-core/lib/types");
var EXPORT_NAME = "__export__";
module.exports = ModuleFormatter;

@@ -11,6 +17,4 @@

// feel free to modify this however
// save the original body
var body = ast.body;
// put together params for the wrapper function

@@ -22,12 +26,14 @@ var params = [

];
// exports object
var exportObj = t.variableDeclaration("var", [t.variableDeclarator(t.identifier(EXPORT_NAME), t.objectExpression([]))]);
body.unshift(exportObj);
var moduleExports = t.memberExpression(t.identifier("module"), t.identifier("exports"));
var moduleExportsAssign = t.assignmentExpression("=", moduleExports, t.identifier(EXPORT_NAME));
body.push(t.expressionStatement(moduleExportsAssign));
// wrap the original body in a function
var container = t.functionExpression(null, params, t.blockStatement(body));
// make a define call with the wrapper body
var call = t.callExpression(t.identifier("define"), [container]);
// assign a new body to the ast
ast.body = [t.expressionStatement(call)];
};

@@ -43,8 +49,6 @@

var ref = t.callExpression(t.identifier("require"), [node.source]);
if (specifier.imported) {
ref = t.memberExpression(ref, specifier.imported);
}
nodes.push(t.variableDeclaration('var', [t.variableDeclarator(specifier.local, ref)]));
}
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(specifier.local, ref)]));
};

@@ -54,2 +58,6 @@

// node is an ExportDeclaration
if (node.declaration) {
var assign = t.assignmentExpression("=", t.identifier(EXPORT_NAME), node.declaration);
nodes.push(t.expressionStatement(assign));
}
};

@@ -60,2 +68,7 @@

// node is an ExportDeclaration
};
if (specifier.exported) {
var left = t.memberExpression(t.identifier(EXPORT_NAME), specifier.exported);
var assign = t.assignmentExpression("=", left, specifier.local);
nodes.push(t.expressionStatement(assign));
}
};
{
"name": "brackets-babel-module-formatter",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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