-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Port flatten task to v3 #6068
base: v-next
Are you sure you want to change the base?
Port flatten task to v3 #6068
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
hardhatTotal size of the bundle: List of dependencies (sorted by size)
|
@@ -68,6 +68,7 @@ | |||
"@types/debug": "^4.1.4", | |||
"@types/node": "^20.14.9", | |||
"@types/semver": "^7.5.8", | |||
"@types/toposort": "^2.0.7", |
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.
We have an implementation of topological sort, which we should reuse
beforeEach(() => { | ||
// Replace console.log and console.warn so we can assert on their output | ||
consoleLogBuffer.length = 0; | ||
consoleWarnBuffer.length = 0; | ||
|
||
console.log = (...args: unknown[]) => { | ||
consoleLogBuffer.push(args.join(" ")); | ||
}; | ||
console.warn = (...args: unknown[]) => { | ||
consoleWarnBuffer.push(args.join(" ")); | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
console.log = originalConsoleLog; | ||
console.warn = originalConsoleWarn; | ||
}); |
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.
Instead of doing this, the task action can accept these params
print = console.log,
warn = console.warn
which are not exposed to the CLI, nor hooked into it in any way.
Then, to test it, we just need to call the task action directly.
Also added a comment about this, but we already have an implementation of top sort.
Single task is the way to go. If we need to make something extensible, we can add hooks.
I guess it's fine for this case.
See the comments.
I think this is ok. |
This PR introduces an implementation for the
flatten
task. Both the implementation and the tests were ported and adapted from v2.Details to point out:
tsort
package was replaced bytoposort
, which has 30x weekly download count and specially, it's typed.FLATTEN
,GET_FLATTENED_SOURCE
,GET_FLATTENED_SOURCE_AND_METADATA
. I wasn't sure there was a need to define more than one task, so I went with this approach. Maybe I could move the printing (contract and warnings) to a separate one, in case just the flattened file and metadata need to be consumed by an external plugin.Closes #5647