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: add experimental.webpackSyntaxValidate config #1080

Merged
merged 2 commits into from
Apr 23, 2024
Merged

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented Apr 23, 2024

ref: #1078

1、添加 experimental.webpackSyntaxValidate 配置,后续试验性配置收到 experimental 下
2、rename plugin invalid_syntax.rs to invalid_webpack_syntax.rs

Summary by CodeRabbit

  • New Features
    • Added experimental webpack syntax validation feature.
    • Introduced webpackSyntaxValidate configuration option.
    • Updated plugins to support webpack syntax validation.
    • Added experimental configuration documentation.
    • Enhanced end-to-end testing for webpack syntax validation.

Copy link
Contributor

coderabbitai bot commented Apr 23, 2024

Walkthrough

The changes bring experimental webpack syntax validation to Mako, enabling precise control over allowed syntax. This involves introducing new configurations, renaming plugins, and updating logic to enforce restrictions on webpack syntax usage.

Changes

File Summary
crates/binding/src/lib.rs Added an experimental field with a webpackSyntaxValidate array to the BuildParams struct.
crates/mako/src/compiler.rs Renamed the InvalidSyntaxPlugin to InvalidWebpackSyntaxPlugin within the list of plugins instantiated in the Compiler implementation.
crates/mako/src/config/config.rs Added a new ExperimentalConfig struct with a field webpack_syntax_validate. Added an experimental field of type ExperimentalConfig to the Config struct.
crates/mako/src/plugins/invalid_webpack_syntax.rs Renamed the InvalidSyntaxPlugin struct to InvalidWebpackSyntaxPlugin. Updated the name method to return "invalid_webpack_syntax". Modified the logic in the transform_js method to check for specific packages in the param.path based on a whitelist provided in context.config.experimental.webpack_syntax_validate.
crates/mako/src/plugins/mod.rs Changed the module name from invalid_syntax to invalid_webpack_syntax in the plugins module.
docs/config.md Added a new experimental configuration webpackSyntaxValidate to specify packages allowed to use webpack syntax.
e2e/fixtures/config.experimental.webpack_syntax_validate/expect.js Introduces functionality to validate experimental webpack syntax in a configuration file. Includes assertions to check for specific webpack syntax in the generated build output.
e2e/fixtures/config.experimental.webpack_syntax_validate/mako.config.json Introduces experimental webpack syntax validation for a specific item "foo" with minification disabled.
e2e/fixtures/config.experimental.webpack_syntax_validate/node_modules/foo/index.js Introduces a conditional block that checks for the presence of __webpack_require__ as a function and then calls __webpack_require__('abc') within that block.
e2e/fixtures/config.experimental.webpack_syntax_validate/node_modules/foo/package.json Introduces a basic configuration for a package named "foo."
e2e/fixtures/config.experimental.webpack_syntax_validate/src/index.tsx Imports 'foo' and logs the number 1 to the console.
packages/mako/binding.d.ts Added an experimental field with a webpackSyntaxValidate array property to the BuildParams interface.

Poem

In webpack's dance, Mako takes a chance,
Syntax experimental, in a whimsical trance.
Renaming plugins, enforcing rules with grace,
A rabbit's code, in a poetic embrace. 🐇✨

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 c80164d and d4695e3.
Files selected for processing (1)
  • crates/mako/src/plugins/invalid_webpack_syntax.rs (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 f18f8c0 into master Apr 23, 2024
8 checks passed
@delete-merged-branch delete-merged-branch bot deleted the sorrycc-419j branch April 23, 2024 08:05
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.

2 participants