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

babel-dead-code-elimination

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-dead-code-elimination - npm Package Versions

1.0.6

Diff

Changelog

Source

1.0.6

Patch Changes

  • d4690c2: Do not eliminate empty object/array pattern function parameters

    Function parameters are not dead code

pcattori
published 1.0.5 •

Changelog

Source

1.0.5

Patch Changes

  • 3cf19e5: Fix: do not check function expressions for referenced variables

    Function expressions do not add their names to outer scopes

  • 5149b08: Do not eliminate arrow expressions

    Arrow expressions do not add names to the outer scope. Arrow expressions bound to names via variable declarators are already handled by VariableDeclarator visitor.

  • 86af914: Do not eliminate unreferenced variables from array patterns and object patterns when they do not match the provided candidates

    Previously, the candidates were passed in to deadCodeElimination were not consulted when removing unreferenced variables from within patterns. This was a bug and has now been fixed.

pcattori
published 1.0.4 •

Changelog

Source

1.0.4

Patch Changes

  • ade9eee: Fix: do not eliminate function expressions

    Function expressions do not add their names to outer scope, so they should never be dead code eliminated

pcattori
published 1.0.3 •

Changelog

Source

1.0.3

Patch Changes

  • ce456b5: Fix referenced variable finding within object patterns and array patterns
pcattori
published 1.0.2 •

Changelog

Source

1.0.2

Patch Changes

  • bd5e331: Fix elimination for object patterns and array patterns

    Previously, running dead code elimination on object patterns and array patterns (aka destructuring) was brittle. For example:

    const {
      a: { b: c },
    } = z
    console.log(c)
    

    Dead code elimination used to incorrectly remove the entire variable declaration even though c is referenced:

    -const {
    -  a: { b: c },
    -} = z
     console.log(c);
    

    This was caused by erroneous detection of a and b as unreferenced variables. But a and b are not variables, they are object property keys. Only c is a variable and it is referenced.

    This is now corrected so that variables in object patterns and array patterns are detected only within values of object properties. This also correctly accounts for cases where the key and value are the same for example { a }.

pcattori
published 1.0.1 •

Changelog

Source

1.0.1

Patch Changes

  • c2d0e23: Provide main and module fields in package.json for older bundlers
pcattori
published 1.0.0 •

Changelog

Source

1.0.0

Major Changes

  • 8264d19: Initial release

    deadCodeElimination

    Eliminates unused code from the Babel AST by repeatedly removing unreferenced identifiers.

    deadCodeElimination(ast)
    

    findReferencedIdentifiers

    Find identifiers that are currently referenced in the Babel AST.

    Useful for limiting deadCodeElimination to only eliminate newly unreferenced identifiers, as a best effort to preserve any intentional side-effects in the source.

    let ast = parse(source, { sourceType: "module" })
    let referenced = findReferencedIdentifiers(ast)
    
    traverse(ast, {
      /* ... your custom transform goes here ... */
    })
    
    deadCodeElimination(ast, referenced)
    
pcattori
published 0.0.0 •

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