buddy
Advanced tools
Comparing version 6.14.0 to 6.14.1
@@ -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", |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
245216
6184
0
+ Addedbabel-helper-evaluate-path@0.2.0(transitive)
+ Addedbabel-helper-mark-eval-scopes@0.2.0(transitive)
+ Addedbabel-helper-remove-or-void@0.2.0(transitive)
+ Addedbabel-plugin-minify-dead-code-elimination@0.2.0(transitive)
+ Addedbrowserslist@2.3.2(transitive)
+ Addedcaniuse-db@1.0.30001612(transitive)
+ Addedcaniuse-lite@1.0.30001612(transitive)
+ Addedpostcss@6.0.9(transitive)
- Removedbabel-helper-mark-eval-scopes@0.1.1(transitive)
- Removedbabel-helper-remove-or-void@0.1.1(transitive)
- Removedbabel-plugin-minify-dead-code-elimination@0.1.7(transitive)
- Removedbrowserslist@2.3.1(transitive)
- Removedcaniuse-db@1.0.30001613(transitive)
- Removedcaniuse-lite@1.0.30001613(transitive)
- Removedpostcss@6.0.8(transitive)
Updatedbrowserslist@2.3.2
Updatedpostcss@6.0.9