feat: support filename function#5957
Merged
ahabhgk merged 17 commits intoweb-infra-dev:mainfrom Mar 21, 2024
Merged
Conversation
branchseer
commented
Mar 15, 2024
Contributor
|
Thanks for the contribution! I will get you back when I'm free ;-) |
branchseer
commented
Mar 15, 2024
h-a-n-a
reviewed
Mar 18, 2024
h-a-n-a
reviewed
Mar 18, 2024
h-a-n-a
reviewed
Mar 18, 2024
h-a-n-a
reviewed
Mar 18, 2024
# 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
h-a-n-a
reviewed
Mar 20, 2024
# Conflicts: # crates/rspack_core/src/compiler/compilation.rs
Contributor
|
@ahabhgk Would you please help double check the API part at your convenience? |
h-a-n-a
previously approved these changes
Mar 20, 2024
Contributor
h-a-n-a
left a comment
There was a problem hiding this comment.
Thank you so much for the wonderful work you've done! We really appreciate your contribution ;-)
ahabhgk
reviewed
Mar 21, 2024
Contributor
ahabhgk
left a comment
There was a problem hiding this comment.
Generally looks good to me, one small nitpick
crates/rspack_plugin_runtime/src/runtime_module/get_chunk_filename.rs
Outdated
Show resolved
Hide resolved
Contributor
|
@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.
|
Contributor
Author
|
# Conflicts: # crates/rspack_plugin_library/src/assign_library_plugin.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
filenameto be a function in these places:output.filenameoutput.chunkFilenameoutput.cssFilenameoutput.cssChunkFilenamecompilation.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::renderdue to its return type changed fromStringtorspack_error::Result<String>(functions could throw).Other notable changes:
ByRefthat implementsHashandEqby js reference.This makes it possible for filename functions to be hashmap keys.
ThreadSafeFunctionWithRefthat can be called in the node thread without causing deadlocks.This is to avoid
Filename::renderbecomingasync. The reason I choose to makeFilename::renderblocking instead ofasyncisasyncwould 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.entryto be a function.In webpack tests, most tests for filename functions also defines
entryas function, not object. We have to support this to unlock them.Require Documentation?