denoland / deno

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

Import error on startup when a Fresh project is a workspace member #24622

Open dahlia opened 1 month ago

dahlia commented 1 month ago

If a Fresh project is a workspace member, an import error occurs on startup. Here's how to reproduce it:

echo '{"workspace": ["fresh"]}' > deno.json
deno run -A -r https://fresh.deno.dev fresh
cd fresh/
deno task start

Here's the error message:

error: Relative import path "preact" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs"
    at https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:46
marvinhagemeister commented 1 month ago

This seems to occur when a dependency of a workspace member refers to something in the import map of said member. In this case fresh is expected to resolve the preact dependency based on the import map of the workspace member. This error seems to only happen with transient dependencies of http imports from what I can tell.

darkship commented 1 month ago

is this the same issue as when a island imports something from a workspace member?

[ERROR] specifier was a bare specifier, but was not remapped to anything by importMap. [plugin deno-resolver]

islands/SunriseManualButton.tsx:1:25:
1 │ import { postJSON } from '@scope/libs';

 Error: Build failed with 2 errors:
 islands/ShutterIsland.tsx:6:25: ERROR: [plugin: deno-resolver] specifier was a bare specifier, but was not remapped to anything by importMap.
 islands/SunriseManualButton.tsx:1:25: ERROR: [plugin: deno-resolver] specifier was a bare specifier, but was not remapped to anything by importMap.
   at failureErrorWithLog (https://deno.land/x/esbuild@v0.20.2/mod.js:1626:15)
   at https://deno.land/x/esbuild@v0.20.2/mod.js:1034:25
   at runOnEndCallbacks (https://deno.land/x/esbuild@v0.20.2/mod.js:1461:45)
   at buildResponseToResult (https://deno.land/x/esbuild@v0.20.2/mod.js:1032:7)
   at https://deno.land/x/esbuild@v0.20.2/mod.js:1061:16
   at responseCallbacks.<computed> (https://deno.land/x/esbuild@v0.20.2/mod.js:679:9)
   at handleIncomingPacket (https://deno.land/x/esbuild@v0.20.2/mod.js:739:9)
   at readFromStdout (https://deno.land/x/esbuild@v0.20.2/mod.js:655:7)
   at https://deno.land/x/esbuild@v0.20.2/mod.js:1974:11
   at eventLoopTick (ext:core/01_core.js:168:7) {
   errors: [Getter/Setter],
   warnings: [Getter/Setter]

seems to work for not island components

sergeysolovev commented 1 month ago

I have the same issue with preact. Trying to make a fresh app a workspace member (it’s been a subfolder)

hoomp3 commented 3 days ago

issue still happening