You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Damian Bielecki, Sergey Bekrin, Malte Laukötter, Mike McLin, Mark Goho, Andri Óskarsson, Audrius Karosevicius, jared laser, Noah Wood, Stephen Haney and 256 more
Reacted by Ahmad Ali, Shun Kakinoki, Marcus Wood, Ethan Sarif-Kattan, Johannes Braun, Luis Eduardo, rohovdmytro, Adarsh Madrecha, Johan CHOUQUET, Lukas Herman and 11 more
Reacted by Ahmad Ali, Shun Kakinoki, Ethan Sarif-Kattan, Dominic Bartl, Johannes Braun, Luis Eduardo, Bruno Motta, rohovdmytro, Adarsh Madrecha, Johan CHOUQUET and 13 more
Reacted by Ahmad Ali, Shun Kakinoki, Qrymy, Igor Krupenja, Ethan Sarif-Kattan, Johannes Braun, Yaron Malin, Luis Eduardo, Bruno Motta, rohovdmytro and 8 more
Reacted by Travis Wimer, Máté Homolya, Mateusz Hadryś, Matheus Schettino, Samrat Bhandari, David Woodward, Ahmad Ali, Shun Kakinoki, Acun Gürsoy, Ethan Sarif-Kattan and 25 more
Reacted by Travis Wimer, Mateusz Hadryś, Matheus Schettino, DY, Samrat Bhandari, David Woodward, Ahmad Ali, Acun Gürsoy, Ethan Sarif-Kattan, Philipp Adrian and 22 more
Reacted by Ahmad Ali, Ethan Sarif-Kattan, Olav Sundfør, Johannes Braun, Luis Eduardo, Luca Ban, Victor Dias, Adarsh Madrecha, Johan CHOUQUET, Lukas Herman and 14 more
This seems to work in my setup, i.e. deploy picks up packages from the root node_modules, even though package.json for that is located under the api/ workspace (I've used a different folder name instead of functions/). Is there anything else that needs fixing here?
EDIT: Moreover, I copy package.json into api/dist to be used by deploy.
Ensuring the firebase.json files for each service don't stomp on one another is left up to the user. Simple conventions of using function groups and multi-site name targeting means this is solved for Cloud Functions and Hosting. Still haven't got a solution for Firestore/GCS rules yet, though splitting them up may not be ideal...
@jthegedus thank you for your reply. But I think issue of this ticket is different. I am trying to use yarn workspaces. And seems that firebase tools doesn't pickup symlink dependencies when uploading functions
Reacted by James Hegedus, Furkan Tunalı, Spain, Ethan Sarif-Kattan, Ikhsan Assaat, Artur Gubaidullin, Carl Patenaude-Poulin, Igor Valoueff, Kollein, abdul ahad and 1 more
Could you elaborate what the issue is? As mentioned above, I just use bare Yarn with api and app workspaces in it, and I build them using yarn workspace api build && yarn workspace app build (with build script specific to each workspace). The build scripts
compile TS code with outDir into api/dist and app/dist respectively
copy the corresponding package.json files into dist directories
copy yarn.lock from the root folder, into dist directories
Then I just run yarn firebase deploy from the root folder, and it picks up both api/dist and app/dist without any hiccups. My firebase.json looks like
Also, I might be wrong but I think the firebase deploy script doesn’t actually use your node_modules directory. I think it just picks up the code, package.json, and yarn.lock from the dist directories, and does the rest.
That's true. The default value of "functions.ignore" in firebase.json is
["node_modules"] so it's not uploaded. I believe you can override that
though if you want to ship up some local modules.
On Mon, Jun 17, 2019, 6:58 PM Denis Loginov ***@***.***> wrote:
Also, I might be wrong but I think the firebase deploy script doesn’t
actually use your node_modules directory. I think it just picks up the
cod, package.json, and yarn.lock from the dist directories, and does the
rest.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#653?email_source=notifications&email_token=ACATB2U73VS2KIILUVRFFB3P3A6NPA5CNFSM4EOR24GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX46ABQ#issuecomment-502915078>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACATB2U3Q2TLVBICRJ3B5OLP3A6NPANCNFSM4EOR24GA>
.
@dinvlad Yes, it requires the package.json and whichever lock file you use as it installs deps in the cloud post deployment.
I believe the scenario originally outlined in the other issue was using a shared package within the workspace and some issues with scope-hoisting. As I was not using yarn this way I can only speculate from what I have read there.
Deployment error.
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`gen_package_lock` had stderr output:\nnpm WARN deprecated [email protected]: use String.prototype.padStart()\nnpm ERR! code E404\nnpm ERR! 404 Not Found: [email protected]\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2019-06-18T07_10_42_472Z-debug.log\n\nerror: `gen_package_lock` returned code: 1", "errorType": "InternalError", "errorId": "1971BEF9"}}
Functions works fine locally on emulator.
Solutions tried
Uploading node_modules (using functions.ignore in firebase.json). Result is same.
My guess that it is because utilities is created as syslink in node-modulesnode_modules/utilities -> ../../utilities
Could it be that firebase-tools doesn't include content of symlink'ed modules when uploading (no dereferencing)?
Reacted by Stephen Haney, Brian Schardt, Luciano, Ethan Sarif-Kattan, Carlos Chida, othondev, Carl Patenaude-Poulin, 유민호(Minho), Matt Nicolls, Andrew Krippner and 13 more
Reacted by Stephen Haney, Mitch Conquer, Luciano, Ethan Sarif-Kattan, Carl Patenaude-Poulin, Jean Costa, Martin Cabral and Thiago Bernardi
Managed to solve this with build output approach with Rollup. Not ideal, but can't think of a better solution given the limitations.
The Strategy
Instead of fighting Firebase Tools' symlink handling, we bundle all local workspace packages into the deployment artifact and strip them from package.json entirely.
Implementation Overview
1. Monorepo Structure
/apps/firefunctions/ # Firebase Functions app
/pkgs/js/utils/ # Local workspace packages
2. Rollup Configuration
Create apps/firefunctions/rollup.config.mjs with a three-step process:
Step 1: Tell Rollup to BUNDLE local packages (not externalize them)
importnodeExternalsfrom'rollup-plugin-node-externals';exportdefault{plugins: [nodeExternals({builtins: true,deps: true,devDeps: false,peerDeps: true,optDeps: true,exclude: /^@your-scope\//,// Don't externalize - bundle these instead!}),// ... other plugins],};
Step 2: Strip local packages from the output package.json
import*asfsfrom'fs/promises';import*aspathfrom'path';constDIST_DIR='./dist';constcopyPackageJson=()=>({name: 'copy-package-json',asyncwriteBundle(){constpackageJsonContent=awaitfs.readFile('./package.json','utf-8');constpackageJson=JSON.parse(packageJsonContent);// Remove all local workspace dependenciesif(packageJson.dependencies){Object.keys(packageJson.dependencies).forEach(dep=>{if(dep.startsWith('@your-scope/')){deletepackageJson.dependencies[dep];}});}if(packageJson.devDependencies){Object.keys(packageJson.devDependencies).forEach(dep=>{if(dep.startsWith('@your-scope/')){deletepackageJson.devDependencies[dep];}});}awaitfs.writeFile(path.join(DIST_DIR,'package.json'),JSON.stringify(packageJson,null,2));},});
Step 3: Configure TypeScript to compile everything
importtypescriptfrom'@rollup/plugin-typescript';exportdefault{plugins: [typescript({tsconfig: './tsconfig.json',sourceMap: true,declaration: false,declarationMap: false,// Override include to process all TypeScript files including workspace packagesinclude: ['**/*.ts','**/*.tsx'],compilerOptions: {outDir: path.join(DIST_DIR,'src'),},}),// ... other plugins],};
Add build scripts to your apps/firefunctions/package.json and don't forget to set main parameter to the src/index.js which will be related to the dist folder after build completes:
@kdawgwilk lockfile stays in the repository root so it doesn't get to the dist folder at therefore doesn't get deployed.
Again, not ideal, but I do --save-exact for all the packages I install, so shouldn't be that critical.
@ivliag Ah --save-exact will only save the exact version of the top level dep you actually use but the transitive downstream deps will still get updated out from under you when the cloud build happens. So like the recent Shai Hulud your container builds would be pulling new vulnerable transitive dep versions into the container at build time 😬
This issue basically makes firebase cloud functions a terrible backend solution in any serious project. If only they would spend less time building AI slops and more time implementing crucial features like this one, maybe then they would have a real positive impact.
...to get around the lock file issue with deploying to Firebase when there's only a single root package-lock.json and not a firebase function specific package-lock.json? With the recent axios trojan attack, it's a good reminder that we need to lock down our package versions, but Firebase inside a npm monorepo doesn't make that easy. I wonder if either of those packages listed above solves the problem.
@johnnyoshika I would say the isolate fork is the best solution for the time being, since it doesn't break the emulator live updates and it handles the lock file.
But using an unofficial fork that doesn't seem to be synced up with the upstream on a regular basis, is not that great. Not to mention that it adds complexity, which goes against the whole point of using a monorepo, which is to simplify dependency management and improve code sharing.
After spending a couple of days trying out different solutions I decided to remove the functions package from the monorepo. Will probably use something like quicktype + chokidar to automatically generate different backend & frontend models/schemas from a single source of truth.
we have our own fork that we use AskElephant/firebase-tools that uses a couple ideas from the isolate package changes and supports pnpm because thats what we use. We also fixed a bunch of bugs with quota rate limits that were causing us all kinds of problems with deploys at scale that we tried to get merged upstream but maintainers have been unresponsive on most of our PRs which is pretty disappointing
Hi everyone 👋 Sorry I haven’t been keeping the firebase-tools-with-isolate fork in sync as regularly as I promised. It is time for a structural solution…
I have managed to automate the whole process via Github actions; A cron job will check daily for a new upstream version, sync it, re-apply the required changes, and publish a new version. So things should stay in sync from now on 👯
I hope this also takes away some people’s fears around using the fork. It does not meaningfully change the behavior of firebase-tools, only how your files are organized before uploading.
I have now also disabled "issues" on the fork repo, to avoid confusion, because any problems related to Isolate-package should be submitted on that repo instead.
I recommend checking out gcp-job-runner. I find it super convenient for processing large amounts of documents, like doing a Firestore migration. It lets you define simple scripts and run them either locally or as a cloud run job, and as such it could be used for any CLI scripts that you wish to run.
I’ve also bundled the family of typed-firestore packages together in an umbrella monorepo, and improved the documentation.
Final thing maybe worth mentioning; Isolate-package should now also supports Bun lockfiles natively (untested), but that will be only useful if you use it to deploy to targets other than Firebase, like a Docker image straight to Cloud Run.
Enjoy!
Reacted by Brian McBarron, Artur Ampilogov, Kevin Pierce, Dylan Lamont and aalej
The latest version of isolate-package now supports NPM lockfile pruning, meaning it preserves the actual locked versions, just like it already did for PNPM, Yarn v1 and Bun. It is currently included in the @next release of firebase-tools-with-isolate. Please give it a try if you use NPM with Firebase.
Activity
dinvlad commentedon Feb 22, 2018
This seems to work in my setup, i.e.
deploypicks up packages from the rootnode_modules, even thoughpackage.jsonfor that is located under theapi/workspace (I've used a different folder name instead offunctions/). Is there anything else that needs fixing here?EDIT: Moreover, I copy
package.jsonintoapi/distto be used bydeploy.So, 2 levels of nesting still resolve the root
node_modulessuccessfully.orouz commentedon Apr 23, 2018
@dinvlad could you share a repo?
dinvlad commentedon Apr 23, 2018
@orouz unfortunately not yet, it's closed source for now.
audkar commentedon Jun 17, 2019
Does anyone managed to tackle this problem? Sharing simple example project would be very useful.
jthegedus commentedon Jun 17, 2019
@audkar Currently I just use lerna.js.org and it's
runcommand to execute an npm script in each subfolder with this folder structure:Ensuring the
firebase.jsonfiles for each service don't stomp on one another is left up to the user. Simple conventions of using function groups and multi-site name targeting means this is solved for Cloud Functions and Hosting. Still haven't got a solution for Firestore/GCS rules yet, though splitting them up may not be ideal...discussed here previously - #1116
audkar commentedon Jun 18, 2019
@jthegedus thank you for your reply. But I think issue of this ticket is different. I am trying to use yarn workspaces. And seems that firebase tools doesn't pickup symlink dependencies when uploading functions
jthegedus commentedon Jun 18, 2019
Ah fair enough, I've avoided that rabbit hole myself
dinvlad commentedon Jun 18, 2019
Could you elaborate what the issue is? As mentioned above, I just use bare Yarn with
apiandappworkspaces in it, and I build them usingyarn workspace api build && yarn workspace app build(withbuildscript specific to each workspace). The build scriptsoutDirintoapi/distandapp/distrespectivelypackage.jsonfiles intodistdirectoriesyarn.lockfrom the root folder, intodistdirectoriesThen I just run
yarn firebase deployfrom the root folder, and it picks up bothapi/distandapp/distwithout any hiccups. Myfirebase.jsonlooks likeUnfortunately, I still can’t share the full code, but this setup is all that matters, afaik.
dinvlad commentedon Jun 18, 2019
Also, I might be wrong but I think the
firebase deployscript doesn’t actually use yournode_modulesdirectory. I think it just picks up the code,package.json, andyarn.lockfrom thedistdirectories, and does the rest.samtstern commentedon Jun 18, 2019
jthegedus commentedon Jun 18, 2019
@dinvlad Yes, it requires the
package.jsonand whichever lock file you use as it installs deps in the cloud post deployment.I believe the scenario originally outlined in the other issue was using a shared package within the workspace and some issues with scope-hoisting. As I was not using yarn this way I can only speculate from what I have read there.
dinvlad commentedon Jun 18, 2019
@samtstern @jthegedus thanks, good to know!
audkar commentedon Jun 18, 2019
Seems we all talk about different problems. I will try to describe
yarn workspacesproblem.Problematic project
project layout
./package.json
functions/package.json
Problem
Error during function deployment:
Functions works fine locally on emulator.
Solutions tried
Uploading
node_modules(usingfunctions.ignorein firebase.json). Result is same.My guess that it is because
utilitiesis created as syslink in node-modulesnode_modules/utilities -> ../../utilitiesCould it be that firebase-tools doesn't include content of symlink'ed modules when uploading (no dereferencing)?
dinvlad commentedon Jun 18, 2019
Sorry, could you clarify which folder your
firebase.jsonlives in (and show its configuration section forfunctions)?174 remaining items
Sandbye commentedon Oct 23, 2025
bump
ivliag commentedon Dec 12, 2025
Managed to solve this with build output approach with Rollup. Not ideal, but can't think of a better solution given the limitations.
The Strategy
Instead of fighting Firebase Tools' symlink handling, we bundle all local workspace packages into the deployment artifact and strip them from
package.jsonentirely.Implementation Overview
1. Monorepo Structure
2. Rollup Configuration
Create
apps/firefunctions/rollup.config.mjswith a three-step process:Step 1: Tell Rollup to BUNDLE local packages (not externalize them)
Step 2: Strip local packages from the output package.json
Step 3: Configure TypeScript to compile everything
Complete Rollup Config Example
3. Firebase Configuration
Point
firebase.jsonto the built output:{ "functions": { "source": "apps/firefunctions/dist" } }4. Package.json Scripts and Main
Add build scripts to your
apps/firefunctions/package.jsonand don't forget to setmainparameter to thesrc/index.jswhich will be related to thedistfolder after build completes:{ "scripts": { "build": "rollup -c rollup.config.mjs", "deploy": "yarn build && firebase deploy --only functions" }, "main": "src/index.js", }5. Firebase.json Source
Set source in
firebase.jsonto thedistfolder:{ "functions": [{ "source": "./dist" }] }Result
The
dist/folder contains:package.jsonwith ONLY external npm dependenciesOverall benefits:
apps/firefunctionsHope this helps.
kdawgwilk commentedon Dec 12, 2025
@ivliag Are you also stripping the local deps from the lockfile?
ivliag commentedon Dec 12, 2025
@kdawgwilk lockfile stays in the repository root so it doesn't get to the
distfolder at therefore doesn't get deployed.Again, not ideal, but I do
--save-exactfor all the packages I install, so shouldn't be that critical.kdawgwilk commentedon Dec 13, 2025
@ivliag Ah
--save-exactwill only save the exact version of the top level dep you actually use but the transitive downstream deps will still get updated out from under you when the cloud build happens. So like the recent Shai Hulud your container builds would be pulling new vulnerable transitive dep versions into the container at build time 😬x1z7 commentedon Apr 2, 2026
This issue basically makes firebase cloud functions a terrible backend solution in any serious project. If only they would spend less time building AI slops and more time implementing crucial features like this one, maybe then they would have a real positive impact.
johnnyoshika commentedon Apr 2, 2026
Has anyone tried either of these packages in their monorepo:
https://github.com/0x80/isolate-package
https://github.com/0x80/firebase-tools-with-isolate
...to get around the lock file issue with deploying to Firebase when there's only a single root package-lock.json and not a firebase function specific package-lock.json? With the recent axios trojan attack, it's a good reminder that we need to lock down our package versions, but Firebase inside a npm monorepo doesn't make that easy. I wonder if either of those packages listed above solves the problem.
x1z7 commentedon Apr 3, 2026
@johnnyoshika I would say the isolate fork is the best solution for the time being, since it doesn't break the emulator live updates and it handles the lock file.
But using an unofficial fork that doesn't seem to be synced up with the upstream on a regular basis, is not that great. Not to mention that it adds complexity, which goes against the whole point of using a monorepo, which is to simplify dependency management and improve code sharing.
After spending a couple of days trying out different solutions I decided to remove the functions package from the monorepo. Will probably use something like quicktype + chokidar to automatically generate different backend & frontend models/schemas from a single source of truth.
kdawgwilk commentedon Apr 3, 2026
we have our own fork that we use AskElephant/firebase-tools that uses a couple ideas from the isolate package changes and supports pnpm because thats what we use. We also fixed a bunch of bugs with quota rate limits that were causing us all kinds of problems with deploys at scale that we tried to get merged upstream but maintainers have been unresponsive on most of our PRs which is pretty disappointing
ArturAmpilogov commentedon Apr 3, 2026
Added a feature request to the Firebase team to gain more attention to this thread.
This is an important and hot topic.
niehaus1301 commentedon Apr 4, 2026
Especially now with AI Coding tools monorepos are becoming more relevant
0x80 commentedon Apr 9, 2026
Hi everyone 👋 Sorry I haven’t been keeping the firebase-tools-with-isolate fork in sync as regularly as I promised. It is time for a structural solution…
I have managed to automate the whole process via Github actions; A cron job will check daily for a new upstream version, sync it, re-apply the required changes, and publish a new version. So things should stay in sync from now on 👯
I hope this also takes away some people’s fears around using the fork. It does not meaningfully change the behavior of firebase-tools, only how your files are organized before uploading.
I have now also disabled "issues" on the fork repo, to avoid confusion, because any problems related to Isolate-package should be submitted on that repo instead.
I have cleaned and up all of my other open-source projects lately, and there’s quite a few related to Firebase and GCP. You can find them here https://www.codecompose.com/open-source
I recommend checking out gcp-job-runner. I find it super convenient for processing large amounts of documents, like doing a Firestore migration. It lets you define simple scripts and run them either locally or as a cloud run job, and as such it could be used for any CLI scripts that you wish to run.
I’ve also bundled the family of typed-firestore packages together in an umbrella monorepo, and improved the documentation.
Final thing maybe worth mentioning; Isolate-package should now also supports Bun lockfiles natively (untested), but that will be only useful if you use it to deploy to targets other than Firebase, like a Docker image straight to Cloud Run.
Enjoy!
0x80 commentedon Apr 11, 2026
Version 15.14.0 now auto-detects a monorepo setup and uses that to opt-in to isolate-package.
This means that it is now a drop-in replacement for firebase-tools, and you don't need to set
isolate: trueanymore in your Firebase config.kevmoo commentedon Apr 16, 2026
I just was able to do a mono-repo deploy!
0x80 commentedon Apr 22, 2026
The latest version of
isolate-packagenow supports NPM lockfile pruning, meaning it preserves the actual locked versions, just like it already did for PNPM, Yarn v1 and Bun. It is currently included in the@nextrelease offirebase-tools-with-isolate. Please give it a try if you use NPM with Firebase.I have also published an article about the different Firebase abstractions that I use. You can find it here https://codecompose.com/articles/my-favorite-firebase-abstractions/