okikio/bundlejs

How to use? I'm confused.

Opened this issue · 3 comments

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.

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+}])

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.

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