-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Collect dynamicImports in plugins #217
feat: Collect dynamicImports in plugins #217
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files
☔ View full report in Codecov by Sentry. |
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
📢 Thoughts on this report? Let us know! |
Bundle ReportChanges will increase total bundle size by 1.12kB (0.02%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
Bundle ReportChanges will decrease total bundle size by 41.44kB (-1.49%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
packages/webpack-plugin/src/webpack-bundle-analysis/utils/processChunks.ts
Outdated
Show resolved
Hide resolved
packages/webpack-plugin/src/webpack-bundle-analysis/utils/processChunks.ts
Outdated
Show resolved
Hide resolved
packages/webpack-plugin/src/webpack-bundle-analysis/utils/processChunks.ts
Outdated
Show resolved
Hide resolved
@@ -7,19 +7,35 @@ export interface ProcessChunksArgs { | |||
|
|||
export const processChunks = ({ chunks, chunkIdMap }: ProcessChunksArgs) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that confused me - the chunkIdMap
input is mutated below in this function. What do you think about adding a comment, or renaming it to like <result|output|mutated>ChunkIdMap
or better yet, <result|output|mutated>UniqueIdsByChunkId
?
I personally find it nice when just reading the function signature to know what the inputs, outputs, and side effects could be at a glance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to add in a comment to provide more details.
return { | ||
id: chunk.id?.toString() ?? "", | ||
uniqueId: uniqueId, | ||
entry: chunk.entry, | ||
initial: chunk.initial, | ||
files: chunk.files ?? [], | ||
names: chunk.names ?? [], | ||
dynamicImports: dynamicImports, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this only goes 1 level deep for the chunk children. That seems right conceptually and simple - nice!
782a812
to
3600d3e
Compare
0ddd647
to
01a321f
Compare
Description
This PR adds the functionality in the base plugins to capture the "dynamic imports". A dynamic import is when a given asset has code that lazily loads code when executed. The reason why we're adding in this functionality now, is that we need the dynamic imports to better inform the end user of what JS will be loaded initially and potentionally eventually on their given endpoint as a part of codecov/engineering-team#2570.
Closes codecov/engineering-team#3034
Notable Changes
Chunk
type to includedynamicImports
field which is of typestring[]
rollup
andvite
plugins to grabdynamicImports
and assign to chunkswebpack
plugin to grabchildren
array and assign the associated assets to thedynamicImports
fieldwebpack
as the children array is an array of chunks and not assets