feat: modifying code generation to reduce bundle size #4978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: modify code generation to reduce bundle size
Add
bin/get_size.py
so thatpython bin/get_size.py plotly build
reports the number of files and total size in bytes of the
plotly
directory (where generated code is put) and the
build
directorythat is populated by
python setup.py build
.Modify
codegen/__init__.py
and./setup.py
so thatpython setup.py --reformat=false
disables reformatting.Assign an empty string to the
data_docs
field of generatedvalidators. (This has a major impact because those docs are
duplicated many times.)
Alias name of base validator during import in
codegen/validators.py
.Remove the long list of CSS colors from help strings for color
properties.
Replace
super(Parent, self)
withsuper()
in generated code.Drop use of sys.version_info and TYPE_CHECKING. Removed the check
for Python < 3.7 using
sys.version_info
and as a backup checkingtyping.TYPE_CHECKING
; this saves a little space and also cleansup the code.
Introduce
_init_provided()
forBaseFigure
andBasePlotlyType
that calls a helper function
_initialize_provided()
to replacerepetitions of:
Original size (bytes): 47086264
New size (bytes): 37142340
Change: -27%