wip: dynamic imports for code-splitting #120
Open
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.
this is a draft how you would do dynamic import to not load all the libraries.
newer bundlers are able to consume libraries that contain import() statements, if the package.json contains a
"module":
entry-point that points to a file where import statements are untranspiled.basically, you can just use the src directory.
For backwards compatibility, you can make a traditional build and add a babel-plugin, that makes normal imports out of this dynamic imports. They won't profit from code-splitting, but it would not break
Problem now is, that this library also uses scss for styles and therefore uses webpack. Webpack does not support creating esmodule libraries. (altough it can consume them). The generated umd build won't work for code-splitting.
So what would need to be done is:
I wont' continue the work on this for now, but i want to leave it here as a reference for someone else to pick it up. It actually should not be too hard, but needs some experience unfortunatly