-
Notifications
You must be signed in to change notification settings - Fork 471
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: support filename function #5957
Conversation
Thanks for the contribution! I will get you back when I'm free ;-) |
# Conflicts: # crates/rspack_plugin_devtool/src/lib.rs
# Conflicts: # Cargo.lock # crates/rspack_core/src/compiler/compilation.rs
# Conflicts: # crates/rspack_core/src/compiler/compilation.rs # crates/rspack_plugin_devtool/src/lib.rs
# Conflicts: # crates/rspack_plugin_devtool/src/lib.rs
# Conflicts: # crates/rspack_core/src/compiler/compilation.rs
@ahabhgk Would you please help double check the API part at your convenience? |
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.
Thank you so much for the wonderful work you've done! We really appreciate your contribution ;-)
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.
Generally looks good to me, one small nitpick
crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs
Outdated
Show resolved
Hide resolved
@branchseer you can add document change in this pr, since we have moved the website repo into rspack repo |
👷 Deploy request for rspack pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for rspack-back canceled.
|
|
# Conflicts: # crates/rspack_plugin_library/src/assign_library_plugin.rs
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.
Thanks!
Summary
Allow
filename
to be a function in these places:output.filename
output.chunkFilename
output.cssFilename
output.cssChunkFilename
compilation.getPath(filename, data)
compilation.getPathWithInfo(filename, data)
compilation.getAssetPath(filename, data)
compilation.getAssetPathWithInfo(filename, data)
Fixes #3483.
Most changed files in the PR are refactoring (in)direct callers of
Filename::render
due to its return type changed fromString
torspack_error::Result<String>
(functions could throw).Other notable changes:
ByRef
that implementsHash
andEq
by js reference.This makes it possible for filename functions to be hashmap keys.
ThreadSafeFunctionWithRef
that can be called in the node thread without causing deadlocks.This is to avoid
Filename::render
becomingasync
. The reason I choose to makeFilename::render
blocking instead ofasync
isasync
would infect all the (in)direct callers, and require much more refactors than changing the return type. I don't think that's worth the effort since js filename functions are usually very lightweight.entry
to be a function.In webpack tests, most tests for filename functions also defines
entry
as function, not object. We have to support this to unlock them.Require Documentation?