qlik-oss/enigma.js

Enigma.js in not tree-shaking friendly

VincentDauliac opened this issue · 1 comments

The size of the library in an app bundle could be improved by making it tree-shakable and more modular. The main issue are the JSON schemas because even if we only use a single method of the Engine API, all methods definitions are loaded in the app bundle.
I know it is possible to manually strip down a schema definition file to only keep the necessary, but being able to import only the needed methods would be simpler and safer.

For an enterprise BI app or a Node.js program bundle size may not be such a big concern, but for a public facing app it clearly is a downside.

I don't know if a change in that direction is possible, or if there are existing solutions/tricks addressing this concern. Let me know !

Thanks

peol commented

Hi Vincent, sorry for the late response. Your issue got lost in all the post-vacation emails.

Thanks for the issue, you're highlighting something we've been talking about for quite some time. It does however require some significant changes to the library so we would have to plan in this work sometime in the future.

What you're mentioning about manually reducing the schema is the best supported way today. An unsupported way would be to manually pass in the JSONRPC request but YMMV here:

session.send({
  handle: model.handle || someNumericHandle,
  method: "GetLayout",
  params: [],
});