You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
It might worth noting that .css.ts files are the organizational principle of https://github.com/vanilla-extract-css/vanilla-extract, and TypeScript has longstanding issues (microsoft/TypeScript#27481) with specifying import paths ending in .ts, so switching from e.g. import { appStyle } from './App.css'; to import { appStyle } from './App.css.ts'; isn't necessarily going to work.
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:Leading to a false positive of this warning:
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 filehttps://github.com/BuilderIO/vite/blob/dcc0004ceb7a76e6d0cbae8b84a103a15f80049b/packages/vite/src/node/plugins/importAnalysis.ts#L441-L447
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
The text was updated successfully, but these errors were encountered: