feat(css): support ignore magic comments - #15314
Conversation
aaa5b69 to
6a4ec99
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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".
Merging this PR will improve performance by 3%
|
| 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)
Footnotes
-
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. ↩
7c73e80 to
68fa80c
Compare
There was a problem hiding this comment.
💡 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".
68fa80c to
6ca8a91
Compare
There was a problem hiding this comment.
💡 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".
| expect(source.match(/\.resolve\(\/\* webpackIgnore: true \*\/ "\.\/non-exists"\)/g)).toHaveLength(3); | ||
| expect(source.match(/\.resolve\(\/\* rspackIgnore: true \*\/ "\.\/non-exists"\)/g)).toHaveLength(3); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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", () => {}); |
There was a problem hiding this comment.
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 👍 / 👎.
2fa4726 to
8a998ef
Compare
There was a problem hiding this comment.
💡 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) { |
There was a problem hiding this comment.
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 👍 / 👎.
8a998ef to
3706eb8
Compare
There was a problem hiding this comment.
💡 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".
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
webpackIgnoreon CSS@import,url(), andimage-set()dependenciesrspackIgnoreas the Rspack alias, including alias precedence and conflict diagnosticscreateRequire(...).resolve()ignore config casesTests
cargo clippy -p css-module-lexer --tests -- -D warningspnpm run lint:jspnpm --dir tests/rspack-test run test --project base -t require-resolve-ignorepnpm --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'