fastify/fast-json-stringify

standalone mode can't be devDependancy

Eomm opened this issue · 5 comments

Eomm commented

The last fastify release fastify/fastify@4.16.0...4.16.3 shows how the standalone mode now requires fjs as a dependency instead of a dev-dependancy because of this requirement:

  const { dependencies } = require('fast-json-stringify/lib/standalone')

https://github.com/fastify/fastify/blob/b3ebbdc1ab363233b7728d2bcb4a5b8fe64ccfb3/lib/error-serializer.js#L5

I think the standalone mode was designed to produce a js file that can run without fjs

ref: #617

Sorry for breaking things. The problem is that to run a standalone code, you need a bunch of other dependencies to install. I decided to wrap and reexport only required entities.

I think the standalone mode was designed to produce a js file that can run without fjs

The main purpose is to optimize the cold start.

@Eomm is that a problem?

Eomm commented

No, it is not - the readme is updated tho

I wonder if we have other options to make it fully standalone

If the standalone code needs Ajv for validation - then no.
If the standalone code doesn't need Ajv for validation - yes, by printing half of the library to the standalone file.

This way of dealing with it is more flexible. We can use any dep library in the runtime.
Example: #612

Eomm commented

Yeah - there is no clue on this