Skip to content

feat(css): support ignore magic comments - #15314

Open
JSerFeng wants to merge 6 commits into
web-infra-dev:mainfrom
JSerFeng:tomas/port-webpack-ignore-magic-comments
Open

feat(css): support ignore magic comments#15314
JSerFeng wants to merge 6 commits into
web-infra-dev:mainfrom
JSerFeng:tomas/port-webpack-ignore-magic-comments

Conversation

@JSerFeng

@JSerFeng JSerFeng commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • support webpackIgnore on CSS @import, url(), and image-set() dependencies
  • support rspackIgnore as the Rspack alias, including alias precedence and conflict diagnostics
  • enable migrated CSS and createRequire(...).resolve() ignore config cases

Tests

  • cargo clippy -p css-module-lexer --tests -- -D warnings
  • pnpm run lint:js
  • pnpm --dir tests/rspack-test run test --project base -t require-resolve-ignore
  • pnpm --dir tests/rspack-test run test --project base -t 'css/webpack-ignore'
  • pnpm --dir tests/rspack-test run test --project base -t 'css/rspack-ignore'

@JSerFeng
JSerFeng force-pushed the tomas/port-webpack-ignore-magic-comments branch from aaa5b69 to 6a4ec99 Compare August 24, 2026 08:38
@JSerFeng

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a4ec99a22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/css-module-lexer/src/dependencies.rs Outdated
@codspeed-hq

codspeed-hq Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 3%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 49 untouched benchmarks
⏩ 47 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_module_hashes 8.7 ms 8.4 ms +3%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing JSerFeng:tomas/port-webpack-ignore-magic-comments (3706eb8) with main (a963c03)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@JSerFeng
JSerFeng force-pushed the tomas/port-webpack-ignore-magic-comments branch from 7c73e80 to 68fa80c Compare August 24, 2026 12:30
@JSerFeng
JSerFeng marked this pull request as ready for review August 25, 2026 08:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68fa80c509

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/css-module-lexer/src/dependencies.rs Outdated
@JSerFeng
JSerFeng force-pushed the tomas/port-webpack-ignore-magic-comments branch from 68fa80c to 6ca8a91 Compare August 25, 2026 09:33

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ca8a9131e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +6 to +7
expect(source.match(/\.resolve\(\/\* webpackIgnore: true \*\/ "\.\/non-exists"\)/g)).toHaveLength(3);
expect(source.match(/\.resolve\(\/\* rspackIgnore: true \*\/ "\.\/non-exists"\)/g)).toHaveLength(3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore validation of the ignored createRequire calls

When the ignored call is createRequire(import.meta.url).resolve(...), these assertions only count the surviving .resolve(...) text and never verify that the node:module import and import.meta.url remain intact or execute bundle1. That is precisely the behavior identified by the deleted test.filter.js, so this test can now pass while the emitted entry is unusable at runtime because createRequire was removed or its base was transformed; retain the original source assertions for those constructs or execute the generated entry before enabling this case.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2fa4726cdf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


expect(css).toMatchSnapshot();
});
it("should compile", () => {});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Assert that webpackIgnore changes the emitted CSS

This empty test only verifies that the fixture compiles. All assets referenced by its ignored URLs exist, so the multiple-comment precedence and quoted, unquoted, and image-set() ignore paths can stop working while this case still passes; the new rspack-ignore case does not cover those forms. Retain emitted-CSS assertions for this migrated fixture instead of enabling it without validating its behavior.

AGENTS.md reference: AGENTS.md:L121-L122

Useful? React with 👍 / 👎.

@JSerFeng
JSerFeng force-pushed the tomas/port-webpack-ignore-magic-comments branch from 2fa4726 to 8a998ef Compare August 25, 2026 10:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a998efede

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} => self.handle_url(request, *range, *kind),
magic_comments,
} => {
if self.should_ignore_magic_comments(*magic_comments, *range) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate magic-comment parsing behind CSS parser options

When a rule sets parser.url: false and a preserved URL has a malformed or non-boolean ignore comment such as /* webpackIgnore: 1 */, this call still parses the comment and emits a warning before handle_url checks the option. The analogous import branch does the same for parser.import: false, so configurations that intentionally disable dependency handling can now fail under warnings-as-errors even though the URL or import is left untouched; check the corresponding parser option before parsing its magic comments.

Useful? React with 👍 / 👎.

@JSerFeng
JSerFeng force-pushed the tomas/port-webpack-ignore-magic-comments branch from 8a998ef to 3706eb8 Compare August 26, 2026 04:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3706eb8017

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3222 to +3225
if magic_comments.is_none()
&& let Some(range) = self.balanced.last().and_then(|item| item.magic_comments)
{
magic_comments = lexer.slice(range.start, range.end);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain function-level ignore across inner comments

When a quoted URL has a function-level ignore comment followed by any ordinary comment inside the function, such as /* webpackIgnore: true */ url(/* note */ "./missing.png"), magic_comments_before returns the inner comment, so this is_none() fallback never restores the ignore comment saved on the balanced url( item. The parser consequently finds no ignore option and attempts to resolve the missing asset; combine the function-level and argument-level comment groups, or fall back when the inner group contains no applicable ignore directive.

Useful? React with 👍 / 👎.

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