-
Notifications
You must be signed in to change notification settings - Fork 0
Add native support for Sass pkg: scheme imports
#61
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
Conversation
Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
pkg: scheme imports
|
@copilot CI is failing: ✖ failing tests: test at test/css.test.ts:1:1891 |
The NodePackageImporter expects standard pkg: URLs (e.g., pkg:package/file.scss) and treats pkg:#styles/file.scss as invalid (# is interpreted as URL fragment, leaving an empty path). Custom resolvers handle pkg:# imports themselves, so NodePackageImporter should only be added when no custom resolver is present. Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
Fixed in commit 8e76c42. The issue was that The fix ensures |
|
@copilot Why would we need a custom resolver for |
Custom importers handle project-specific pkg: variants (e.g., pkg:#subpath) and are placed first in the importers list. NodePackageImporter is added after to handle standard pkg:package URLs. Both can coexist and work together. Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
You're right that The Fixed in commit 6d05c53: Both custom importers and NodePackageImporter now coexist. Custom importers run first to handle project-specific |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
- Coverage 92.22% 92.11% -0.12%
==========================================
Files 14 14
Lines 3924 3982 +58
Branches 690 704 +14
==========================================
+ Hits 3619 3668 +49
- Misses 278 287 +9
Partials 27 27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot agreed that sass node package imports are designed to work with |
Implemented native The importer manually parses package.json to map subpath imports (e.g., Test updated to demonstrate usage without custom resolvers. |
Implements a built-in Sass importer that resolves pkg:# imports using package.json imports field, providing native bundler-style resolution without requiring custom resolvers. The importer: - Parses package.json to map subpath imports (e.g., #styles/* → ./styles/*) - Applies Sass-specific path resolution (partials, index files) - Works alongside custom resolvers for backward compatibility Removed NodePackageImporter to avoid conflicts with pkg:# handling. Co-authored-by: knightedcodemonkey <139886941+knightedcodemonkey@users.noreply.github.com>
pkg: scheme importspkg: scheme imports
|
Closed in favor of #62 |
Plan: Add native support for Sass
pkg:scheme imports ✅normalizeSpecifierinlexer.tsto allowpkg:schemenormalizeSpecifierinmoduleGraph.tsto allowpkg:schemeresolveWithFactoryinmoduleResolution.tsto strippkg:prefix before resolutionresolveImportPathingenerateTypes.tsto handlepkg:prefixpkg:#import resolutionpkg:scheme resolutionSummary
All changes have been successfully implemented and validated:
✅ Lexer & Module Graph: Updated
normalizeSpecifierfunctions to allowpkg:scheme and preserve#character for Sass package imports✅ Module Resolution: Updated
resolveWithFactoryandresolveImportPathto strippkg:prefix before resolution✅ Native pkg:# Support: Implemented built-in Sass importer (
createPkgImporter) that provides native resolution forpkg:#imports using package.jsonimportsfield - no custom resolver required✅ Bundler-Style Resolution: The importer manually parses package.json to map subpath imports (e.g.,
#styles/*→./styles/*) and applies Sass-specific path resolution (partials, index files)✅ Tests: Added comprehensive tests and package.json fixture with imports field configuration
✅ Validation: Core tests pass, no linting errors, formatting correct
✅ Security: CodeQL scan found no security vulnerabilities
Key Features
pkg:#imports (e.g.,pkg:#styles/colors.scss) without writing custom resolversimportsfield_) and index files automaticallyThe implementation provides the expected bundler-style behavior by default, making it easier for users working with bundlers like rspack to use Sass imports with the
pkg:scheme and Node.js subpath imports.Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.