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(concatenate): exports conflict between root and inner #1256

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

stormslowly
Copy link
Member

@stormslowly stormslowly commented Jun 6, 2024

运行时保护,避免 export 冲突
对齐 webpack 处理,root 导出优先

close #1255

Summary by CodeRabbit

  • 新功能
    • 更新了RootTransformer中的define_exports变量赋值,从__mako_require__.e更改为__mako_require__.es
    • runtime_code函数中添加了concatenate_enabled字段,指示模块串联是否启用。
    • AppRuntimeTemplate结构体添加了concatenate_enabled公共布尔字段。
    • app_runtime.stplcreateRuntime函数中增加了Export Star实用函数requireModule.es
    • 新增了用于特定模块的测试工具和文件解析的修改,包括注入Jest、解析构建结果、检查文件内容的函数。
    • ext.js中引入了常量extvalue的导出,以及默认导出"ext-default"
    • 新增了检查跳过内部模块冲突导出的测试用例。
    • inner.js中引入了导出常量valuenotConflict和默认导出"inner-default"
    • mako.config.json引入了与项目优化相关的配置设置,指定了入口点和与模块处理相关的优化选项。
    • root.js中引入了来自inner.jsext.js的导出,并定义了常量value

Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

这次改动集中在优化模块拼接和导出实体声明的更新。新增了一些字段和函数以支持模块拼接功能,并调整了导出实体声明以适应这些变化。

Changes

文件 改动摘要
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/root_transformer.rs 更新了 RootTransformer 中的 define_exports 变量赋值。
crates/mako/src/generate/chunk_pot/util.rs
crates/mako/src/generate/runtime.rs
util.rs 中添加了 concatenate_enabled 字段,同时在 runtime.rs 中新增了 AppRuntimeTemplate 结构体的 concatenate_enabled 字段。
crates/mako/templates/app_runtime.stpl app_runtime.stpl 中的 createRuntime 函数中增加了 requireModule.es 函数。
e2e/fixtures/mako.scope-hoisting.export_conflict_with_root/expect.js
e2e/fixtures/mako.scope-hoisting.export_conflict_with_root/ext.js
e2e/fixtures/mako.scope-hoisting.export_conflict_with_root/index.js
e2e/fixtures/mako.scope-hoisting.export_conflict_with_root/inner.js
e2e/fixtures/mako.scope-hoisting.export_conflict_with_root/root.js
引入了新的测试文件和模块,包括函数、常量和模块间的导出关系变化。

Poem

兔子敲键盘换新衣,模块拼接添新辉。

导出声明微调心悦目,代码间舞动如诗意。 🐇📦


Note

Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai

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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

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

+1,验证业务项目可以工作

@sorrycc sorrycc merged commit 510f929 into master Jun 7, 2024
8 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix/concatenate_export_conflict branch June 7, 2024 07:56
sorrycc pushed a commit that referenced this pull request Jun 11, 2024
* test: ✅ export conflict between root exports, inner exports and ext exports

* fix(concatenate): 🐛 fix exports conflict in root inner and ext

* refactor: 🎨 add runtime by utils
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.

bug: redefine non-configurable property error since concatenateModules
3 participants