-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Description
Describe the bug
Typescript and node-resolution allows to import files dropping the last extension so a file named styles.css.ts
can be imported like:
import {export1, export2} from './styles.css';
Leading to a false positive of this warning:
Default and named imports from CSS files are deprecated. Use the ?inline query instead. For example: import { counter } from './styles.css?inline'
The new import analysys in vite 4 is detecting usage of named exports in side-effect imports of .css
files, but in order to do so, it's checking the AST values instead of the resolved Id to the file
This is problematic since it's a false positive of importing some non-css files like the described example
Reproduction
https://stackblitz.com/edit/vitejs-vite-bedqvf?file=file.css.js,main.js&terminal=dev
Steps to reproduce
See warnings in the console:
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 7.17.0 - /usr/local/bin/npm
npmPackages:
vite: ^4.0.0 => 4.0.0
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
wmertens and nomoon