It appears to be in a vicious cycle.
Whenever I import onDocumentUpdated trigger like this:
import { onDocumentUpdated } from 'firebase-functions/v2/firestore';
yarn lint throws the following error, therefore I can't deploy:
/XXX/functions/src/notifications/sendNotification.ts
2:35 error Unable to resolve path to module 'firebase-functions/v2/firestore' import/no-unresolved
✖ 1 problem (1 error, 0 warnings)
Whenever I import the function like this:
import { onDocumentUpdated } from 'firebase-functions/lib/v2/providers/firestore';
linter passes but then firebase deploy throws this error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/v2' is not defined by "exports" in /XXX/functions/node_modules/firebase-functions/package.json
at exportsNotFound (node:internal/modules/esm/resolve:303:10)
at packageExportsResolve (node:internal/modules/esm/resolve:650:9)
at resolveExports (node:internal/modules/cjs/loader:591:36)
at Module._findPath (node:internal/modules/cjs/loader:668:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/XXX/functions/lib/index.js:28:14)
at Module._compile (node:internal/modules/cjs/loader:1376:14) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Error: Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The second error makes sense. When I look at the package.json of firebase-functions then the exports look like following:
"v2": [
"lib/v2"
],
"v2/core": [
"lib/v2/core"
],
"v2/alerts": [
"lib/v2/providers/alerts"
],
"v2/alerts/appDistribution": [
"lib/v2/providers/alerts/appDistribution"
],
"v2/alerts/billing": [
"lib/v2/providers/alerts/billing"
],
"v2/alerts/crashlytics": [
"lib/v2/providers/alerts/crashlytics"
],
"v2/alerts/performance": [
"lib/v2/providers/alerts/performance"
],
"v2/base": [
"lib/v2/base"
],
"v2/database": [
"lib/v2/providers/database"
],
"v2/eventarc": [
"lib/v2/providers/eventarc"
],
"v2/identity": [
"lib/v2/providers/identity"
],
"v2/options": [
"lib/v2/options"
],
"v2/https": [
"lib/v2/providers/https"
],
"v2/pubsub": [
"lib/v2/providers/pubsub"
],
"v2/storage": [
"lib/v2/providers/storage"
],
"v2/tasks": [
"lib/v2/providers/tasks"
],
"v2/scheduler": [
"lib/v2/providers/scheduler"
],
"v2/remoteConfig": [
"lib/v2/providers/remoteConfig"
],
"v2/testLab": [
"lib/v2/providers/testLab"
],
"v2/firestore": [
"lib/v2/providers/firestore"
]
}
},
Why is the linter not be able resolve the path? The paths are already properly exported :/