ApplicationInsights-node.js icon indicating copy to clipboard operation
ApplicationInsights-node.js copied to clipboard

[Beta] Module size is too BIG

Open fakedob opened this issue 1 year ago • 4 comments

Hey guys, I have noticed that since I started using the beta, our dev environment, runing on Azure functions, started getting its cold start from 2 seconds, to 30+ seconds. Well, I didnt figured it out straight away and it did took me some time to realise that the new Beta depends on few node modules, specifically the @opentelemetry (as noted in the docs), that allocates around 36mb's os space. My package.json has only:

"dependencies": {
    "@azure/functions": "^4.0.1",
    "applicationinsights": "^3.0.0-beta.10"
  },

And my node_modules are already 69.5mb...

I understand this is still a beta, but are there any ways of reducing the package size, that you are aware? Are there plans to reduce the size, maybe distribute a compiled standalone version or other technique?

Thanks :)

fakedob avatar Nov 10 '23 03:11 fakedob

Thumbs up for this. Did some evaluation between patches v2.9.2 and v2.9.3 and the increase in size is exponential. Some dependencies should be optional at best.

v2.9.2

v2 9 2

v2.9.3

v2 9 3

One culprit seems to be the @nevware21 packages.

npm list @nevware21/ts-async
`-- [email protected]
  `-- @microsoft/[email protected]
    `-- @microsoft/[email protected]
      `-- @microsoft/[email protected]
        `-- @nevware21/[email protected]

Considering the extremely slow releases of nodejs apps in Azure Dev Ops, correlating to the number of files, this is getting very annoying.

paed01 avatar Feb 16 '24 15:02 paed01

Quite an increase: https://bundlephobia.com/package/[email protected]

https://bundlephobia.com/package/@azure/functions

paed01 avatar Feb 16 '24 16:02 paed01

We have created the following Application Insights Issue to address the inclusion of these dependencies, as they are not actually needed at runtime, once we rework the inclusion we will publish an updated v1.1.1 version.

  • https://github.com/microsoft/ApplicationInsights-JS/issues/2277

MSNev avatar Feb 16 '24 19:02 MSNev

Much better, now it is back to normal sizes.

v2.9.4

v2 9 4

Thank you.

@fakedob I scanned the directories with TreeSize free (Windows) after npm prune --omit=dev

paed01 avatar Feb 19 '24 09:02 paed01

Closing as the bundle sizes were reduced.

JacksonWeber avatar Apr 26 '24 23:04 JacksonWeber