Code Monkey home page Code Monkey logo

Comments (8)

thiagowfx avatar thiagowfx commented on September 25, 2024

Maksim:

Try to compile mapper, and check its size. The vast majority of the space is taken by the CDP method definitions.

from chromium-bidi.

thiagowfx avatar thiagowfx commented on September 25, 2024

cc @vladimir-nechaev @mathiasbynens

The first commit that integrates terser has been already merged (c.f. #221). To close this bug I need more clarification from @sadym-chromium w.r.t.:

Removing those definitions [CDP string literals describing CDP methods, which are added for development convenience and are required for the functionality]

Let me know how we can accomplish that.

from chromium-bidi.

OrKoN avatar OrKoN commented on September 25, 2024

I think it could be achieved by removing the following imports in the cdp client:

import * as browserProtocol from 'devtools-protocol/json/browser_protocol.json';
import * as jsProtocol from 'devtools-protocol/json/js_protocol.json';

Perhaps instead of generating classes at runtime based on JSON definitions, we could employ a Proxy?

from chromium-bidi.

sadym-chromium avatar sadym-chromium commented on September 25, 2024

I think it could be achieved by removing the following imports in the cdp client:

import * as browserProtocol from 'devtools-protocol/json/browser_protocol.json';
import * as jsProtocol from 'devtools-protocol/json/js_protocol.json';

Perhaps instead of generating classes at runtime based on JSON definitions, we could employ a Proxy?

@thiagowfx IDK how exactly to reach that, and the issue involves some research. Alex's approach looks promising.

from chromium-bidi.

sadym-chromium avatar sadym-chromium commented on September 25, 2024

Additionally I'd consider adding a step verifying the compiled size in the given diapason.

from chromium-bidi.

thiagowfx avatar thiagowfx commented on September 25, 2024

Additionally I'd consider adding a step verifying the compiled size in the given diapason.

That was a good idea! Done on #224

from chromium-bidi.

thiagowfx avatar thiagowfx commented on September 25, 2024

https://mariusschulz.com/blog/importing-json-modules-in-typescript:

Now, we get a type error in line 2. TypeScript doesn't let us import a JSON module out of the box, just like that. This was a conscious design decision made by the TypeScript team: pulling in large JSON files could potentially consume a lot of memory, which is why we need to opt into that feature by enabling the --resolveJsonModule compiler flag:

This is likely why the bidi mapper size is quite bloated.

from chromium-bidi.

thiagowfx avatar thiagowfx commented on September 25, 2024

Basic preprocessing with jq to filter out types and events from the JSON file:

960K    node_modules/devtools-protocol/json/browser_protocol.json =>
284K    node_modules/devtools-protocol/json/browser_protocol_commands_only.json

168K    node_modules/devtools-protocol/json/js_protocol.json =>
60K     node_modules/devtools-protocol/json/js_protocol_commands_only.json

528K => 268K (~50% size reduction)    src/.build/bidiMapper/mapper.js

from chromium-bidi.

Related Issues (20)

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.