Socket
Socket
Sign inDemoInstall

buddy

Package Overview
Dependencies
274
Maintainers
2
Versions
180
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.14.0 to 6.14.1

103

lib/config/buildPlugins.js

@@ -50,8 +50,7 @@ 'use strict';

];
const BABEL_PRESET_COMPRESS = [];
const BABEL_PRESET_COMPRESS = [['babel-plugin-minify-dead-code-elimination', { keepFnArgs: true, keepFnName: true }]];
const POSTCSS_PRESET_COMPRESS = ['cssnano'];
const BABEL_PRESET_DEFAULT = [
'babel-plugin-external-helpers',
['babel-plugin-transform-es2015-modules-commonjs', { loose: true, strictMode: false }],
['babel-plugin-minify-dead-code-elimination', { keepFnArgs: true, keepFnName: true }]
['babel-plugin-transform-es2015-modules-commonjs', { loose: true, strictMode: false }]
];

@@ -161,54 +160,51 @@ const POSTCSS_PRESET_DEFAULT = [];

// Add plugins based on version presets
plugins = version.reduce(
(plugins, preset) => {
let presetPlugins;
plugins = version.reduce((plugins, preset) => {
let presetPlugins;
if ('string' == typeof preset) {
preset = preset.toLowerCase();
// Ignore generic
if (RE_GENERIC_VERSION.test(preset)) return plugins;
// Skip if babel version and type is postcss
if (type == 'postcss' && preset in allPlugins.babel) return plugins;
if ('string' == typeof preset) {
preset = preset.toLowerCase();
// Ignore generic
if (RE_GENERIC_VERSION.test(preset)) return plugins;
// Skip if babel version and type is postcss
if (type == 'postcss' && preset in allPlugins.babel) return plugins;
presetPlugins = allPlugins[type][preset];
// Try and parse with browserslist if no match
if (!presetPlugins) preset = { browsers: [preset] };
}
presetPlugins = allPlugins[type][preset];
// Try and parse with browserslist if no match
if (!presetPlugins) preset = { browsers: [preset] };
}
// Handle object ({ chrome: 5 }, { browsers: ['last 3'] })
if (!presetPlugins && 'string' != typeof preset) {
const key = Object.keys(preset)[0];
const value = preset[key];
// Handle object ({ chrome: 5 }, { browsers: ['last 3'] })
if (!presetPlugins && 'string' != typeof preset) {
const key = Object.keys(preset)[0];
const value = preset[key];
if (key == 'browsers' && Array.isArray(value)) {
if (type == 'postcss') {
// Add Autoprefixer and pass-through
presetPlugins = [['autoprefixer', preset]];
} else if (type == 'babel') {
try {
// Add Babel plugins based on Autoprefixer-style config
presetPlugins = resolvePluginsForBrowsers(
browserslist(value).map(browser => {
const [name, version] = browser.split(' ');
if (key == 'browsers' && Array.isArray(value)) {
if (type == 'postcss') {
// Add Autoprefixer and pass-through
presetPlugins = [['autoprefixer', preset]];
} else if (type == 'babel') {
try {
// Add Babel plugins based on Autoprefixer-style config
presetPlugins = resolvePluginsForBrowsers(
browserslist(value).map(browser => {
const [name, version] = browser.split(' ');
return { [name]: version };
})
);
} catch (err) {
/* invalid browserslist value */
}
return { [name]: version };
})
);
} catch (err) {
/* invalid browserslist value */
}
} else {
// See if concated key+value exists already
presetPlugins = allPlugins[type][(key + value).toLowerCase()] ||
(type == 'babel' && resolvePluginsForBrowsers(preset));
}
} else {
// See if concated key+value exists already
presetPlugins =
allPlugins[type][(key + value).toLowerCase()] || (type == 'babel' && resolvePluginsForBrowsers(preset));
}
}
if (!presetPlugins) warn(`unable to resolve plugins for ${strong(preset)} version`, 1);
if (!presetPlugins) warn(`unable to resolve plugins for ${strong(preset)} version`, 1);
return unique(plugins.concat(presetPlugins || []));
},
plugins
);
return unique(plugins.concat(presetPlugins || []));
}, plugins);

@@ -259,13 +255,10 @@ // Add compression plugins

if (Array.isArray(items)) {
items.reduce(
(dependencies, item) => {
// Items can be Array with depedency as first param
const dep = Array.isArray(item) ? item[0] : item;
items.reduce((dependencies, item) => {
// Items can be Array with depedency as first param
const dep = Array.isArray(item) ? item[0] : item;
// Only gather string references, not functions/modules
if ('string' == typeof dep) dependencies.push(dep);
return dependencies;
},
dependencies
);
// Only gather string references, not functions/modules
if ('string' == typeof dep) dependencies.push(dep);
return dependencies;
}, dependencies);
}

@@ -272,0 +265,0 @@ }

'use strict';
const types = require('babel-types');
/**

@@ -17,2 +19,3 @@ * Identifier visitor to namespace all declarations in root scope,

// Make sure any dynamic declarations are declared (_this, _require, etc)
if (name in rootScope.uids) {

@@ -28,3 +31,3 @@ path.getFunctionParent().scope.registerDeclaration(parent);

if (opts.replace && (name == 'module' || name == 'exports')) {
if (opts.replace && (name === 'module' || name === 'exports')) {
replaceModuleExports(path, opts.source.moduleExports);

@@ -67,4 +70,5 @@ } else if (!name.includes(opts.source.namespace) && !name.includes(opts.source.moduleExports)) {

const rootScope = scope.getProgramParent();
const binding = scope.getBinding(oldName);
const isRootScope = scope === rootScope;
const newName = `${namespace}${oldName}`;
let binding = scope.getBinding(oldName);

@@ -74,2 +78,10 @@ if (binding) {

path.node.name = newName;
if (!isRootScope) {
const declarationParent = getDeclarationParent(path);
// Function declaration defines own scope, so switch to parent
if (declarationParent.isFunctionDeclaration()) {
binding = declarationParent.scope.parent.getBinding(oldName);
}
}
// Handle references

@@ -86,29 +98,2 @@ if (binding.referenced) {

/**
* Retrieve declaration parent for 'path'
* @param {NodePath} path
* @returns {NodePath}
*/
function getDeclarationParent(path) {
do {
if (
path.isFunctionDeclaration() ||
path.isVariableDeclaration() ||
path.isClassDeclaration() ||
path.isAssignmentExpression()
) {
return path;
}
} while ((path = path.parentPath));
}
/**
* Determine if 'path' is an key or property of another object
* @param {NodePath} path
* @returns {Boolean}
*/
function isPropertyOrKey(path) {
return path.parentPath.get('key') === path || path.parentPath.get('property') === path;
}
/**
* Determine if declaration 'path' should be renamed

@@ -156,1 +141,28 @@ * @param {String} name

}
/**
* Retrieve declaration parent for 'path'
* @param {NodePath} path
* @returns {NodePath}
*/
function getDeclarationParent(path) {
do {
if (
path.isFunctionDeclaration() ||
path.isVariableDeclaration() ||
path.isClassDeclaration() ||
path.isAssignmentExpression()
) {
return path;
}
} while ((path = path.parentPath));
}
/**
* Determine if 'path' is an key or property of another object
* @param {NodePath} path
* @returns {Boolean}
*/
function isPropertyOrKey(path) {
return path.parentPath.get('key') === path || path.parentPath.get('property') === path;
}

@@ -23,3 +23,3 @@ 'use strict';

const RE_BUDDY_BUILT = /^\/\*\* BUDDY BUILT \*\*\//;
const RE_TRANSPILE = /process\.env|\bconst |\blet |\b=>\b/g;
const RE_TRANSPILE = /\bconst |\blet |\b=>\b/g;
const RE_STRICT = /'use strict';?\s?/g;

@@ -97,3 +97,3 @@ // Browserify, closure compiler, webpack, etc

: false;
// Transpile all non-npm modules unless module looks like es6 or has process.env.* that may require DCE
// Transpile all non-npm modules unless module looks like es6
RE_TRANSPILE.lastIndex = 0;

@@ -100,0 +100,0 @@ this.shouldTranspile = this.isNpmModule ? RE_TRANSPILE.test(this.content) : true;

{
"name": "buddy",
"description": "A fast, simple build tool for web projects.",
"version": "6.14.0",
"version": "6.14.1",
"author": "popeindustries <alex@pope-industries.com>",

@@ -22,5 +22,5 @@ "keywords": [

"babel-plugin-external-helpers": "6.22.0",
"babel-plugin-minify-dead-code-elimination": "0.1.7",
"babel-plugin-minify-dead-code-elimination": "0.2.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.24.1",
"browserslist": "2.3.1",
"browserslist": "2.3.2",
"buddy-cli": "6.1.0",

@@ -36,3 +36,3 @@ "chalk": "2.1.0",

"portscanner": "2.1.1",
"postcss": "6.0.8",
"postcss": "6.0.9",
"pretty-bytes": "4.0.2",

@@ -39,0 +39,0 @@ "recur-fs": "2.2.4",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc