Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: dynamic imports for code-splitting #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

macrozone
Copy link

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:

  • create a complete separated build-step that targets modern packages
  • this buildstep would create a es6 dist folder with all es6 code (this can be done via babel-cli i)
  • it would also require to handle the scss files somehow. this is the part that i have no clue how to do it

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant