firebase-framework-tools
firebase-framework-tools copied to clipboard
Dependencies of n[e|u]xt.config.js are not included in the Cloud Function
Seems like the autogenerated function may be ignoring deps from the next config file.
Error:
Error: Cannot find module './next-i18next.config'
Require stack:
- MYSITE/.firebase/MYPROJECT/functions/next.config.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.mod._resolveFilename (MYSITE/.firebase/MYPROJECT/functions/node_modules/next/dist/build/webpack/require-hook.js:183:28)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (MYSITE/.firebase/MYPROJECT/functions/next.config.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
next.config.js:
const path = require('path');
const {i18n} = require('./next-i18next.config');
const nextConfig = {
distDir: 'build',
i18n: i18n,
};
module.exports = nextConfig;
Great feedback! Thanks. We should test for dependencies of this file and pack them into the cloud function.
Plan of action: rather than just copying during the build step, we should webpack (or equivalent) the next.config.js. Mark all NPM prod dependencies as external and output file to .firebase/SITE/functions/next.config.json
We should do the same for Nuxt.
This has been addressed in the latest version of the tooling https://firebase.google.com/docs/hosting/nextjs