Trimming Unused Dependencies via Package and Module Graphs

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing techniques for removing unused portions of applications, such as tree-shaking, often fail to accurately identify and eliminate dynamic dependencies, leading to incomplete removal and potential sharing issues between applications.

Innovation Solution

The use of package and module graphs to traverse and identify unused dependencies at compile time, allowing for precise inclusion or exclusion of dependencies in the application at deployment time, preserving module identity and eliminating the need for manual trimming.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Quantity of substance

If native compilers statically analyze libraries and eliminate uncalled code, then application size is reduced, but dynamic references cannot be handled and module identity is lost

Engineering Contradiction:
Improveapplication sizeVSAvoidhandling dynamic references
Core Design Contradiction:
Quantity of substanceVSAdaptability or versatility

Solution Approach 1:

The patent introduces an intermediary system that bridges static analysis and dynamic reference handling. Package graphs and module graphs serve as intermediary data structures that capture both static dependencies and dynamic reference patterns, allowing the compiler to make informed decisions about code elimination without losing module identity or breaking dynamic references.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The patent performs preliminary actions by constructing package graphs and module graphs before the actual tree-shaking process. These graphs pre-identify all potential dependencies including dynamic ones, so that when code elimination occurs, no critical dynamic references are accidentally removed. This preliminary analysis phase separates the identification of dependencies from the elimination process.

Inventive Principle:
Principle #10Preliminary action

2Measurement precision

If pre-compilers use heuristics to identify dynamic references, then some dynamic dependencies are found, but the heuristics are incomplete and require additional developer effort

Engineering Contradiction:
Improveidentification of dynamic referencesVSAvoidcomplexity of identifying all dynamic dependencies
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent segments the dependency analysis into two distinct graphs: package graphs for static package-level dependencies and module graphs for fine-grained module-level dependencies including dynamic references. This segmentation allows each graph to specialize in its domain, achieving comprehensive coverage without requiring a single complex heuristic system. The module graph specifically captures dynamic references that heuristics might miss.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent adds another dimension to dependency analysis by introducing the module graph layer beneath the package graph. While package graphs operate at one level of abstraction, the module graph provides a finer-grained dimension that captures module-level dynamic references. This dimensional addition enables precise identification of dynamic dependencies without overwhelming complexity.

Inventive Principle:
Principle #17Another dimension (Dimensionality change)

3Device complexity

If code is merged into a single module, then static analysis is simplified, but module identity is eliminated and sharing between applications is prevented

Engineering Contradiction:
Improvesimplicity of static analysisVSAvoidmodule sharing between applications
Core Design Contradiction:
Device complexityVSAdaptability or versatility

Solution Approach 1:

The patent maintains segmentation at the module level throughout the analysis and compilation process. Rather than merging all code into a single module, the system preserves module boundaries and uses the module graph to track dependencies between distinct modules. This segmentation enables both simplified analysis (through graph-based dependency tracking) and module identity preservation (for sharing and servicing outside applications).

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS10409567B2Trimming unused dependencies using package graph and module graph
Publication Date: 2019.09.10 MICROSOFT TECHNOLOGY LICENSING LLC
  • US10409567B2 patent drawing
  • US10409567B2 patent drawing
  • US10409567B2 patent drawing

AI summary

Techniques are described herein that are capable of trimming unused dependencies using a package graph and a module graph. For instance, the package graph and the module graph may be traversed to determine whether dependencies of an application are used during execution of the application. A version of the application may be configured to include the dependencies that are used and to not include the dependencies that are not used. For instance, the version of the application may be configured to be utilized at deployment time.