gxmari007 / vite-plugin-eslint

🚨 ESLint plugin for vite
MIT License
268 stars 48 forks source link

Typescript types are not properly exported #74

Open SnirShechter opened 1 year ago

SnirShechter commented 1 year ago
Could not find a declaration file for module 'vite-plugin-eslint'.
'c:/Code/react-vite-example/node_modules/vite-plugin-eslint/dist/index.mjs' implicitly has an 'any' type.
There are types at 'c:/Code/react-vite-example/node_modules/vite-plugin-eslint/dist/index.d.ts',
but this result could not be resolved when respecting package.json "exports".
The 'vite-plugin-eslint' library may need to update its package.json or typings.ts(7016)
image
SnirShechter commented 1 year ago

For anyone else stuck here, I've added a fix myself via patch-package:

  1. npm install --save-dev patch-package
  2. Create the patch file patches/vite-plugin-eslint+1.8.1.dev.patch with this content:
    
    diff --git a/node_modules/vite-plugin-eslint/package.json b/node_modules/vite-plugin-eslint/package.json
    index afbc41c..5f6d8f7 100644
    --- a/node_modules/vite-plugin-eslint/package.json
    +++ b/node_modules/vite-plugin-eslint/package.json
    @@ -9,6 +9,7 @@
    "types": "./dist/index.d.ts",
    "exports": {
     ".": {
    +      "types": "./dist/index.d.ts",
       "import": "./dist/index.mjs",
       "require": "./dist/index.js"
     }
3. Add a postinstall script in your `package.json`:

"postinstall": "patch-package",


4. `npm install`
mrlika commented 1 year ago

It happens when using recommended in TypeScript 5 "moduleResolution": "Bundler" in tsconfig.json

thany commented 5 months ago

What does it take to get this fixed? It seems like an easy thing to fix...

I don't really want to use a patch-package mechanism, since I'm setting up a totally new virgin project. It feels dirty.