Does anyone have a working example for a multi-mod...
# javascript
m
Does anyone have a working example for a multi-module project with code splitting and lazy loading? • I’d like to have modules “Main” and “Full”. • “Main” is loaded initially and “Full” loaded lazily for certain pages. • “Full” depends on “Main”. • “Full” should be able to use code and access resources of “Main”. Currently it looks like this: • I have no idea how to import “Full” from “Main” lazily. • How do I set that up without creating cyclic dependencies? Using
external interface
in “Main” for certain exports of “Full”? • “Full” also seems to contain all code of “Main” which is not desired. • I don’t know how to set up resources properly so that
require
works in both modules for their local resources and in “Full” for “Main”’s resources.
Got a rough first version working. That was a really annoying experience 😅 Still many issues to work around. Different JS modules seem to overwrite each other’s
node_modules
🙄
is
and
as
area also broken because many classes are created twice - once per chunk 😕
t
Do you use webpack entrypoints?
m
The problem is Kotlin. But I'm working on another solution.
That's not needed
t
Does it create
js
file per subproject?
m
Yes, each Gradle subproject is a module. Whether it's imported statically or dynamically depends on how you import it (Gradle or dynamic JS import).