[NextJS Functions] zip size - issue!

Hello! I’m facing a few problems:
1. If I set my next.config.js target: “experimental-serverless-trace” to “serverless” the zip size is great (around half) but I get this when trying to render a page with serverSideProps:

"{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '@grpc/grpc-js/package.json'\nRequire stack:\n- /opt/build/repo/node_modules/@firebase/firestore/dist/index.node.mjs","trace":["Runtime.ImportModuleError: Error: Cannot find module '@grpc/grpc-js/package.json'","Require stack:","- /opt/build/repo/node_modules/@firebase/firestore/dist/index.node.mjs"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}

import ProductCard from '@components/ProductCard';
import { getProducts } from '@utils/products'

const Products = ({ products }) => {
  return (
    <div>
      <h1>All Results</h1>
      <p>Our Products:</p>
      <div>
        {products.map((product) => (
          <ProductCard key={product.id} product={product} />
        ))}
      </div>
    </div>
  );
};

export default Products;

export async function getServerSideProps({locale, params}){
  //This functions calls Firebase and gets multiple documents and adds it to an array
  let products = await getProducts();

  return {
    props: {
      products
    }
  }
}

2. I’ve also tried to change on netlify.toml (node_bundler= “esbuild”) which helps on the size, but the only way to make it work is to add way too many “external_node_modules” making it also a really big zip. Otherwise I have the same error as above. Also, images don’t seem to load.

Nothing of this happens on my dev environment. Not sure even how to properly test it without constantly deploying.

The only way I have found to fix it is by using the configs below but some of my zips are already at 50mb, which is close to creating issues again.

module.exports = {
  target: "experimental-serverless-trace"
}

and

[functions."next_*"]
  node_bundler = "zisi"

Any support would be really appreciated, have been hitting the wall for way too many hours. Thank you!

Any idea how to help? :slight_smile:

Hey there, @pertoi :wave:

Thanks so much for your patience here, and sorry to hear you have hit a wall! Can you please share your site name and your repo?

Additionally, you can attempt testing using: GitHub - netlify/build-image: This is the build image used for running automated builds there is documentation about how to run locally!