Giter Club home page Giter Club logo

fast-json-stringify-compiler's People

Contributors

climba03003 avatar dependabot[bot] avatar eomm avatar fdawgs avatar ivan-tymoshenko avatar mcollina avatar uzlopak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast-json-stringify-compiler's Issues

Compiled serializer is huged because of `serializerState`

Prerequisites

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

Last working version

4.20

Stopped working in version

4.3.0

Node.js version

20.x

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

๐Ÿ’ฅ Regression Report

Every compiled schema contains a stringified version of the schema. Issue is when the schema is huged.
Today it almost kills the advantage of compilation.

It comes from the bump to v5.7.0 of fast-json-stringify.
And to be specific if comes from : fastify/fast-json-stringify#617.

It seems that this getState() of the serializer is never used.

Steps to Reproduce

async function main() {
  const app = fastify({
    exposeHeadRoutes: false,
    jsonShorthand: false,
    schemaController: {
      compilersFactory: {
        buildSerializer: writeSerializerFactory,
      },
    },
    logger: {
      level: 'debug'
    }
  });

  addAllSchemas(app);

  await app.register(async api => {
    api.register(... all handlers ...)
  });

  await app.ready().then(() => {
    app.log.info('Ready, all serializer compiled');
    app.close();
  });
}


export const writeSerializerFactory = StandaloneSerializer({
  readMode: false,
  storeFunction(routeOpts, schemaSerializationCode) {
    if (routeOpts.method === 'HEAD') {
      return;
    }
    writeFileSync(generateSerializerFilePath(routeOps), schemaSerializationCode);
  },
});

Expected Behavior

Why have this serializerState ? Is does not seem to be used at all ?

Updating for v5

Prerequisites

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

Issue

๐Ÿ‘‹ I'm Matteo, and would like to work on this.
Coming from Fastify issue #5116 (fastify/fastify#5116)

From what I've understood, I need to:

  • Update any NPM dependencies that might be updated
  • Update the workflow to use the version 4 of plugins-ci

If there's anything I'm missing, please do let me know

Bump fast-json-stringify dependency to 4.1.0

Prerequisites

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

Fastify version

4.0.1

Plugin version

3.0.0

Node.js version

16.14.2

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Unrelated

Description

In fastify/fastify@cf46dea a new fast-json-stringify version is used but only as a dev dependency. I have an older project upgraded to Fastify 4.0.1, but the fast-json-stringify version in my package-lock remained at 4.0.0 instead of 4.1.0, so bumping the version here seems appropriate.

Steps to Reproduce

Upgrading a project with a lock made prior to the 4.1.0 release.

Expected Behavior

No response

Is type `SerializerCompiler` correct ?

Prerequisites

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

Issue

Hello,

From my research, I have the feeling that the declared SerializerCompiler might be wrong.

In fastify, compiler is eventually called this way :

serializerCompiler({
    schema,
    method,
    url,
    httpStatus,
    contentType
  })

In fast-json-stringify-compiler; with jfsOpts being already bounded,

function responseSchemaCompiler (fjsOpts, { schema /* method, url, httpStatus */ }) { ... }

My conclusion is that SerializerCompiler should be:

export type SerializerCompiler = (routeDef : RouteDefinition) => Serializer;

What do you think ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.