storybookjs / builder-vite

A builder plugin to run and build Storybooks with Vite
MIT License
886 stars 109 forks source link

vite-plugin-eslint is not compatible with virtual modules #535

Closed hi-reeve closed 1 year ago

hi-reeve commented 1 year ago

What version of vite are you using?

4.0.2

System info and storybook versions

Environment Info:

System: OS: macOS 13.1 CPU: (8) arm64 Apple M1 Pro Binaries: Node: 18.12.0 - ~/.nvm/versions/node/v18.12.0/bin/node npm: 8.19.2 - ~/.nvm/versions/node/v18.12.0/bin/npm Browsers: Safari: 16.2 npmPackages: @storybook/addon-essentials: ^7.0.0-beta.12 => 7.0.0-beta.12 @storybook/addon-interactions: ^7.0.0-beta.12 => 7.0.0-beta.12 @storybook/addon-links: ^7.0.0-beta.12 => 7.0.0-beta.12 @storybook/blocks: ^7.0.0-beta.12 => 7.0.0-beta.12 @storybook/testing-library: ^0.0.13 => 0.0.13 @storybook/vue3: ^7.0.0-beta.12 => 7.0.0-beta.12 @storybook/vue3-vite: ^7.0.0-beta.12 => 7.0.0-beta.12

Describe the Bug

just install storybook on my project trying to run storybook for the first time and got this error

image

Link to Minimal Reproducible Example

No response

Participation

IanVS commented 1 year ago

This appears to be a pnpm caching issue. If you can create a reproduction I can take a look. Others have tried and been unable to, which indicates there is something corrupted locally.

hi-reeve commented 1 year ago

This appears to be a pnpm caching issue. If you can create a reproduction I can take a look. Others have tried and been unable to, which indicates there is something corrupted locally.

i resolve this by deleting node_modules and try to re-init storybook and it works fine now. got other error

[vite] Internal server error: No ESLint configuration found in /virtual:/@storybook/builder-vite.
  Plugin: vite-plugin-eslint
  File: /virtual:/@storybook/builder-vite/vite-app.js
      at CascadingConfigArrayFactory._finalizeConfigArray (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/@eslint+eslintrc@1.4.0/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:521:19)
      at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/@eslint+eslintrc@1.4.0/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:312:21)
      at CLIEngine.isPathIgnored (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/lib/cli-engine/cli-engine.js:989:18)
      at ESLint.isPathIgnored (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/lib/eslint/eslint.js:681:26)
      at TransformContext.transform (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite-plugin-eslint@1.8.1_eslint@8.30.0+vite@4.0.2/node_modules/vite-plugin-eslint/dist/index.js:1:2348)
      at Object.transform (file:///Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite@4.0.2_gneikmxcpj2uc2xuqjosnroj4e/node_modules/vite/dist/node/chunks/dep-6305614c.js:42626:44)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async loadAndTransform (file:///Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite@4.0.2_gneikmxcpj2uc2xuqjosnroj4e/node_modules/vite/dist/node/chunks/dep-6305614c.js:40434:29)
IanVS commented 1 year ago

Can you share a reproduction? I can't tell what's happening otherwise.

woodreamz commented 1 year ago

This appears to be a pnpm caching issue. If you can create a reproduction I can take a look. Others have tried and been unable to, which indicates there is something corrupted locally.

i resolve this by deleting node_modules and try to re-init storybook and it works fine now. got other error

[vite] Internal server error: No ESLint configuration found in /virtual:/@storybook/builder-vite.
  Plugin: vite-plugin-eslint
  File: /virtual:/@storybook/builder-vite/vite-app.js
      at CascadingConfigArrayFactory._finalizeConfigArray (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/@eslint+eslintrc@1.4.0/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:521:19)
      at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/@eslint+eslintrc@1.4.0/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:312:21)
      at CLIEngine.isPathIgnored (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/lib/cli-engine/cli-engine.js:989:18)
      at ESLint.isPathIgnored (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/eslint@8.30.0/node_modules/eslint/lib/eslint/eslint.js:681:26)
      at TransformContext.transform (/Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite-plugin-eslint@1.8.1_eslint@8.30.0+vite@4.0.2/node_modules/vite-plugin-eslint/dist/index.js:1:2348)
      at Object.transform (file:///Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite@4.0.2_gneikmxcpj2uc2xuqjosnroj4e/node_modules/vite/dist/node/chunks/dep-6305614c.js:42626:44)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async loadAndTransform (file:///Users/reeve/Documents/reeve/Works/nostra-erp-webapp/node_modules/.pnpm/vite@4.0.2_gneikmxcpj2uc2xuqjosnroj4e/node_modules/vite/dist/node/chunks/dep-6305614c.js:40434:29)

@hi-reeve Did you find a solution? I am facing the same issue.

UPDATE: Finally found a solution by excluding /virtual:/

//vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import eslint from 'vite-plugin-eslint';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    eslint({
      exclude: ['/virtual:/**', 'node_modules/**'],
    }),
});
IanVS commented 1 year ago

I suggest upgrading to Storybook 7 if you want to use vite 4, I never got it fully working back in Storybook 6.5.

woodreamz commented 1 year ago

I suggest upgrading to Storybook 7 if you want to use vite 4, I never got it fully working back in Storybook 6.5.

The issue is still there with Storybook 7 (I am currently using 7.0.4).

    "eslint": "8.38.0",
    "eslint-plugin-react": "7.32.2",
    "eslint-plugin-react-hooks": "4.6.0",
    "eslint-plugin-storybook": "0.6.11",
    "eslint-plugin-testing-library": "5.10.2",
    "vite": "4.2.1",
    "vite-plugin-eslint": "1.8.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "@storybook/addon-essentials": "7.0.4",
    "@storybook/addon-interactions": "7.0.4",
    "@storybook/addon-links": "7.0.4",
    "@storybook/blocks": "7.0.4",
    "@storybook/react": "7.0.4",
    "@storybook/react-vite": "7.0.4",
    "@storybook/testing-library": "0.1.0",
IanVS commented 1 year ago

OK, thanks. This repo is the code for the 6.5 version, which is why I thought you weren't using 7.

jung-han commented 1 year ago

@IanVS Hi, I have same issue. Storybook version is 7.0.4 and vite version is 4.2.1. The problem was solved by excluding as mentioned above(https://github.com/storybookjs/builder-vite/issues/535#issuecomment-1507352550), but I share it because it seems to be a temporary solution.

tarik-gadoumi commented 1 year ago

Hi i have same issue : "vite": "^4.2.1", "storybook": "^7.0.4", "vite-plugin-eslint": "^1.8.1" "eslint": "^8.38.0", "eslint-config-react-app": "^7.0.1", "eslint-plugin-jsx-a11y": "^6.7.1",

alextes90 commented 1 year ago

Hi, have the same issue:

"vite": "^4.1.0", "vite-plugin-eslint": "^1.8.1", "@storybook/react": "^7.0.10", "@storybook/react-vite": "^7.0.10", "eslint": "^8.36.0",

Solved, as written above. Thank you

IanVS commented 1 year ago

This doesn't have anything to do with Storybook, it's an issue in vite-plugin-eslint that it cannot handle virtual files.

IanVS commented 1 year ago

This doesn't have anything to do with Storybook, it's an issue in vite-plugin-eslint that it cannot handle virtual files.