From daf946be0aad6ea432a42b684f865b5934d7765f Mon Sep 17 00:00:00 2001 From: sorrycc Date: Mon, 6 May 2024 10:22:19 +0800 Subject: [PATCH] feat: add global __mako_chunk_load__ --- crates/mako/templates/app_runtime.stpl | 1 + examples/rsc/build.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/mako/templates/app_runtime.stpl b/crates/mako/templates/app_runtime.stpl index 9a0bf943d..12edcc080 100644 --- a/crates/mako/templates/app_runtime.stpl +++ b/crates/mako/templates/app_runtime.stpl @@ -334,6 +334,7 @@ function createRuntime(makoModules, entryModuleId, global) { // __inject_runtime_code__ global.__mako_require_module__ = requireModule; + global.__mako_chunk_load__ = requireModule.ensure; <% if umd.is_some() || cjs { %> var exports = requireModule(entryModuleId); <% } else { %> diff --git a/examples/rsc/build.js b/examples/rsc/build.js index 3f83490e5..64978dbdf 100644 --- a/examples/rsc/build.js +++ b/examples/rsc/build.js @@ -36,8 +36,11 @@ module.exports = {$$typeof: Symbol.for(\"react.module.reference\"),filepath:\"{{ }); // build client - fs.rmdirSync(path.join(root, 'tmp'), { recursive: true }); - fs.mkdirSync(path.join(root, 'tmp')); + let tmpDir = path.join(root, 'tmp'); + if (fs.existsSync(tmpDir)) { + fs.rmdirSync(tmpDir, { recursive: true }); + } + fs.mkdirSync(tmpDir); let stats = fs.readFileSync( path.join(serverOutputPath, 'stats.json'), 'utf-8',