-
-
Notifications
You must be signed in to change notification settings - Fork 754
feat(css): introduce resolveImport parser option for css parser to choose whether to resolve @import syntax
#12672
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
resolveImport parser option for css parser to choose wether to resolve @import syntaxresolveImport parser option for css parser to choose whether to resolve @import syntax
resolveImport parser option for css parser to choose whether to resolve @import syntaxresolveImport parser option for css parser to choose whether to resolve @import syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a resolveImport parser option for CSS parsers (css/auto, css, and css/module) that allows users to control whether @import syntax should be resolved. This provides functionality similar to css-loader's import option.
Key Changes:
- Adds
resolveImportoption supporting boolean or function values to filter@importstatements - Implements the feature across TypeScript and Rust layers
- Adds documentation in both English and Chinese
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/en/config/module.mdx | Adds English documentation for the new resolveImport option across all CSS parser types |
| website/docs/zh/config/module.mdx | Adds Chinese documentation for the new resolveImport option across all CSS parser types |
| packages/rspack/src/config/types.ts | Defines TypeScript types for CssParserResolveImport with function signature using individual parameters |
| packages/rspack/src/config/adapter.ts | Adds adapter logic to convert user-facing API to napi layer (with workaround for missing FnArgs) |
| packages/rspack/etc/core.api.md | Updates public API documentation with new types |
| crates/rspack_core/src/options/module.rs | Defines core Rust types for CssParserImport enum and related structures |
| crates/rspack_binding_api/src/raw_options/raw_module/mod.rs | Implements napi bindings for the resolveImport option (with bugs in ThreadsafeFunction usage) |
| crates/node_binding/napi-binding.d.ts | Auto-generated TypeScript declarations (contains incorrect function signatures) |
| crates/rspack_plugin_css/src/parser_and_generator/mod.rs | Implements the actual import filtering logic in the CSS parser |
| crates/rspack_plugin_css/src/plugin/impl_plugin_for_css_plugin.rs | Wires up the resolveImport option to parser instances |
| tests/rspack-test/configCases/css/import-filter/* | Test case for function-based filtering of @import statements |
| tests/rspack-test/configCases/css/import-false/* | Test case for disabling all @import resolution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 22.75KB from 47.87MB to 47.90MB (⬆️0.05%) |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
| resourcePath: string, | ||
| supports: string | undefined, | ||
| layer: string | undefined, | ||
| ) => boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pass a context object instead of flat parameters?
export type CssParserResolveImport =
| boolean
| (context: {
url: string,
media: string | undefined,
resourcePath: string,
supports: string | undefined,
layer: string | undefined,
} => boolean);| <ApiMeta addedVersion="1.7.2" /> | ||
| - **Type:** `boolean | ((url: string, media: string, resourcePath: string, supports: string, layer: string) => boolean)` | ||
| - **Default:** `undefined` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default to true?
Summary
This is for providing the same capability as
css-loader.Provide users a way to choose whether to resolve
@importsyntax in css modules.Related links
Checklist