-
Notifications
You must be signed in to change notification settings - Fork 107
Closed
Description
Problem:
When building multi entries for server-less functions (like Chair Function), some functions may share many modules. By code splitting, those shared modules will be bundled into a common chunk. Usually, the chunk group rule will be like:
{
codeSplitting: {
strategy: "advanced",
options: {
groups: [
{
name: "common",
test: "common/.*",
allowChunk: "all",
minSize: 1
}
]
}
}
}In server-less functions, those multi entries may be require in a same nodejs process, and expect modules in the common chunk
will be single instance. Now time, our runtime mechanism will let common modules be isolated cross entries.
function createRuntime(makoModules, entryModuleId, global) {
// modulesRegistry is in a closure, which will be isolated.
var modulesRegistry = {};
/* ... */
}Solution 1:
Add an option to let runtime can get moduleRegistry from a global variable, the runtime code will be like:
global.__makoGlobalModuleRegistry =
process.env.globalModuleRegistry ?
(global.__makoGlobalModuleRegistry || {}) :
undefine;
function createRuntime(makoModules, entryModuleId, global) {
var modulesRegistry = global.__makoGlobalModuleRegistry || {};
/* ... */
}Solution 2:
Add plugin mechanism for runtime template, let users can customize the runtime template.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels