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(bundler-mako): generate dynamicImportToRequire from babel and webpack config #1479

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

PeachScript
Copy link
Member

@PeachScript PeachScript commented Aug 8, 2024

支持将 Webpack 的 output.asyncChunks 配置以及 Umi 此前在用的 babel-plugin-dynamic-import-node 转成 Mako 的 dynamicImportToRequire 配置项

Close #1470

Summary by CodeRabbit

  • 新功能

    • 添加了对动态导入的支持,提升了构建过程中的灵活性。
    • 增加了一个简单的模块,能够异步导入其他模块,从而优化应用性能。
  • 修复

    • 增强了插件处理和配置管理的逻辑,以便更好地支持动态导入插件。
  • 测试

    • 引入了测试脚本,以验证构建过程中生成的 JavaScript 文件数量是否正确。

@PeachScript PeachScript requested review from sorrycc and bravepg August 8, 2024 02:03
Copy link
Contributor

coderabbitai bot commented Aug 8, 2024

Walkthrough

此次更改引入了对 Babel 动态导入的支持,通过配置 babel-plugin-dynamic-import-node 来增强构建过程,从而在不原生支持动态导入的环境中提供兼容性。此外,Webpack 输出设置也得到了增强,尤其是在处理 asyncChunks 配置时,提高了灵活性和可配置性。

Changes

文件 更改摘要
.../config.babel-plugin-dynamic-import-node/.umirc.ts 新增 Babel 配置对象,包含 extraBabelPlugins 数组,支持动态导入。
.../config.babel-plugin-dynamic-import-node/async.ts 新增模块,导出字符串 'a' 作为常量,供其他模块使用。
.../config.babel-plugin-dynamic-import-node/expect.js 新增测试脚本,验证生成的 JavaScript 文件数量是否为一个。
.../config.babel-plugin-dynamic-import-node/pages/index.tsx 新增模块,日志输出并异步动态导入另一个模块,支持代码分割。
.../index.js 修改 checkConfiggetMakoConfig 函数,增强插件处理逻辑及配置管理,特别是在处理 asyncChunks 时。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BuildSystem
    participant Babel
    participant Webpack

    User->>BuildSystem: Initiate Build
    BuildSystem->>Babel: Process Code
    Babel->>Webpack: Handle Dynamic Imports
    Webpack->>BuildSystem: Generate Output
    BuildSystem->>User: Complete Build
Loading

Assessment against linked issues

Objective Addressed Explanation
支持将 Webpack 的 asyncChunks 转换为 Mako 的 dynamicImportToRequire#1470
统一 extraBabelIncludes 的方案为 chainWebpack#1470 相关集成尚未完成。

兔子跳跃,欢声笑语,
动态导入,代码在舞。
Babel 的魔法,Webpack 的力,
一起欢庆,变化无比! 🐰✨


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 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 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: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 711611d and ceb0cea.

Files selected for processing (5)
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/.umirc.ts (1 hunks)
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/async.ts (1 hunks)
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/expect.js (1 hunks)
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/pages/index.tsx (1 hunks)
  • packages/bundler-mako/index.js (4 hunks)
Files skipped from review due to trivial changes (4)
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/.umirc.ts
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/async.ts
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/expect.js
  • e2e/fixtures.umi/config.babel-plugin-dynamic-import-node/pages/index.tsx
Additional comments not posted (3)
packages/bundler-mako/index.js (3)

391-393: 更改已批准:添加对 dynamic-import-node 插件的检查。

此更改符合 PR 的目标,确保函数识别额外的插件类别,不会触发警告。


452-457: 更改已批准:处理 asyncChunks 配置。

此更改增强了输出设置的可配置性,符合 PR 的目标。


534-539: 更改已批准:将 babel-plugin-dynamic-import-node 转换为 dynamicImportToRequire

此更改改进了动态导入的处理,符合 PR 的目标。

建议验证此更改与代码库其他部分的集成。

Verification successful

验证通过:dynamicImportToRequire 已在代码库中成功集成。

dynamicImportToRequire 在多个关键文件中出现,包括配置文件、文档和源代码,表明其已被充分集成和记录。无需进一步操作。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `dynamicImportToRequire` in the codebase.

# Test: Search for `dynamicImportToRequire` usage. Expect: Consistent integration across the codebase.
rg --type javascript -A 5 $'dynamicImportToRequire'

Length of output: 85


Script:

#!/bin/bash
# Description: Re-verify the integration of `dynamicImportToRequire` in the codebase.

# Test: Search for `dynamicImportToRequire` usage. Expect: Consistent integration across the codebase.
rg -A 5 'dynamicImportToRequire'

Length of output: 4626

@sorrycc sorrycc merged commit 114a0ea into master Aug 8, 2024
12 checks passed
@PeachScript PeachScript deleted the feature/bundler-mako-dynamic-to-require branch August 9, 2024 01:10
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.

feat: support to transform asyncChunks config in bundler-mako
2 participants