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

feat: support to install chunks before entry loaded #783

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

PeachScript
Copy link
Member

支持在 entry 之前安装 chunks,该特性是多 entry 功能的改造点之一

实现方案详见 RFC『Runtime 相关』任务:#766

<Expr as ExprFactory>::make_bin::<Expr>(
chunk_global_expr.clone(),
BinaryOp::LogicalOr,
quote_ident!("[]").into(),
Copy link
Member

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": "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们是不是也叫 namespace 好一点

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack 的默认值也是 "" 吗?

Copy link
Member Author

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 }])
Copy link
Member

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。

Copy link
Member Author

@PeachScript PeachScript Dec 13, 2023

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": "",
Copy link
Member

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() %>'] || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段感觉也是可以按需载入的,如果没有打包出前置加载的 chunk,应该不需要。

Copy link
Member Author

@PeachScript PeachScript Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已线下沟通,先不做处理

@sorrycc sorrycc merged commit 295416c into master Dec 13, 2023
@delete-merged-branch delete-merged-branch bot deleted the feature/pre-install-chunks branch December 13, 2023 03:13
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.

3 participants