Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

split salve's simplification off from the main bundle #40

Open
lddubeau opened this issue Jun 19, 2018 · 0 comments
Open

split salve's simplification off from the main bundle #40

lddubeau opened this issue Jun 19, 2018 · 0 comments

Comments

@lddubeau
Copy link
Member

It would be nice if salve's simplification code could be split off from the main bundle. Since version 6 salve has been able to perform internally simplification and conversion of RNG files to its internal format. So there are two functions that salve performs:

  1. Simplify and convert schemas to an internal representation suitable for validation.

  2. Validate files according to the internal representation produced in 1.

There are use-case scenarios where 1 and 2 are tightly coupled. However, there are also scenarios where 1 and 2 are not so coupled. A specialized app, for instance, may convert schemas ahead of time (e.g. during application build) and only use function 2 in a single-page application. For such application, loading the simplification-conversion code in the SPA is a waste. Code splitting would allow loading only the necessary code. (To name some applications that would benefit from this: wed, and consequently, BTW and MMWP would all benefit.)

Note that the simplify-and-convert code uses salve to validate the schema so it is dependent on the rest of salve. It cannot be build as an independent, and small bundle, because if it is to be independent then it needs to incorporate all of salve.

In theory Webpack's chunking allows splitting off the simplify-and-convert code into a chunk to be loaded on demand. However, these chunks do not behave like the main bundle produced by webpack. We produce a UMD main bundle but the chunks are not UMD. Their names and locations are set at build time, and they cannot be consumed by another webpack build. e.g. if an application that uses salve would want to load the main bundle and the chunks into a single-file build, that's not possible.

The only other alternative seems to be to carefully hand-craft code that would load the internal simplifier on an on-demand basis and pass to it references to the rest of salve. This would probably work fine but the work required is substantial.

@lddubeau lddubeau changed the title splitting salve's simplification off from the main bundle split salve's simplification off from the main bundle Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant