-
Notifications
You must be signed in to change notification settings - Fork 6
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
[build-report] Optimise build-report to prevent memory hog over long running builds #148
base: master
Are you sure you want to change the base?
Conversation
inputs = []; | ||
outputs = []; | ||
entries = []; |
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.
do we prefer to do = []
or .length = 0
? (to use the same array, but clear it, like what we do with the sets .clear()
as we aren't redefining new ones with moduleIndex = new Set()
)
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 was using .length = 0
but I kind of found it a bit hacky and not super explicit.
From what I read online, it's seemingly the same performance either = []
or .length = 0
, so I went with the most explicit and comprehensible one.
// We know it's not a map, so we cast it. | ||
entryInputs.push(...(outputFound.inputs as Input[])); | ||
for (const input of outputFound.inputs as Input[]) { |
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.
why is the cast necessary here?
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.
In the case of sourcemaps, file.inputs
are Outputs
as sourcemaps are built out of both Output
and Input
type of files.
So since I'm checking it's not a sourcemaps earlier, I'm casting it to make the rest of code type error free.
Very much looking for a better way.
What and why?
Running a devserver with webpack/rspack would often (always) end up with a
RangerError: Maximum call stack size exceeded
error.How?
The
build-report
was filling arrays over and over, with each build increasing their size.Now the
build-report
cleans between builds, and keep state in a more efficient way (usingSet
andMap
).The indexation of modules doesn't log warnings anymore, we mitigate the previous duplication issues by merging differences into the previously indexed module.
Testing covers these changes and remain ✅