All notable changes to this project will be documented in this file.
General changes
- Improved listing of firebase functions dependencies; now ordered by npm module libraries first, then local libraries, sorted alphabetically.
Enhanced Support for Firebase Emulators
nx g @simondotm/nx-firebase:app
generator now additionally:
-
Adds default
auth
andpubsub
settings to"emulators": {...}
config infirebase.<appname>.json
so that these services are also emulated by default. -
Adds a new
getconfig
target to firebase functions app, where:nx getconfig <firebaseappname>
will fetch the functions configuration variables from the server and store it locally as.runtimeconfig.json
-
Adds
.runtimeconfig.json
to asset list to be copied (if it exists) from app directory to outputdist
directory when built, so that the function emulators will now run if the functions being emulated access variables from the functions config. -
Adds
.runtimeconfig.json
to the Nx workspace root.gitignore
file (if not already added), since these files should not be version controlled -
Adds an
emulate
target to the Nx-firebase app, which is used byserve
but also allows Firebase emulators to be started independently of a watched build.
Plugin maintenance
- Executors use workspace logger routines instead of console
- Fixed minor issues in e2e tests
- Removed redundant/legacy firebase target
- Replaced plugin use of node
join
with workspacejoinPathFragments
Migration from v0.3.2
For users with existing nx-firebase applications in their workspace you may wish to add the new version schema updates manually to your workspace configuration files.
In your angular.json
or workspace.json
file, for each nx-firebase
app project:
- Add the
.runtimeconfig.json
to your build assets:
"targets": {
"build": {
...
"options": {
...
"assets": [
...
"apps/nxfirebase-root-app/.runtimeconfig.json"
]
}
},
- Add the new
emulate
target to your app:
"targets": {
...
"emulate": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase emulators:start --config firebase.nxfirebase-root-app.json"
}
},
- Modify the
serve
target to:
"targets": {
...
"serve": {
...
"options": {
"commands": [
{
"command": "nx run <appname>:build --with-deps && nx run <appname>:build --watch"
},
{
"command": "nx run <appname>:emulate"
}
],
"parallel": true
}
},
- Add the new
getconfig
target:
"targets": {
...
"getconfig": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase functions:config:get --config firebase.<appname>.json > apps/<path-to-app>/.runtimeconfig.json"
}
},
...
And in your firebase.<appname>.json
config settings for "emulators"
add "auth"
and "pubsub"
configs:
"emulators": {
...
"auth": {
"port": 9099
},
"pubsub": {
"port": 8085
}
}
- Plugin now detects incompatible Nx library dependencies and aborts compilation when found
Incompatible dependencies are as follows:
- Non
--buildable
libraries - Nested libraries that were not created with
--importPath
If either of these two types of libraries are imported by Firebase functions, the compilation will be halted, since a functional app cannot be created with these types of dependencies.
See the README for more information.
-
Removed undocumented/unusued
firebase
target in app generator. No longer needed. -
serve
target now builds--with-deps
before watching to ensure all dependent local libraries are built. Note thatserve
only detects incremental changes to the main application, and not dependent libraries as well at this time.
Project has been renamed from @simondotm/nxfirebase
to @simondotm/nx-firebase
to better match Nx plugin naming conventions. Took a deep breath and did it early before many installs occurred. Apologies to any users who this may have inconvenienced - I didn't realise I could deprecate packages until after I'd deleted & renamed the pnm project. Rest assured, I won't be making any further major modifications like this!
If you have already generated NxFirebase applications using @simondotm/nxfirebase
you will need to migrate as follows:
npm uninstall @simondotm/nxfirebase
npm install @simondotm/nx-firebase --save-dev
- Update the
builder
targets in any NxFirebase applications you already have in yourworkspace.json
orangular.json
config from@simondotm/nxfirebase:build
to@simondotm/nx-firebase:build
Built against Nx 12.3.4
Updates
-
build
executor now supports--watch
option for incremental builds -
Added
serve
target to applications which will build the application with--with-deps
and--watch
options, and also launch the Firebase emulator with the application's firebase configuration in parallel -
Added
deploy
target to applications. Supports Nx forwarded command line arguments so commands likenx deploy <appname> --only functions
work fine -
Default template function
index.ts
now has added import offirebase-admin
to ensure all necessary Firebase package dependencies for functions are included out of the box
Fixes
-
Default
firebase.appname.json
now has a valid default hosting configuration and apps ship with a templatepublic/index.html
(as generated by Firebase CLI) inside the application folder -
Nx-Firebase App generator sets
target
intsconfig.app.ts
toes2018
to ensure Node 10 compatibility for Firebase Functions (for scenarios where root workspacetsconfig.base.json
may be set to a later ES target) -
Fixed
predeploy
scripts infirebase.appname.json
to usenpx nx
so that they work correctly in CI environments -
Fixed default
firestore.rules
file to correct a typo -
Fixed default
storage.rules
file to use version 2 ruleset -
Plugin peer dependencies set so there's some indication of plugin compatibility
Migrating from apps generated with v0.2.2
v0.2.3 adds these targets to your workspace.json
or angular.json
, so for users of earlier versions of the plugin this will have to be done manually:
"serve": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"commands": [
{
"command": "nx run <appname>:build --with-deps && nx run <appname>:build --watch"
},
{
"command": "firebase emulators:start --config firebase.<appname>.json"
}
],
"parallel": true
}
},
"deploy": {
"builder": "@nrwl/workspace:run-commands",
"options": {
"command": "firebase deploy --config firebase.<appname>.json"
}
},
Built against Nx 12.1.1