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

Lighter bundles with no-side-effect #5560

Closed
dubzzz opened this issue Dec 26, 2024 · 4 comments · Fixed by #5771
Closed

Lighter bundles with no-side-effect #5560

dubzzz opened this issue Dec 26, 2024 · 4 comments · Fixed by #5771

Comments

@dubzzz
Copy link
Owner

dubzzz commented Dec 26, 2024

Not a game changer but always better to target a lighter bundle. We could try to look at fabian-hiller/valibot#995

@TomerAberbach
Copy link
Contributor

Not sure if you're using rollup or not, but I wrote a rollup plugin that automatically "pure" annotates all top-level constructs that could be interpreted by bundlers as effectful

I've been using it with some of my libraries to make them fully tree shakeable. You can see these annotations in the bundled source of lfi, which supports tree-shakeability well as a result.

@dubzzz
Copy link
Owner Author

dubzzz commented Dec 26, 2024

So far, I'm not using any real bundler to bundle fast-check. But I might one day.

The whole target of this issue is to analyze whether or not I can make users' life better if they pull fast-check in their bundles. That said I don't know why they would do that.

Copy link

stale bot commented Feb 25, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 25, 2025
@dubzzz dubzzz removed the stale label Feb 26, 2025
@dubzzz
Copy link
Owner Author

dubzzz commented Mar 1, 2025

By using the example provided against valibot in fabian-hiller/valibot#995 and replacing by fast-check I confirm that we can save a bit of tree-shaking by toggling on the flag on each of our publicly exposed functions. But for now, it means that we would have to re-enable comments in published code and will have to increase the bundle size.

dubzzz added a commit that referenced this issue Mar 1, 2025
dubzzz added a commit that referenced this issue Mar 1, 2025
**Description**

<!-- Please provide a short description and potentially linked issues
justifying the need for this PR -->

Fixes #5560

So far we did it via a post build script as we strip comments in the
build process configured with tsc.

Results: [here](https://stackblitz.com/edit/node-m2wqwvcg).

<!-- * Your PR is fixing a bug or regression? Check for existing issues
related to this bug and link them -->
<!-- * Your PR is adding a new feature? Make sure there is a related
issue or discussion attached to it -->

<!-- You can provide any additional context to help into understanding
what's this PR is attempting to solve: reproduction of a bug, code
snippets... -->

**Checklist** — _Don't delete this checklist and make sure you do the
following before opening the PR_

- [x] The name of my PR follows [gitmoji](https://gitmoji.dev/)
specification
- [x] My PR references one of several related issues (if any)
- [x] New features or breaking changes must come with an associated
Issue or Discussion
- [x] My PR does not add any new dependency without an associated Issue
or Discussion
- [x] My PR includes bumps details, please run `pnpm run bump` and flag
the impacts properly
- [x] My PR adds relevant tests and they would have failed without my PR
(when applicable)

<!-- More about contributing at
https://github.com/dubzzz/fast-check/blob/main/CONTRIBUTING.md -->

**Advanced**

<!-- How to fill the advanced section is detailed below! -->

- [ ] Category: ...
- [ ] Impacts: ...

<!-- [Category] Please use one of the categories below, it will help us
into better understanding the urgency of the PR -->
<!-- * ✨ Introduce new features -->
<!-- * 📝 Add or update documentation -->
<!-- * ✅ Add or update tests -->
<!-- * 🐛 Fix a bug -->
<!-- * 🏷️ Add or update types -->
<!-- * ⚡️ Improve performance -->
<!-- * _Other(s):_ ... -->

<!-- [Impacts] Please provide a comma separated list of the potential
impacts that might be introduced by this change -->
<!-- * Generated values: Can your change impact any of the existing
generators in terms of generated values, if so which ones? when? -->
<!-- * Shrink values: Can your change impact any of the existing
generators in terms of shrink values, if so which ones? when? -->
<!-- * Performance: Can it require some typings changes on user side?
Please give more details -->
<!-- * Typings: Is there a potential performance impact? In which cases?
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants