Skip to content
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

Dead code elimination on client #12992

Draft
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

StorytellerCZ
Copy link
Collaborator

Based on #10056 and related to #11164

Heard about this recently and I think this could help a little, so I have decided to revive the code.
I would like to hear what people think and how we can make this better.

@zodern
Copy link
Member

zodern commented Feb 7, 2024

I think this comment still applies - #10056 (comment)
It really should work on the AST instead of using a regex.

Instead of doing it in the minifier, it might be better to do it as either part of the import scanner, or in the babel-compiler package. This way Meteor would also ignore any imports in the removed code. The import scanner would work in more situations but be more difficult to optimize - I was planning to redesign how its caching works to support this, but I probably won't have time in the near future.

@jamauro
Copy link
Contributor

jamauro commented Feb 8, 2024

This would be applied to the final bundle right?

If so, could this be viewed as an interim solution until a better solution materializes or the tree shaking pr is merged? Would be great to have Meteor.isServer code removed from the client bundle.

Even if it were opt in only, I think it would be beneficial. It could always be removed when a better solution is ready.

I suppose it also depends on when the tree shaking pr could be conceivably merged. At this point, I'm assuming that's still a ways off given all the Meteor 3 work, but maybe that's a bad assumption and it's right around the corner 🤞.

@StorytellerCZ
Copy link
Collaborator Author

@zodern point well taken, still I'm with @jamauro on this. Once I get around to this again, I will try to add a flag that can turn this on and off and we can turn this off by default until we have a better solution so this could be an interim solution for people who need it or want to experiment with this. Thoughts?

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.

None yet

3 participants