Skip to content

Commit

Permalink
fix: pass props to custom bootstrap (#5731)
Browse files Browse the repository at this point in the history
Co-authored-by: nyqykk <nieyan.kk@bytedance.com>
  • Loading branch information
nyqykk and nyqykk committed May 11, 2024
1 parent d10d0bf commit d7e6c67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-sheep-scream.md
@@ -0,0 +1,5 @@
---
'@modern-js/plugin-garfish': patch
---

fix: parse props to custom bootstrap
6 changes: 6 additions & 0 deletions packages/runtime/plugin-garfish/src/cli/utils.ts
Expand Up @@ -102,6 +102,12 @@ export const makeRenderFunction = (code: string) => {
`customBootstrap(AppWrapper`,
'customBootstrap(AppWrapper, mountNode',
)
/*
传递 props 给 customBootstrap
(.*):.代表任何字符(除了换行符),*代表前面的字符可以出现任意次数,包括0次。所以这部分匹配任何在 customBootstrap 括号中的内容,并且用括号()标记为一个捕获组,留待之后引用。
'customBootstrap($1, props)': 这是替换模式。$1是一个特殊的符号,用于引用前面正则表达式中的第一个捕获组。
*/
.replace(/customBootstrap\((.*)\)/g, 'customBootstrap($1, props)')
);
};

Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d7e6c67

Please sign in to comment.