Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firebase): use nodejs 18 as default runtime #925

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/content/2.deploy/providers/firebase.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Firebase
description: 'Discover Firebase preset for Nitro!'
description: "Discover Firebase preset for Nitro!"
---

**Preset:** `firebase` ([switch to this preset](/deploy/#changing-the-deployment-preset))
Expand Down Expand Up @@ -45,6 +45,7 @@ yarn global add firebase-tools
npm install -g firebase-tools
```

**Note**: You need to be on [^11.18.0](https://github.com/firebase/firebase-tools/releases/tag/v11.18.0) to deploy a nodejs18 function.

#### Initialize your Firebase project

Expand Down
8 changes: 5 additions & 3 deletions src/presets/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,19 @@ async function writeRoutes(nitro: Nitro) {
return obj;
}, {} as Record<string, string>);

let nodeVersion = "14";
let nodeVersion = "18";
const supportedNodeVersions = ["18", "16", "14", "12", "10"];
// ^ See https://cloud.google.com/functions/docs/concepts/nodejs-runtime
try {
const currentNodeVersion = JSON.parse(
await readFile(join(nitro.options.rootDir, "package.json"), "utf8")
).engines.node;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: engines.node could be like 18 || 14 too. We might parse it as array and choose first matching version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be in later PR..

if (["16", "14"].includes(currentNodeVersion)) {
if (supportedNodeVersions.includes(currentNodeVersion)) {
nodeVersion = currentNodeVersion;
}
} catch {
const currentNodeVersion = process.versions.node.slice(0, 2);
if (["16", "14"].includes(currentNodeVersion)) {
if (supportedNodeVersions.includes(currentNodeVersion)) {
nodeVersion = currentNodeVersion;
}
}
Expand Down