Skip to content

Conversation

chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Oct 13, 2025

Summary

  • Fix the 'swc_plugin_import' panic that occurs when invalid options are passed.
  • Remove all .unwrap() calls.
  • Optimize diagnostic logs.

Before

customName: "{{ unknown member }}"

Screenshot 2025-10-13 at 21 49 48

customName: "{{ member"

Screenshot 2025-10-13 at 19 06 07

After

customName: "{{ unknown member }}"

image

customName: "{{ member"

image

customName: "{{ }}"

image

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 14:17
Copy link

netlify bot commented Oct 13, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 1ac5198
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68ed0a4802f8380008f8f66a

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Oct 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes panic in swc_plugin_import when invalid template options are provided and improves diagnostic error messages. The changes convert panics to proper error handling with clearer error messages that include context about which configuration option failed.

  • Add proper error handling for template parsing instead of using unwrap()
  • Update error messages to be more descriptive and user-friendly
  • Add test cases for invalid template configurations

Reviewed Changes

Copilot reviewed 16 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/swc_plugin_import/src/template.rs Updates error types and messages for better diagnostics
crates/swc_plugin_import/src/lib.rs Replaces unwrap() calls with proper error handling and improved error messages
tests/rspack-test/configCases/builtin-swc-loader/plugin-import-invalid-template/* Test case for empty template strings
tests/rspack-test/configCases/builtin-swc-loader/plugin-import-invalid-helper/* Test case for invalid helper configurations
tests/rspack-test/configCases/builtin-swc-loader/plugin-import-imcomplate-template/* Test case for incomplete template strings
tests/rspack-test/configCases/builtin-swc-loader/issue-5329/* Removes outdated test files
Comments suppressed due to low confidence (2)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

📦 Binary Size-limit

Comparing 1ac5198 to chore(deps): update patch npm dependencies (#11806) by renovate[bot]

🎉 Size decreased by 282.00KB from 47.89MB to 47.62MB (⬇️0.58%)

Copy link

codspeed-hq bot commented Oct 13, 2025

CodSpeed Performance Report

Merging #11862 will not alter performance

Comparing plugin_import_panic (1ac5198) with main (a915dab)

Summary

✅ 17 untouched

@chenjiahan chenjiahan requested a review from JSerFeng October 14, 2025 02:37
@chenjiahan chenjiahan enabled auto-merge (squash) October 14, 2025 02:38
@chenjiahan chenjiahan merged commit 376a74f into main Oct 14, 2025
68 of 72 checks passed
@chenjiahan chenjiahan deleted the plugin_import_panic branch October 14, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants