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

chore: improve build #1432

Merged
merged 1 commit into from
Nov 19, 2024
Merged

Conversation

cyyynthia
Copy link
Contributor

This PR supersedes and closes #1102

It does not use the same approach as proposed in #1102 however; seeing the current v2 build uses preserveModules. However, because of how the SFC gets split in multiple virtual chunks this causes a lot of unwanted files to clutter the build making it larger than it needs to be.

The approach proposed in this PR mitigates it by using manualChunks to achieve the intended result of a 1:1 mapping between Vue files and the resulting JS files. A little hack has been introduced as well to properly name chunk files with the right file extension and without a hash.

Minification has been disabled: along with the drop of hashes the intent is to make eventual dependency patches less brittle (see last comment of #908 for a use-case). This is also yet-another-attempt at building with sourcemaps enabled 😄

Package size measurements: measured by running pnpm run build-only; du -sh dist in packages/core.

  • Current v2: 7.4M
  • This PR (no maps): 4.8M
  • This PR (w/ maps): 11M
  • #1102 chunking approach1 (no maps): 2.5M
  • #1102 chunking approach (w/ maps): 5.8M

Footnotes

  1. these numbers were obtained by replacing the manual chunking approach from this PR by the manual chunking approach used in build: improve support for code splitting, ditch umd, sourcemaps #1102. Does not include the more heavy-handed dual config approach for esm and cjs.

@zernonia
Copy link
Member

Yo @cyyynthia ! Thanks again for this! I totally understand the benefit of having sourceMap, however the thought of another additional 3mb for package size is still haunting me 😬

But seeing that react-aria is 16mb, I think we can get this baby in!

@cyyynthia
Copy link
Contributor Author

cyyynthia commented Nov 18, 2024

Well, to be fair given there isn't any mangling going on anymore I wouldn't find it horrible to not have source maps, in which case this PR saves 2.5MB!

I honestly don't have much opinion about whether the maps are important or not, I pretty much did it as I saw there was some demand 😅

I really do dig the concern for bundle size though! A lost art these days 💫

@zernonia zernonia merged commit 3efabe4 into unovue:v2 Nov 19, 2024
3 checks passed
@cyyynthia cyyynthia deleted the chore/build-improvements-v2 branch November 19, 2024 05:44
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.

2 participants