-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
🙋 Tree Shaking #392
Comments
I'm sorry to say, but since you're already constructing your own Asset & Bundle trees, it makes most sense (to me) that you create your own tree shaker. You have (nearly) all the info that you need to know, so why pass it off to another tool which is going to reconstruct another/similar tree, just to acquire the same info you already have. 🙃 |
+1 custom. If Parcel can treeshake with multiple cores, it would be a huge advantage over the competition. There are fairly huge limitations with the tools you mentioned @devongovett. The only way to overcome those limitations would be a custom implementation. The ability to treeshake multiple module patterns in one app is a huge problem that needs to be resolved by someone. |
source map 😄 |
It is worth waiting 😍 fighting ~ |
@davidnagli did you mean to close this? |
Whoops sorry!!!! |
waiting special |
Can't wait to see this implemented in Parcel |
+1, I'm trying Parcel for the first time & it is a great experience, the only issue I have is that my bundle sizes are singnificantly bigger than with Webpack (I'm talking 300kb no gzip production mode) |
@jsiebern I know that this doesn't solve the root-issue, but perhaps think about doing some code-splitting? You could potentially provide a better experience to your end-users if you split the codebase and pre-fetched in the background after the initial load? Plus, when tree-shaking is implemented, it's still a decent thing to have done. |
@Siyfion Unfortunately I'm shipping my code as part of a Wordpress plugin where every environment / url is totally different (and out of my control), code splitting won't work for me unfortunately Edit: Just tried it for the kicks, it seems that Parcel does not have any issues with changing urls, I'm impressed. I might stick with it then, I need to do some testing, thanks for the nudge :) |
One example of where tree shaking makes a lot of sense to work without could configuration is when using a library like lodash. lodash-es recently added the webpack 4 "side effects: false" in the package.json (not sure if it's released yet). |
To be completely honest @ConneXNL, tree shaking makes sense for almost every library. |
Just for reference, there is a pull request: #731. |
Any reason to not just use rollup? Also, if speed is a concern, one could potentially just do it when building for production. The lack of treeshaking is the only thing keeping me from using parcel for production projects. |
Also, even if treeshaking only was applied for packages that have a ‘module’ field in the package.json that still seems like a big improvement to me. |
Sure, I did get sending to rollup on build working at one point. It was really slow though. A 3s build to 15s is not acceptable IMO. Tree shaking is our next big area of focus. Hopefully we'll do some experimentation and come up with something good over the next few weeks. 😄 |
Does this issue respect css treeshaking as well already? |
See #1104, where scope hoisting is being discussed/implemented. You can check the scope-hoist branch to follow along with our progress! |
If it's a production build - maybe it is? It could be an optional parameter. I can accept a 15s build on CI, so long as my devzone builds remain lightning-quick. |
Being used to compiling C++ with LTO opts, minutes wouldn't be a problem for production builds. It's only in dev where the speed really is needed imo. Tests take a whole lot more time to run through any way. |
Goddamn I love parcel. - my mind was fucking blown when I saw it install the missing dependencies. Anyways ontopic : I personally think using parcel for prod would be a big tradeoff though since not everyone's prod requirements are the same - like me, some people are optimization freaks - maybe parcel can optionally accept custom configs? It's prod anyways, I sincerely think this is the right spot to introduce optional webpack-level configurability. Oh parcel <3 |
Tree shaking is now merged in v1.9.0! 🚀 You can try it out with the Read more about how it works here: https://medium.com/@devongovett/parcel-v1-9-0-tree-shaking-2x-faster-watcher-and-more-87f2e1a70f79 |
|
@goyney make sure you're running the latest version 😉 |
Definitely on 1.9.0. |
If you are on 1.9.0, the output of If it's not, then it's likely that you have installed 1.9.0 locally for the repo, but are running the command with a global installation of parcel from earlier. Try adding |
Stupid me, I left out the word |
It seems Parcel 1.9.0 only accepts |
We should add tree shaking to Parcel in production mode so we have smaller bundle sizes. Because this requires cross-file optimizations, it will be harder to do with Parcel's parallel architecture. This basically means that tree-shaking must be done in a Packager.
There are a few approaches we could take:
Goals we should aim for:
sideEffects: false
option inpackage.json
to enable us to not parse or include all code that is imported but not used.Would love to hear some feedback on this, and if you have ideas on how we should implement this or features we should support please comment below! 😍
The text was updated successfully, but these errors were encountered: