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: re-implement module concatenate #1295

Merged
merged 46 commits into from
Jun 24, 2024
Merged

Conversation

stormslowly
Copy link
Member

@stormslowly stormslowly commented Jun 20, 2024

close #1231
improve #1165

inner 和 root transform 合并到 concatenate transform 中, concatenate transform 中 使用 var_link 的方式将 import/export 的符号 link 到原始的符号, 以保证 import/export reference 的性质。

import  {x as bar} from "inner"
console.log(bar)

转换成

console.log(x)
import { y as foo} from "ext"
console.log(foo)

转换成

import { y as foo} from "ext"
console.log(ext_namespace.y)

Summary by CodeRabbit

  • 新功能

    • 引入了JavaScript模块中共享引用的测试案例。
    • module模块中添加valuesetValue导出项。
    • 文件index.js引入了case文件。
  • 文档

    • 更新了JSON配置文件中的路径引用,从"index": "index.js"修改为"index": "./index.js"
  • e2e/fixtures/webpack.side-effects.empty-modules/expect.js

    • 引入了Webpack副作用和模块定义的逻辑,包括验证构建输出中特定模块定义的存在或缺失。
  • e2e/fixtures/javascript.tsx.preact/mako.config.json

    • 在Preact TypeScript项目的mako.config.json文件中,将optimization配置中的concatenateModules设置从false更改为true

Copy link
Contributor

coderabbitai bot commented Jun 20, 2024

Walkthrough

这次改动涉及对模块合并的各个方面的调整,包括添加新模块、重构现有代码、简化逻辑和优化结构。有关模块连接、导出处理和优化的代码进行了明显的改进和更新。

Changes

文件 改动摘要
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate 添加了新模块,调整了逻辑和模块优化处理。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/concatenate_context.rs 引入新类型和方法,加强导出处理。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/external_transformer.rs 重构代码,简化导入和外部模块处理。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/inner_transformer.rs 增加新的枚举、结构体、方法和函数,优化导入和导出处理。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/inner_transformer/external_tests.rs 引入外部测试单元,测试导入和导出外部模块的场景。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/inner_transformer/tests.rs 修改了现有测试用例,增加新测试用例,更新导入和导出的逻辑。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/inner_transformer/utils.rs 引入处理导出映射的函数。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/module_ref_rewriter.rs 添加了重写模块引用的结构体和方法。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/concatenated_transformer.rs 重命名结构体和方法,更新导入和导出处理。
crates/mako/src/plugins/farm_tree_shake/shake/module_concatenate/exports_transform.rs 移除了对 HashMap 的引用,优化导出处理。

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.

@stormslowly stormslowly changed the title wip feat: re-implement module concatenate feat: re-implement module concatenate Jun 24, 2024
@stormslowly stormslowly merged commit f47703e into master Jun 24, 2024
8 checks passed
@stormslowly stormslowly deleted the fix/runtime_execute_order branch August 9, 2024 06:00
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[concatenate]: handle reexport from ext
1 participant