Skip to content

[11.2.x] perf(@ngtools/webpack): avoid adding transitive dependencies to Webpack's dependency graph #20247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

clydin
Copy link
Member

@clydin clydin commented Mar 11, 2021

This change augments a TypeScript Compiler Host's resolveModuleNames function to collect dependencies of the containing file based on the module names passed to the resolveModuleNames function. This process assumes that consumers of the Compiler Host will call resolveModuleNames with modules that are actually present in a containing file. The TypeScript compiler exhibits such behavior making this process effective at generating a set of all direct dependencies for a given source file.
This process is a workaround for gathering a TypeScript SourceFile's dependencies as there is no currently exposed public method to do so. A BuilderProgram does have a getAllDependencies function. However, that function returns all transitive dependencies as well which can cause excessive Webpack rebuilds especially in larger programs.

11.2.x version of #20236

…ck's dependency graph

This change augments a TypeScript Compiler Host's resolveModuleNames function to collect dependencies of the containing file based on the module names passed to the resolveModuleNames function. This process assumes that consumers of the Compiler Host will call resolveModuleNames with modules that are actually present in a containing file.  The TypeScript compiler exhibits such behavior making this process effective at generating a set of all direct dependencies for a given source file.
This process is a workaround for gathering a TypeScript SourceFile's dependencies as there is no currently exposed public method to do so. A BuilderProgram does have a `getAllDependencies` function. However, that function returns all transitive dependencies as well which can cause excessive Webpack rebuilds especially in larger programs.
@clydin clydin added the target: patch This PR is targeted for the next patch release label Mar 11, 2021
@clydin clydin requested a review from alan-agius4 March 11, 2021 11:16
@google-cla google-cla bot added the cla: yes label Mar 11, 2021
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 11, 2021
@alan-agius4 alan-agius4 merged commit cc9be1c into angular:11.2.x Mar 11, 2021
@clydin clydin deleted the webpack-plugin/dep-perf-11.2.x branch March 11, 2021 12:07
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants