-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: support to install chunks before entry loaded #783
Conversation
crates/mako/src/chunk_pot/util.rs
Outdated
<Expr as ExprFactory>::make_bin::<Expr>( | ||
chunk_global_expr.clone(), | ||
BinaryOp::LogicalOr, | ||
quote_ident!("[]").into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ident 可以 into 成 array expression 吗?
@@ -314,6 +315,7 @@ const DEFAULT_CONFIG: &str = r#" | |||
"esVersion": "es2022", | |||
"meta": false, | |||
"asciiOnly": true, | |||
"chunkLoadingGlobal": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们是不是也叫 namespace 好一点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webpack 的默认值也是 "" 吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们是不是也叫 namespace 好一点
webpack 也是叫这个名字:https://webpack.js.org/configuration/output/#outputchunkloadingglobal
webpack 的默认值也是 "" 吗?
不是,Mako 和 webpack 一样默认值是根据配置动态计算的
// globalThis.jsonpCallback([["module_id"], { module object }]) | ||
let jsonp_callback_stmt = <Expr as ExprFactory>::as_call( | ||
*member_expr!(DUMMY_SP, globalThis.jsonpCallback), | ||
// (globalThis['makoChunk_global'] = globalThis['makoChunk_global'] || []).push([["module_id"], { module object }]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
globalThis['makoChunk_global'] =
赋值是需要前置加载的 chunk 需要的吧,async chunk 应该不需要。这个优化比较小,如果先不做,可以注释里记个 TODO。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是打算 async chunk 和 shared chunk 用同一套 wrap,不然还得区分两种 chunk 的 runtime wrap
@@ -314,6 +315,7 @@ const DEFAULT_CONFIG: &str = r#" | |||
"esVersion": "es2022", | |||
"meta": false, | |||
"asciiOnly": true, | |||
"chunkLoadingGlobal": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webpack 的默认值也是 "" 吗?
@@ -287,6 +288,12 @@ function createRuntime(makoModules, entryModuleId) { | |||
installedChunks[id] = 0; | |||
} | |||
}; | |||
var chunkLoadingGlobal = global['<%= chunk_loading_global.clone() %>'] = global['<%= chunk_loading_global.clone() %>'] || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这段感觉也是可以按需载入的,如果没有打包出前置加载的 chunk,应该不需要。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已线下沟通,先不做处理
支持在 entry 之前安装 chunks,该特性是多 entry 功能的改造点之一
实现方案详见 RFC『Runtime 相关』任务:#766