-
-
Notifications
You must be signed in to change notification settings - Fork 543
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
refactor: move context dependency walk_expression
into create_context_dependency
#6963
Merged
ahabhgk
merged 11 commits into
web-infra-dev:main
from
CPunisher:fix/context-dependency
Jul 16, 2024
Merged
refactor: move context dependency walk_expression
into create_context_dependency
#6963
ahabhgk
merged 11 commits into
web-infra-dev:main
from
CPunisher:fix/context-dependency
Jul 16, 2024
Conversation
This file contains 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
github-actions
bot
added
the
release: bug fix
release: bug related release(mr only)
label
Jun 27, 2024
✅ Deploy Preview for rspack canceled.
|
CPunisher
force-pushed
the
fix/context-dependency
branch
from
June 28, 2024 03:51
daba9d5
to
3cdae65
Compare
h-a-n-a
previously approved these changes
Jun 28, 2024
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!
Do you need a double check? @ahabhgk |
ahabhgk
requested changes
Jun 28, 2024
crates/rspack_plugin_javascript/src/visitors/dependency/context_dependency_helper.rs
Outdated
Show resolved
Hide resolved
ahabhgk
force-pushed
the
fix/context-dependency
branch
from
July 16, 2024 06:33
85456ac
to
a9b393f
Compare
ahabhgk
changed the title
fix: align
refactor: move context dependency Jul 16, 2024
parser.walk_expression
to webpack, which put into context_dependency_helper
walk_expression
into create_context_dependency
github-actions
bot
removed
the
release: bug fix
release: bug related release(mr only)
label
Jul 16, 2024
ahabhgk
approved these changes
Jul 16, 2024
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
fix #6874
The cause of the problem is the direct walking of import call expression, which led to a conflict between the replacement generated by this walk and the replacement handled by ConstPlugin.
Webpack handles the import call expression in three cases:
TemplateLiteral: walk the parts with odd indices, see https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/dependencies/ContextDependencyHelpers.js#L151
Wrapped expr: process the inner expressions, see https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/dependencies/ContextDependencyHelpers.js#L218
Other cases: directly walk the import call expression, see https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/dependencies/ContextDependencyHelpers.js#L241
My solution is to use a visitor to traverse the expression and find the corresponding
Expr
forBasicEvaluatedExpressionVisitor
based on span. A better solution might be to add a reference to the correspondingExpr
forBasicEvaluatedExpressionVisitor
like webpack does. I tried this but couldn't resolve the lifetime issues.Checklist