when SwcMinify true , firestore(firebase) cannot getting data on build and serve
See original GitHub issueWhat version of Next.js are you using?
12.0.4
What version of Node.js are you using?
16.13.0
What browser are you using?
chrome
What operating system are you using?
macOS
How are you deploying your application?
next start
Describe the Bug
i tried create next app , and set config next with swcMinify: true
when I use firebase-firestore to fetch data while dev is running smoothly.
but when i do build the result from firestore can be undefined
Expected Behavior
should result from build and dev produce the same
To Reproduce
import { useEffect } from "react";
import Link from "next/link";
import { initializeApp, getApps, getApp } from "firebase/app";
import { getFirestore, getDoc, doc } from "@firebase/firestore";
const app = !getApps().length
? initializeApp({})
: getApp();
const store = getFirestore(app);
export default function IndexPage() {
const testRequest = async () => {
try {
// if run with dev will run fine and will get result from firestore
// if run with build and start , it will only get undefined
const result = await getDoc(doc(store, "users", "testid"));
console.log("test result", { docSnap: result.data() });
} catch (error) {
console.log(error)
}
};
useEffect(() => {
testRequest();
}, []);
return (
<div>
Hello World.{" "}
<Link href="/about">
<a>About</a>
</Link>
</div>
);
}
//next-config.js
const config = {
swcMinify:true
};
module.exports = config;
sample when i run dev
sample when i run build start
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Get data with Cloud Firestore - Firebase
There are three ways to retrieve data stored in Cloud Firestore. Any of these methods can be used with documents, collections of documents,...
Read more >Next.js production: CANNOT READ DATA FROM FIRESTORE
So my firestore configuration is fine, the code is fine, and there's nothing wrong with the deployment server. Since there's nothing wrong with ......
Read more >Querying and filtering data | Firestore - Google Cloud
Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.
Read more >Next.js and Firebase Tutorial – How to Build an Evernote Clone
Next.js is a server-side rendering framework based on React, which is search engine ... Now, let's send our data to the Firebase Firestore....
Read more >Cloud Firestore | Flutter Firestore CRUD | Flutter Firestore Tutorial
We'll learn about cloud firestore. Learn CRUD operations in flutter firestore. Cloud Firestore is a realtime database provide by Firebase and learn how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@timneutkens can you check this out too? Seems to be another
swcMinify
issue. Does thenext@canary
release address this as well?This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.