vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
4.2k stars 348 forks source link

No default export found in imported module "vike/plugin" #1838

Closed rtritto closed 3 weeks ago

rtritto commented 4 weeks ago

Description

Using ESLint with eslint-import-resolver-typescript (under the hood eslint-import-resolver-node), the rule import/default of eslint-import-resolver-node fails with vike/plugin import.

Code

Output

1:8  error  No default export found in imported module "vike/plugin"  import/default

In VSCode, opening the reference of vike/plugin (/vike/dist/esm/node/plugin/index.d.ts), I got:

vite.config.ts

export default plugin;
export { plugin };
export { plugin as ssr };
export type { ConfigVikeUserProvided as UserConfig };
export { PROJECT_VERSION as version } from './utils.js';
import type { ConfigVikeUserProvided } from '../../shared/ConfigVike.js';
declare function plugin(vikeConfig?: ConfigVikeUserProvided): any;

Reproduction

  1. git clone https://github.com/rtritto/template-vike-solid-daisyui.git
  2. cd template-vike-solid-daisyui
  3. yarn
  4. yarn eslint .
rtritto commented 4 weeks ago

Fixed changing import from default to named:

import { plugin as vike } from 'vike/plugin'

Same issue with vike-solid/config (esModuleInterop: false, missing default export) and vike-node/plugin

FYI @brillout

rtritto commented 4 weeks ago

Maybe it can be fixed moving the declare ... before the export default ...

brillout commented 3 weeks ago

I cannot reproduce:

~/tmp/template-vike-solid-daisyui (master|u+1) pnpm exec eslint .

🌼   daisyUI 4.12.10
├─ ✔︎ 1 theme added     https://daisyui.com/docs/themes
╰─ ❤︎ Support daisyUI project:  https://opencollective.com/daisyui

🌼   daisyUI 4.12.10
├─ ✔︎ 1 theme added     https://daisyui.com/docs/themes
╰─ ★ Star daisyUI on GitHub https://github.com/saadeghi/daisyui

Note that I'm using pnpm instead of yarn: https://github.com/brillout/template-vike-solid-daisyui. Can you reproduce when using pnpm instead of yarn?

rtritto commented 3 weeks ago

Fixed changing import from default to named:

import { plugin as vike } from 'vike/plugin'

Same issue with vike-solid/config (esModuleInterop: false, missing default export) and vike-node/plugin

FYI @brillout

Sorry, on main branch, I changed the code with the naming import. The issue will apper changing with the default import (you can try changing the code):

vite.config.ts

-import { plugin as vike } from 'vike/plugin'  // OK ESLint
+import vike from 'vike/plugin'  // KO ESLint

Edit: Same issue using pnpm on your fork.

brillout commented 3 weeks ago

I could reproduce indeed and updated my fork.

Seems to be a ESLint quirk? Closing as I don't see this to be a Vike bug, but I'm open for a workaround.

brillout commented 3 weeks ago

Fix pre-released as 0.4.193-commit-c1d490a.