Skip to content

Conversation

@JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Jan 8, 2026

Summary

This is for providing the same capability as css-loader.

Provide users a way to choose whether to resolve @import syntax in css modules.

export default {
  module: {
    parser: {
      'css/module': {
        resolveImport: (url, media, resourcePath, supports, layer) => {
          return url.includes('style.css');
        },
      },
    },
  },
};

Related links

Checklist

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

@JSerFeng JSerFeng requested a review from hardfist as a code owner January 8, 2026 07:31
Copilot AI review requested due to automatic review settings January 8, 2026 07:31
@netlify
Copy link

netlify bot commented Jan 8, 2026

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit 8c124a0
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69607d49d6a87b000889f26c
😎 Deploy Preview https://deploy-preview-12672--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: feature release: feature related release(mr only) labels Jan 8, 2026
@JSerFeng JSerFeng changed the title feat: introduce resolveImport parser option for css parser to choose wether to resolve @import syntax feat: introduce resolveImport parser option for css parser to choose whether to resolve @import syntax Jan 8, 2026
@JSerFeng JSerFeng changed the title feat: introduce resolveImport parser option for css parser to choose whether to resolve @import syntax feat(css): introduce resolveImport parser option for css parser to choose whether to resolve @import syntax Jan 8, 2026
Copy link
Contributor

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

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 resolveImport option supporting boolean or function values to filter @import statements
  • 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

📦 Binary Size-limit

Comparing 8c124a0 to refactor: use DerfOpt's take/replace assist artifact mutation (#12659) by pshu

❌ Size increased by 22.75KB from 47.87MB to 47.90MB (⬆️0.05%)

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 8, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing rspack-sub2 (8c124a0) with main (29642b2)

Summary

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@JSerFeng JSerFeng enabled auto-merge (squash) January 9, 2026 03:48
resourcePath: string,
supports: string | undefined,
layer: string | undefined,
) => boolean);
Copy link
Member

@chenjiahan chenjiahan Jan 9, 2026

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`
Copy link
Member

Choose a reason for hiding this comment

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

Default to true?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature 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.

3 participants