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

Integrate zephyr dead code elimination #158

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andys8
Copy link
Contributor

@andys8 andys8 commented Sep 18, 2020

Hi,

I wanted to see how much effect zephyr dead code elimination would have on a production build. It shaved of ~ 80 kb (gzipped) / 535 kb (zipped) / 50+ % (if I'm not mistaken).

So I'm sold on trying to integrate it in the build. Here is a draft PR, that shows the current integration.

If you want to give it a try, there is a pre-compiled branch and you can use it like this in package.json:

    "purs-loader": "andys8/purs-loader#poc/zephyr-build",

Discussion

I've still open questions. That's why this is a draft.

  • The README says there is already dead code elimination. Can you provide details what is meant?
  • This needs to be integrated into bundle. I'm not using bundle so far, because it will fail resolving TypeScript/Assets for me. It should be done. I can't test it.
  • What details are missing for documentation?
  • I'm currently re-using the configured output directory both for the compile and zephyr step. This avoids created a temporary folder. It seems to work fine for me. Could this lead to issues?

Issues

Closes #143

@toastal
Copy link

toastal commented Feb 11, 2021

I opened a PR to this branch moving package.json's main to "src/index.js". This allowed me to use this fork via git+https, and by using this zephyr option, it cut the size of my output by about 50%.

@toastal
Copy link

toastal commented Feb 11, 2021

Usually zephyr's output goes to dce-output. I'm not sure if about your last comment either though.

@toastal
Copy link

toastal commented Apr 20, 2021

I did run across a big issue with this recently though: you can only have one entry point. Zephyr allows you can pass in multiple files to make sure you don't dead-code-eliminate code for your other entries. Unless I missed something, this fork doesn't collect all of the imported entries and then run the DCE. I decided to drop the module all together and require() from the appropriate /output/ or /dce-output/ folder per process.env.NODE_ENV (similar to how many projects suggest using with Parcel).

point main to the index in src
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 this pull request may close these issues.

Add a step that runs zephyr
2 participants