Skip to content

Revert "fix:dynamic import as namespace import (#1171)"#1208

Merged
stormslowly merged 1 commit intomasterfrom
chore/revert_dynamic_import_as_namespace_import
May 27, 2024
Merged

Revert "fix:dynamic import as namespace import (#1171)"#1208
stormslowly merged 1 commit intomasterfrom
chore/revert_dynamic_import_as_namespace_import

Conversation

@stormslowly
Copy link
Contributor

@stormslowly stormslowly commented May 27, 2024

This reverts commit 5ad6f5f.

Summary by CodeRabbit

  • 新功能
    • transform.rsbundless_compiler.rs中的transform_js_generate函数中,将dynamic_import的初始化更改为使用结构体初始化,并为context赋值,而不是使用DynamicImport::newcontextdep_map一起调用。
    • app_runtime.stplcreateRuntime函数中删除了requireModule.dr函数,影响了动态块加载机制。
    • expect.js文件中,更新了__mako_require__.dr__mako_require__.bind的函数调用,用于在异步块中为不同的JSON文件(zh-CN.jsonen-US.json)生成上下文模块的moduleReg函数。
    • index.tsloadLangExt函数中,重构了功能,改用import代替importrequire的组合,简化了代码结构并提高了可读性。该函数现在直接返回动态导入操作的结果。

@coderabbitai
Copy link

coderabbitai bot commented May 27, 2024

漫游

这次更改涉及多个文件,主要集中在动态导入和模块上下文的调整,以及运行时函数的变更。代码结构和导入机制得到了优化,提高了代码的可读性和效率。

变更

文件路径 变更摘要
crates/mako/src/generate/transform.rs 修改了transform_js_generate函数中dynamic_import的初始化方式,采用了结构体初始化方法。
crates/mako/src/plugins/context_module.rs 调整了context_module.rs文件中表达式参数的赋值方式,从引用m.default改为使用quote_ident!("m")
crates/mako/src/visitors/dynamic_import.rs - 移除了DynamicImport结构体中的interdep_to_replace字段和相关初始化。 - 简化了DynamicImport中的方法实现。 - 更新了处理动态导入的方法实现。
crates/mako/templates/app_runtime.stpl 移除了app_runtime.stplcreateRuntime函数中的requireModule.dr函数,影响了动态块加载机制。
e2e/fixtures/javascript.require-dynamic/expect.js 更新了expect.js文件中的函数调用,从__mako_require__.dr改为__mako_require__.bind,用于生成正确映射的上下文模块。
e2e/fixtures/javascript.require-dynamic/src/index.ts 重构了index.ts中的loadLangExt函数,使用import替代importrequire的组合,简化了代码结构,提高了可读性。函数现在直接返回动态导入操作的结果。
packages/mako/binding.d.ts 引入了新的TransformOutput接口,具有code和可选的map属性,为TransformOutput定义了清晰的接口结构。

诗歌

兔子编码忙改变,代码优化如春风。
动态导入显轻盈,结构清晰如画廊。 🐇🌿


Tip

Early Access Features
  • gpt-4o model for chat

Note

Pull Request 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.

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 full the 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 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 merged commit 6e69d85 into master May 27, 2024
@delete-merged-branch delete-merged-branch bot deleted the chore/revert_dynamic_import_as_namespace_import branch May 27, 2024 08:39
stormslowly added a commit that referenced this pull request May 27, 2024
stormslowly added a commit that referenced this pull request Jun 13, 2024
* Reapply "fix:dynamic import as namespace import (#1171)" (#1208)

This reverts commit 6e69d85.

* release: @umijs/mako@0.4.18-canary.20240528.5

* chore: ⬆️ update pnpm-lock

* release: @umijs/mako@0.5.5-canary.20240606.1

---------

Co-authored-by: Jinbao1001 <nodewebli@gmail.com>
Co-authored-by: sorrycc <sorrycc@gmail.com>
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