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

common-shakeify

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

common-shakeify - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

test/funny-exports/app.js

26

index.js

@@ -108,9 +108,21 @@ 'use strict'

if (node.type === 'AssignmentExpression') {
string.overwrite(node.start, node.right.start,
commentify(`${node.left.getSource()} =`) +
// Make sure we can't accidentally continue a previous statement.
// eg in `exports.a = [0]` the `[0]` could continue a previous statement if that
// did not have a semicolon. By putting `void ` in front we force a new statement.
(node.parent.type === 'ExpressionStatement' ? ' void ' : ' ')
)
var prefix = commentify(`${node.left.getSource()} =`) + ' '
// Make sure we can't accidentally continue a previous statement.
// eg in `exports.a = [0]` the `[0]` could continue a previous statement if that
// did not have a semicolon. By putting `void ` in front we force a new statement.
if (node.parent.type === 'ExpressionStatement') {
prefix += 'void '
}
// Anonymous function and class expressions are parsed as statements if they
// are the first thing in a statement, which can happen if the `exports.xyz`
// assignment happened inside a SequenceExpression (usually after minification).
// eg: `exports.a=function(){},exports.b=function(){}`
// Here if `exports.a` is removed we need to make sure the `function(){}` is still
// an expression, by prepending `void 0,` to result in:
// `void 0,function(){},exports.b=function(){}`
var isPossiblyAmbiguousExpression = node.right.type === 'FunctionExpression' || node.right.type === 'ClassExpression'
if (isPossiblyAmbiguousExpression && node.parent.type === 'SequenceExpression') {
prefix += 'void 0, '
}
string.overwrite(node.start, node.right.start, prefix)
return

@@ -117,0 +129,0 @@ } else if (node.type === 'Property') {

{
"name": "common-shakeify",
"version": "0.3.0",
"version": "0.3.1",
"description": "browserify tree shaking plugin using @indutny common-shake",

@@ -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