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

Swap mainfields in build script #2751

Merged
merged 1 commit into from Mar 21, 2022
Merged

Swap mainfields in build script #2751

merged 1 commit into from Mar 21, 2022

Conversation

ekwoka
Copy link
Contributor

@ekwoka ekwoka commented Mar 15, 2022

This reduces the build size of the AlpineJS module by ~20%

AlpineJS
Before: 112kb
After: 87kb

Focus Plugin:
Before: 32kb
After: 28kb

I've used a variation of this build myself on projects for a while now and have yet to see any actual issues in browser or with bundlers.

This reduces the build size of the module by ~20%
@calebporzio
Copy link
Collaborator

Interesting, here are my result before and after this change (there is no build size difference)
Before:
image

After:
image

Can you clarify what you're going for here and why it makes the bundle smaller? Of course I always love making the bundle smaller!

@ekwoka
Copy link
Contributor Author

ekwoka commented Mar 17, 2022

@calebporzio

Yes, that is because your build size report reports on the minified CDN size.

Not the esm module.

I should have clarified, but these sizes reported are the size of the output esm.js.

So those importing the project without using the CDN would be affected.

Naturally, the sizes shown are exaggerated from the esm not being minified, but it's still extra stuff.

I believe the cause is because esbuild is adding more code to allow it to import cjs packages (the main field) instead of using the available modules.

I don't know enough about what esbuild does, but diffing the two shows a lot of code for compatibility that doesn't exist in the CDN.

@calebporzio
Copy link
Collaborator

Ok, fair enough. Thanks for the explanation!

@calebporzio calebporzio merged commit 0d1731b into alpinejs:main Mar 21, 2022
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.

None yet

2 participants