fastify/fast-json-stringify

Standalone mode doesn't work without dependencies

ivan-tymoshenko opened this issue · 12 comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

Standalone mode is not working without required deps: ajv, fast-uri, ajv-formats, rfdc. Should we use webpack to create a bundle or it's ok?

I believe the statement in document is very clear that you need to manually install those dependency in order get it works.
Same applied to ajv standalone mode.

Maybe it's better to reexport them somehow from fjs, so user will have to install and require only fjs. WDYT?

Maybe it's better to reexport them somehow from fjs, so user will have to install and require only fjs. WDYT?

If the dependency is imported from fast-json-stringify.
Then, the usage of compile it prior and eliminate fast-json-stringify as dependency will be gone. It is rare, but it should be a current valid use-case.

Sorry, I didn't get you.

Sorry, I didn't get you.

It means that if I want to compile the stringify function before deploy, and reduce the dependency size.
I don't have to install fast-json-stringify as extra dependency as it did nothing after the compilation of function.

FJS is a small module. I think the main goal of standalone mode is to reduce compilation time but not the size.

FJS is a small module. I think the main goal of standalone mode is to reduce compilation time but not the size.

Valid point, but the movement just reduce a valid use-case that currently support.

It’s very inconvenient right now. I can’t just update to the new FJS version and recompile. I have to go and check docs or check source code in order to be sure that there is no new dependencies appeared. It may break someone prod if he didn't check it.

I am not block to either bundle or re-export. Both has the advantages.
We can also toggle between the re-export and direct import. It is not much code dealing with it.

I'm -1 to bundle the dependencies. In the standalone code, we could require('fast-json-stringify/runtime.js') that returns all the dependencies.

Cant we use peerDependencies?

They won't do if the goal is to have a standalone build that could be run without having fjs in the dependency tree.