Newer versions of the plugin occasionally need to update the workspace configurations, and this page documents the strategies available across these versions.
Please note that these migrations are provided on a 'best effort' basis, due to the fact that workspaces are quite complex and often customised.
Plugin version 2.1 added some new features that required changes to the project configurations.
To help with this & future updates, an automatic migration generator has been added:
- Update to the latest plugin using
npm i @simondotm/nx-firebase@latest --save-dev
- Run npx nx g @simondotm/nx-firebase:migrate
This tool will run checks on your workspace firebase apps, functions and configurations and try to ensure they are correctly configured for compatibility with the plugin version you are using.
Please note, this generator is not the same as Nx's own migration tool, so always review the changes it makes to ensure they are appropriate for your workspace.
Version 2.x of this plugin has been completely rewritten, and uses a completely new approach to building & deploying, so migrating an existing Nx workspace using V1 of the plugin to use V2 requires some manual migration procedures.
-
First of all, your workspace will need to be migrated to at least Nx 16.1.1.
-
Next, update the
@simondotm/nx-firebase
plugin package to the latest v2.x version.
Run the following steps 3-5 in order, for each separate Firebase application project in your workspace.
- Next, you can either generate a new firebase v2 application project and copy across your Firebase rules, indexes, storage rules etc. to the new firebase application project folder
OR
- you can manually modify your existing Firebase
project.json
to be structured as shown here.
If you are using Firebase functions in your project, the migration process is as follows:
-
Update the
"functions"
section in thefirebase.json
orfirebase.project-name.json
config file for your firebase application project to be set to"functions": []
-
Generate a new Firebase functions application in your workspace, using the
--app
parameter set to the name of your Firebase application above -
Move the source code from your old Nx Firebase application
functions/src
folder to thesrc
folder in the newly created Firebase function application -
You will need to rename your entry point source file from
index.ts
tomain.ts
-
If you migrated your Firebase application in place (as described above), you will need to manually delete the following from your Firebase application folder:
src
folder- All
tsconfig.*.json
files package.json
file
-
OR, if you migrated by creating a new firebase application, you can now simply delete the old v1 Firebase application project
Check the Nx-Firebase project schemas document for more information about the v2 plugin generators project layouts.
The previous version of the plugin required that all Nx libraries imported by firebase functions were buildable.
With v2 of the plugin, this is no longer the case and Nx libraries can be buildable or non-buildable, since esbuild
builds from Typescript source files, not compiled JS.
Nx Typescript libraries can be converted to non-buildable by simply removing the build
target from their project.json
files.
Run nx build your-firebase-project-name
to compile & bundle your functions.
Run nx deploy your-firebase-project-name
to deploy your project.