surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.21k stars 814 forks source link

Support tree shaking #1362

Closed mikecousins closed 4 years ago

mikecousins commented 6 years ago

Are you requesting a feature, reporting a bug or asking a question?

Feature

What is the current behavior?

We have to bring in the entire library and it's enormous.

What is the expected behavior?

We should be able to bring in the parts we need so that we don't kill our performance.

image

The Javascript library for React comes in at 98.3KB when gzipped. This is pretty unacceptable and is the single biggest library that we use. Is there any chance that we can get this written so that we can bring in chunks of the library instead to bring this down if we aren't using all of the features?

andrewtelnov commented 6 years ago

@mikecousins You may fork the library, remove unneeded files from https://github.com/surveyjs/surveyjs/blob/master/src/entries/react.ts https://github.com/surveyjs/surveyjs/blob/master/src/entries/chunks/model.ts https://github.com/surveyjs/surveyjs/blob/master/src/entries/chunks/localization.ts

You may do not need matrixes questions or some others. The most questions are done as plug-ins you may remove them and build the library.

Moving from webpack into another solution may reduce the size as well.

Thank you, Andrew

chrismclarke commented 5 years ago

+1 for this feature, stands at 650KB for survey-angular image

dactechie commented 4 years ago

I see that my minified version has many parts of the library which i don't use e.g. the signature pad. Any update on the question about treeshaking ?

tsv2013 commented 4 years ago

@dactechie At this moment library is built into a single package. If you want, you can create your custom build via removing unused elements from the https://github.com/surveyjs/survey-library/blob/master/src/entries/chunks/model.ts file and other entry point files.

dirq commented 4 years ago

+1. Vue version is about 900k!!

stevebering commented 4 years ago

I would be very interested in tree-shaking capability. The survey-vue package makes up almost half of our vendor bundle. We don't need language packs, etc. So tree-shaking them out would help us quite bit. Removing unused components would be great as well.

tsv2013 commented 4 years ago

Closed since the workaround suggested: https://github.com/surveyjs/survey-library/issues/1362#issuecomment-425204688