Open ghost opened 4 years ago
The culprit appears to be the .dart_tools
and packages
directories, which aren't necessary at runtime. Here's what I did to fix it:
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run build",
"npm --prefix \"$RESOURCE_DIR\" run cleanSymlink"
],
"ignore": ["node_modules", ".dart_tool", "packages"]
},
{
"scripts": {
"build": "pub run build_runner build --output=build",
"cleanSymLink": "rimraf ./build/node/packages",
...
},
...
"devDependencies": {
"rimraf" : "^3.0.0",
...
}
}
Re-run npm install
in the functions
directory and it should work. Cut mine down from 36MB for the sample Hello World to 97KB while the function still works.
Good finding! I was able to reduce to 100kb. But I wanted to add one more thing - on this page https://console.cloud.google.com/ you can download the files that have been deployed to firebase:
That helped me understand what the ignore is actually doing / what still had to be added to the ignore in my case.
Firebase creates a 38 MB package when I try to deploy my functions. Usually, my functions have less than 1 mb.
Curiously,
node_modules
has exactly 38 MB, however it is supposed to be automatically ignored (https://stackoverflow.com/a/51182549/6696558).Is this normal when using this package? Is there any configuration I can do to exclude unwanted parts?