Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running dev server: No known conditions for "./action" specifier in "svelte" package [plugin vite:dep-scan] #15236

Open
MathiasWP opened this issue Feb 7, 2025 · 3 comments

Comments

@MathiasWP
Copy link
Contributor

MathiasWP commented Feb 7, 2025

Describe the bug

In one of our components we type import ActionReturn from svelte/action:

import { type ActionReturn } from 'svelte/action';

When running pnpm dev on our SvelteKit project we get the following error in the terminal:

✘ [ERROR] No known conditions for "./action" specifier in "svelte" package [plugin vite:dep-scan]

script:/frontend/apps/kvist/src/ui/components/KvistPopover/KvistPopover.svelte?id=0:70:7:
  70 │ import 'svelte/action'
	 ╵        ~~~~~~~~~~~~~~~

This error came from the "onResolve" callback registered here:

../../node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1150:20:
  1150 │       let promise = setup({
	   ╵                     ^

at setup (file:///frontend/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:18418:13)
at handlePlugins (/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1150:21)
at buildOrContextImpl (/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:873:5)
at Object.buildOrContext (/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:699:5)
at /frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:2038:68
at new Promise (<anonymous>)
at Object.context (/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:2038:27)
at Object.context (/frontend/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1880:58)
at prepareEsbuildScanner (file:///frontend/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-CfG9u7Cn.js:18206:24)

This error seems to be a kind error, as everything works as expected, but it's a little unlucky to get this error every time we boot up our dev-server.

Reproduction

https://github.com/MathiasWP/no-known-condition-for-action

Logs

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 966.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.6.1 - /opt/homebrew/bin/node
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 10.1.0 - /opt/homebrew/bin/pnpm
    bun: 1.0.0 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 131.1.73.104
    Chrome: 132.0.6834.160
    Edge: 132.0.2957.140
    Safari: 18.2
  npmPackages:
    svelte: ^5.19.9 => 5.19.9

Severity

annoyance

@jasonlyu123
Copy link
Member

With TypeScript's verbatimModuleSyntax compiler option,

import { type xx } from "module"

is transformed into

 import "module"

But svelte/action is a type-only module and doesn't exist in the runtime, svelte/elements also. You can write import type to avoid the problem. To make it work with import { type } Svelte needs to actually create an empty module for this but I am not sure this makes sense.

import type { xx } from "module"

@Conduitry
Copy link
Member

Hm. Yeah, I don't know whether Svelte should publish dummy JS modules for these types-only modules. I can see there are cases where it would result in fewer confusing errors, but it also feels icky. I dunno.

@Ocean-OS
Copy link
Contributor

Ocean-OS commented Feb 7, 2025

This is also a bit icky, but could the compiler just remove these imports from the component if they are from one of Svelte's type-only modules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants