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

Switch to Preconstruct #144

Merged
merged 1 commit into from
May 29, 2023
Merged

Switch to Preconstruct #144

merged 1 commit into from
May 29, 2023

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 28, 2023

Just a showcase PR since I truly think that it simplifies quite a bit here. Feel free to close it if you want to stick with Parcel (which is an excellent tool as well!)

A nice improvement here is that the size of the library went down:

npx terser old.js -c | gzip | wc -c // 1388
npx terser new.js -c | gzip | wc -c // 1015

That is 27% improvement!

@bvaughn
Copy link
Owner

bvaughn commented May 28, 2023

I like the bundled code more. It doesn't look like Preconstruct is generating any source-maps though (at least for the non type def files). Is that expected?

I guess the flip side of that is that the bundled code is a lot more readable and closer to the source to begin with, e.g.

// Parcel
class $6d6d4999e62b3ee0$export$e926676385687eaf extends (0, $8zHUo$react.Component) {

// Preconstruct
class ErrorBoundary extends react.Component {
// Parcel
$parcel$exportWildcard(module.exports, $6d6d4999e62b3ee0$exports);
$parcel$exportWildcard(module.exports, $4a61716688322eb0$exports);
$parcel$exportWildcard(module.exports, $3c4937b727a6fcfb$exports);
$parcel$exportWildcard(module.exports, $9e88dd86e0bb2944$exports);
$parcel$exportWildcard(module.exports, $faefaad95e5fcca0$exports);

// Preconstruct
exports.ErrorBoundary = ErrorBoundary;
exports.ErrorBoundaryContext = ErrorBoundaryContext;
exports.useErrorBoundary = useErrorBoundary;
exports.withErrorBoundary = withErrorBoundary;

@bvaughn
Copy link
Owner

bvaughn commented May 28, 2023

This seems like a more clear cut decision than bvaughn/react-resizable-panels#148. The only real downside is that I'd be moving away from an infra/setup that I've gotten familiar with for my OSS projects.

Props Cons

The Preconstruct bundle is more readable

The Preconstruct bundle size is ~27% smaller

No mangled React component names

Package exports syntax is unfamiliar to me

@bvaughn bvaughn merged commit b0f3cc4 into bvaughn:master May 29, 2023
3 checks passed
@bvaughn
Copy link
Owner

bvaughn commented May 29, 2023

Thank you! 🙇🏼

@bvaughn
Copy link
Owner

bvaughn commented May 29, 2023

Published as 4.0.8

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