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: support load with jsx enabled js #1079

Merged
merged 1 commit into from
Apr 23, 2024
Merged

feat: support load with jsx enabled js #1079

merged 1 commit into from
Apr 23, 2024

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented Apr 23, 2024

Close #1017

Summary by CodeRabbit

  • New Features

    • Added support for handling additional content types like "ts", "tsx", and "jsx" in the app.
    • Enhanced the structure of returned content with the introduction of a new struct JsContent.
    • Updated file processing logic to include new properties for JavaScript content handling.
    • Modified the load function signature to support more file types like jsx, ts, and tsx.
    • Improved JSX file identification within the codebase.
  • Bug Fixes

    • Fixed handling of specific cases in the load function to ensure correct object returns.
  • Documentation

    • Updated documentation related to the load function within the MakoPlugin interface and hooks section.
  • Refactor

    • Restructured content handling for various file types like CSS, JS, SVG, TOML, YAML, XML, and JSON.
  • Style

    • Adjusted import statements and variable names for consistency and clarity in different modules.
  • Tests

    • Added an assertion for checking a specific JSX pattern in the content.
  • Chores

    • Introduced a new file foo.bar with a comment indicating it should be handled with a load hook.

Copy link
Contributor

coderabbitai bot commented Apr 23, 2024

Walkthrough

The changes involve introducing JsContent to handle JavaScript-related content across various modules in the mako crate. This includes updating struct definitions, enum variants, and method implementations to accommodate JSX files and enhance JavaScript content handling.

Changes

File Change Summary
crates/binding/src/js_plugin.rs Modified import statements and added handling for "ts", "tsx", and "jsx" content types in JsPlugin.
crates/mako/src/ast/...file.rs Added JsContent, updated Content enum to hold JsContent, and adjusted methods to support the new structure.
crates/mako/src/ast/...js_ast.rs Updated logic for jsx determination, imported JsContent, and adjusted Content::Js construction.
crates/mako/src/ast/tests.rs Introduced JsContent, updated Content enum, and added is_jsx variable for JSX file detection.
crates/mako/src/build.rs Added JsContent, updated Content::Js usage, and adjusted content setting for File instances.
crates/mako/src/load.rs Introduced JsContent, modified Content::Js variants, and added is_jsx flag for various file types.
crates/mako/src/parse.rs Added JsContent import, adjusted JavaScript content generation, and updated content settings for JS files.
crates/mako/src/plugins/...context_module.rs Modified import statement, replaced code with content, and updated return value to include JsContent.
crates/mako/src/plugins/...minifish.rs Added JsContent struct, updated return value in a match block to use JsContent for enhanced content structure.
crates/mako/src/plugins/...inject.rs Modified import statements to include JsContent, and initialized File instances with JsContent struct.
crates/mako/src/transform.rs Modified JSX file identification logic to include is_content_jsx() method call in addition to extension checks.
docs/api.md Updated load function signature to support additional file types like jsx, ts, and tsx.
e2e/fixtures/hooks/expect.js Added assertion for a specific JSX pattern in foo.bar.
e2e/fixtures/hooks/hooks.config.js Added conditional check in load function for handling paths ending with 'foo.bar'.
e2e/fixtures/hooks/src/foo.bar New file indicating it should be handled with a load hook.
e2e/fixtures/hooks/src/index.tsx Replaced console.log(1) with console.log(require('./foo.bar')) for dynamic logging.

Poem

In the code's dance,
JsContent joins the trance.
JSX files now sing,
A melody of change they bring.
CodeRabbit hops with glee,
Embracing this tech jubilee!

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


Commits Files that changed from the base of the PR and between cb00ebe and 1c0c4c9.
Files selected for processing (17)
  • crates/binding/src/js_plugin.rs (2 hunks)
  • crates/mako/src/ast/file.rs (4 hunks)
  • crates/mako/src/ast/js_ast.rs (3 hunks)
  • crates/mako/src/ast/tests.rs (3 hunks)
  • crates/mako/src/build.rs (4 hunks)
  • crates/mako/src/load.rs (8 hunks)
  • crates/mako/src/parse.rs (3 hunks)
  • crates/mako/src/plugins/context_module.rs (3 hunks)
  • crates/mako/src/plugins/farm_tree_shake/shake/find_export_source.rs (2 hunks)
  • crates/mako/src/plugins/minifish.rs (2 hunks)
  • crates/mako/src/plugins/minifish/inject.rs (2 hunks)
  • crates/mako/src/transform.rs (1 hunks)
  • docs/api.md (2 hunks)
  • e2e/fixtures/hooks/expect.js (1 hunks)
  • e2e/fixtures/hooks/hooks.config.js (1 hunks)
  • e2e/fixtures/hooks/src/foo.bar (1 hunks)
  • e2e/fixtures/hooks/src/index.tsx (1 hunks)

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @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.

@sorrycc sorrycc merged commit f14bae7 into master Apr 23, 2024
8 checks passed
@delete-merged-branch delete-merged-branch bot deleted the sorrycc-bnqv branch April 23, 2024 07:31
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.

parse transfrom 不以文件后缀判断处理文件
1 participant