Conversation
🦋 Changeset detectedLatest commit: 3d5667a The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
cd02e10 to
3d5667a
Compare
Merged
mizdra
added a commit
that referenced
this pull request
Jan 11, 2026
mizdra
added a commit
that referenced
this pull request
Jan 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
replace: #292
Background
Currently, css-modules-kit reports an error
Cannot import module 'xxx'when code tries to import a non-existent CSS Module file. This helps users catch mistakes early.However, in certain cases, this error is not reported. Specifically, when importing a non-existent CSS Module file using an import alias.
src/a.module.css:tsconfig.json:{ "compilerOptions": { "paths": { "@/*": ["./*"] } }, "cmkOptions": { "enabled": true } }This happens because import specifiers are resolved differently for
@/src/non-existent.module.cssand./non-existent.module.css. The former usests.resolveModuleName, while the latter usesresolve(fileURLToPath(new URL(specifier, pathToFileURL(options.request)).href)). The latter can resolve the specifier even if the file does not exist, while the former cannot resolve non-existent files.Moreover, css-modules-kit does not report the error for specifiers that cannot be resolved. Ideally, it should report an error in such cases. However, users often write code like
@import 'https://example.com/remote.css';to import CSS files that are resolved at runtime. To avoid reporting errors for these cases, css-modules-kit is designed not to report errors for specifiers that cannot be resolved.This behavior of not reporting errors for unresolved specifiers also applies when using import aliases. As a result, import specifiers like
@/src/non-existent.module.cssdo not trigger errors even when they cannot be resolved.Solution
Modify the resolver to always resolve specifiers using
ts.resolveModuleName. Additionally, enable reporting ofCannot import module 'xxx'diagnostics even when resolving withts.resolveModuleName.Note
This pull request introduced a regression, but it was fixed in #298.