Skip to content

feat: implement the rest branches in side effect detector#2009

Merged
IWANABETHATGUY merged 11 commits intorolldown:mainfrom
kermanx:feat/side-effect-detector-except-jsx
Aug 18, 2024
Merged

feat: implement the rest branches in side effect detector#2009
IWANABETHATGUY merged 11 commits intorolldown:mainfrom
kermanx:feat/side-effect-detector-except-jsx

Conversation

@kermanx
Copy link
Copy Markdown
Contributor

@kermanx kermanx commented Aug 17, 2024

This PR implements all unimplemented side effect detectors except the two JSX-related ones. The JSX-related expressions are not implemented because I am not sure should JSX calls be always considered pure (although this seems true in esbuild). Tests included.

@netlify
Copy link
Copy Markdown

netlify bot commented Aug 17, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 2b52612
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66c1970fe1c5a000086d8657

@kermanx kermanx changed the title feat: implement side effect detector for statements and expressions except JSX feat: implement the rest branches in side effect detector Aug 18, 2024
@IWANABETHATGUY
Copy link
Copy Markdown
Member

@kermanx
Copy link
Copy Markdown
Contributor Author

kermanx commented Aug 18, 2024

And for for*stmt, esbuild considering they all have side effects. evanw/esbuild@9c13ae1/internal/js_ast/js_ast_helpers.go#L2289-L2293

This PR has the same logic as Rollup's: for-in, for-of, for. Which one should we follow?

for, TaggedTemplateExpression:
evanw/esbuild@9c13ae1/internal/js_ast/js_ast_helpers.go#L2578-L2590

Yes, esbuild uses e.TagOrNil.Data == nil to exclude tagged template literal.

@IWANABETHATGUY
Copy link
Copy Markdown
Member

And for for*stmt, esbuild considering they all have side effects. evanw/esbuild@9c13ae1/internal/js_ast/js_ast_helpers.go#L2289-L2293

This PR has the same logic as Rollup's: for-in, for-of, for. Which one should we follow?

for, TaggedTemplateExpression:
evanw/esbuild@9c13ae1/internal/js_ast/js_ast_helpers.go#L2578-L2590

Yes, esbuild uses e.TagOrNil.Data == nil to exclude tagged template literal.

follow Esbuild. https://rollupjs.org/repl/?version=4.20.0&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QnNxdWFyZSU3RCUyMGZyb20lMjAnLiUyRm1hdGhzLmpzJyU1Q24lMkJzcXVhcmUlMjIlMkMlMjJpc0VudHJ5JTIyJTNBdHJ1ZSUyQyUyMm5hbWUlMjIlM0ElMjJtYWluLmpzJTIyJTdEJTJDJTdCJTIyY29kZSUyMiUzQSUyMk9iamVjdC5wcm90b3R5cGUudmFsdWVPZiUyMCUzRCUyMGZ1bmN0aW9uKHYpJTIwJTdCJTVDbiUyMCUyMGNvbnNvbGUubG9nKCd0ZXN0JyklNUNuJTIwJTIwcmV0dXJuJTIwMCUzQiU1Q24lN0QlNUNuJTVDbmxldCUyMGElMjAlM0QlMjAlN0IlN0QlM0IlNUNuJTJCJTdCJTdEJTVDbiU1Q25leHBvcnQlMjBjb25zdCUyMHNxdWFyZSUyMCUzRCUyMCU3QiU3RCU1Q24lMjIlMkMlMjJpc0VudHJ5JTIyJTNBZmFsc2UlMkMlMjJuYW1lJTIyJTNBJTIybWF0aHMuanMlMjIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTIyb3V0cHV0JTIyJTNBJTdCJTIyZm9ybWF0JTIyJTNBJTIyZXMlMjIlN0QlMkMlMjJ0cmVlc2hha2UlMjIlM0ElMjJzYWZlc3QlMjIlN0QlN0Q= It't not too hard to generate unsafe behavior in Rollup safest treeshaking.

I did not mean esbuild could avoid all unsafe scenarios, but it is much better. Also our goal is to pass 100% esbuild tests in the future.

Copy link
Copy Markdown
Member

@IWANABETHATGUY IWANABETHATGUY left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Aug 18, 2024
Merged via the queue into rolldown:main with commit ef084bf Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants