The arithmetic expressions are a powerful way of creating several bundles in the project. Combined with lazy loading they can deliver similar results then the API I would like to propose, but
GOAL: Automatically split application into several bundles and lazy-load bundles by module reference during run time.
API: Extend FuseBox.import function with following overload:
FuseBox.import(modulePath: string, fileName: string, callback: (loadedModule: any) => void): Promise<loadedModule: any>
e.g.
const module = await FuseBox.import('../../my_module', 'split_1.js');
BUNDLER BEHAVIOR:
FuseBox.import it starts to create a new bundle with name 'fileName'.LOADER BEHAVIOUR:
What do you think? Would you consider implementing such API?
@tomitrescak absolutely. Love the idea!
I do, however, few notes on that.
I would not mess with FuseBox.import. You see if you want to automatically bundle (create a new one at build time) and load at runtime, that would probably require introducing a new API.
FuseBox.lazy("./mylazy-module").then( module => {
})
lazy method. Extract parameters and initiates a separate process that bundles it. Configuration?! we need to think of that. Probably in the main config - like isolated dependencies and stuff. Or like that?!FuseBox.lazy("./mylazy-module", `> + [entry.ts]`).then( module => {
})
FuseBox.import("./mylazy-module") (just an idea to make it simpler)IMHO that would make it more explicit, as the lazy method will point to an instruction at build time.
To summarise, i would introduce _Build Time Process Instructions_
He re we go
Fuse Code Splitting proposal.pdf
Please give us your feedbacks.
This is now awesomely available in version 2.0
we will close it, but feel free to open it otherwise :)
Most helpful comment
This is now awesomely available in version 2.0
we will close it, but feel free to open it otherwise :)