denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.04k stars 5.23k forks source link

Should `deno cache` ignore specifiers it does not understand? #25763

Open marvinhagemeister opened 4 hours ago

marvinhagemeister commented 4 hours ago

Vite projects (and other frontend ones) typically contain non-standard imports like importing .svg files. Deno errors when it encounters such a file upon calling deno cache.

Steps to reproduce

  1. Run npm create vite
  2. Pick the "Vanilla" -> "TypeScript" preset
  3. cd into the project folder and run deno cache src/App.tsx

Output:

error: Expected a JavaScript or TypeScript module, but identified a Unknown module. Importing these types of modules is currently not supported.
  Specifier: file:///workspaces/deno2_test/src/assets/react.svg
    at file:///workspaces/deno2_test/src/App.tsx:3:23

Version: Deno 2.0.0-rc.4+66fb81e

lucacasonato commented 3 hours ago

I removed the "bug" classification from this. Right now, this is intentional behaviour. deno cache fails on imports it does not understand, rather than just silently ignoring them (just like Node fails when you run a file that imports a .svg file). Maybe we can change this behaviour though.