Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large package when deploying #57

Open
ghost opened this issue Jul 10, 2019 · 2 comments
Open

Large package when deploying #57

ghost opened this issue Jul 10, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 10, 2019

Firebase creates a 38 MB package when I try to deploy my functions. Usually, my functions have less than 1 mb.

a

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?

@interrobrian
Copy link

interrobrian commented Sep 23, 2019

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:

  • Removed the build from predeploy in package.json
  • Added the following to firebase.json:
"functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run build",
      "npm --prefix \"$RESOURCE_DIR\" run cleanSymlink"
    ],
    "ignore": ["node_modules", ".dart_tool", "packages"]
  },
  • Added the following to package.json
{
  "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.

@StefanLobbenmeier
Copy link

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:
image

That helped me understand what the ignore is actually doing / what still had to be added to the ignore in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants