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

fix: chunk_loading_global #1590

Merged
merged 2 commits into from
Sep 13, 2024
Merged

fix: chunk_loading_global #1590

merged 2 commits into from
Sep 13, 2024

Conversation

xusd320
Copy link
Contributor

@xusd320 xusd320 commented Sep 13, 2024

If the chunk_loading_global String contains a single quote, it will be sanitized to ' see rust-sailfish/sailfish#145 (comment). This behavior is not matched with async chunk register.

Summary by CodeRabbit

  • 新功能

    • 更新了全局变量 chunkLoadingGlobal 的处理方式,采用 JSON 字符串表示。
    • 引入新的配置文件 mako.config.json,允许自定义全局上下文的 chunk 加载设置。
    • 新增文件 a.ts,导出简单字符串值 'a'。
    • index.tsx 中实现动态导入模块,优化性能。
  • 测试

    • 新增文件 expect.js,验证全局变量在构建文件中的存在性。

Copy link
Contributor

coderabbitai bot commented Sep 13, 2024

Walkthrough

此次更改涉及对 chunk_loading_global 配置的处理方式进行调整。util.rs 文件中的 runtime_code 函数将 chunk_loading_global 值从直接克隆改为序列化为 JSON 字符串。此外,app_runtime.stpl 文件中的全局变量访问语法也进行了修改,以确保在模板中安全输出。新添加的测试文件和配置文件增强了对全局变量的验证和配置能力。

Changes

文件路径 更改摘要
crates/mako/src/generate/chunk_pot/util.rs 修改 runtime_code 函数,处理 chunk_loading_global 从克隆改为 JSON 序列化。
crates/mako/templates/app_runtime.stpl 修改 createRuntime 函数中对 chunkLoadingGlobal 的访问方式,从 <%= %> 改为 <%- %>
e2e/fixtures/config.output.chunk_loading_global/expect.js 新增文件,包含对全局变量在 index.js 和异步块文件中的存在性验证。
e2e/fixtures/config.output.chunk_loading_global/mako.config.json 新增配置文件,设置 chunkLoadingGlobal"foo' oo"
e2e/fixtures/config.output.chunk_loading_global/src/a.ts 新增文件,导出字符串 'a'
e2e/fixtures/config.output.chunk_loading_global/src/index.tsx 新增动态导入模块 a,并在控制台输出数字 1

Possibly related PRs

Poem

🐇 在代码的世界里跳跃,
全局变量闪闪发光,
JSON序列化如春风,
安全输出不再迷茫。
兔子欢呼,庆祝变化,
让我们一起迎接新的希望! 🌟

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
e2e/fixtures/config.output.chunk_loading_global/src/index.tsx (1)

2-2: 考虑移除或改进日志语句。

当前的 console.log(1) 语句没有提供有意义的信息。建议移除该语句,或者记录一些更有价值的变量或消息。

例如:

-console.log(1);
+// console.log(1);

或者:

-console.log(1);
+console.log('Module loaded successfully');
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 672ee42 and df4d6ec.

Files selected for processing (6)
  • crates/mako/src/generate/chunk_pot/util.rs (1 hunks)
  • crates/mako/templates/app_runtime.stpl (1 hunks)
  • e2e/fixtures/config.output.chunk_loading_global/expect.js (1 hunks)
  • e2e/fixtures/config.output.chunk_loading_global/mako.config.json (1 hunks)
  • e2e/fixtures/config.output.chunk_loading_global/src/a.ts (1 hunks)
  • e2e/fixtures/config.output.chunk_loading_global/src/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • e2e/fixtures/config.output.chunk_loading_global/src/a.ts
Additional comments not posted (2)
e2e/fixtures/config.output.chunk_loading_global/mako.config.json (1)

1-5: 配置文件看起来不错!

这个新的配置文件正确地设置了 chunkLoadingGlobal 属性的值,其中包含一个单引号字符。这与 PR 的目标一致,即修复包含单引号的 chunk_loading_global 字符串的处理问题。

配置文件的格式正确,没有发现任何问题。

e2e/fixtures/config.output.chunk_loading_global/expect.js (1)

1-16: 测试文件设置正确,断言语句全面覆盖了入口文件和异步 chunk 文件中全局变量的检查。

该测试文件使用了适当的工具函数来解析构建结果,并使用 assert 语句正确地检查了 foo' oo 全局变量在 index.jssrc_a_ts-async.js 文件中的存在性。测试内容全面,涵盖了入口文件和异步 chunk 文件两种情况。

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.17%. Comparing base (421560f) to head (df4d6ec).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1590      +/-   ##
==========================================
+ Coverage   62.05%   62.17%   +0.11%     
==========================================
  Files         127      128       +1     
  Lines       15358    15528     +170     
==========================================
+ Hits         9531     9655     +124     
- Misses       5827     5873      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xusd320 xusd320 merged commit 910dd76 into master Sep 13, 2024
21 checks passed
@xusd320 xusd320 deleted the fix/entry-chunk-loading branch September 13, 2024 06:53
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.

1 participant