okikio / bundlejs

An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
https://bundlejs.com
MIT License
751 stars 13 forks source link

How to use? I'm confused. #27

Closed ghost closed 2 years ago

ghost commented 2 years ago

When I try to enter the following code and hit the "Build" button, I see no output.

import { initializeApp } from "@firebase/app"; import { getAnalytics } from "@firebase/analytics"; import { getAuth, onAuthStateChanged, GoogleAuthProvider, signOut } from "@firebase/auth"; import { getFirestore } from "@firebase/firestore";

Please help me.

okikio commented 2 years ago

You're importing a bunch of modules but you're not using any of them so bundlejs is treeshaking them out of the final bundle. What you need to do is to either use some of your imports of make all those imports exports, e.g.

export { initializeApp } from "@firebase/app";
export { getAnalytics } from "@firebase/analytics";
export { getAuth, onAuthStateChanged, GoogleAuthProvider, signOut } from "@firebase/auth";
export { getFirestore } from "@firebase/firestore";

The final result of switching to exports is Screenshot_20220602-131236_Kiwi Browser.jpg

(Open Bundle)(https://bundlejs.com/?q=@firebase/app,@firebase/analytics,@firebase/auth,@firebase/firestore&treeshake=[{+initializeApp+}],[{+getAnalytics+}],[{+getAuth,onAuthStateChanged,GoogleAuthProvider,signOut+}],[{+getFirestore+}])

ghost commented 2 years ago

Thanks for helping me!

But I would like to suggest, what if you add a feature to download the output as a file instead of copying it to the clipboard? because the code can't be copied if there are too many.

okikio commented 2 years ago

That's fair, I'll try to add that