Open viktormarinho opened 1 month ago
i have both deno.json and package.json at the root of the project:
My root deno.json:
{
"compilerOptions": {
"lib": [
"deno.window",
"dom",
"esnext"
],
"jsx": "react-jsx",
"jsxImportSource": "react"
},
"fmt": {
"exclude": [
"*.yaml",
"deploy/**"
]
},
"unstable": ["kv"],
"exclude": [
"node_modules",
"README.md",
"apps/**/build",
"docs/**",
".github"
],
"hooks": {
"pre-commit": "deno fmt --check && deno lint"
},
"workspace": [
"./apps/project",
"./packages/ui",
"./packages/collab"
]
}
My root package.json
:
{
"name": "project",
"private": true,
"scripts": {
"build": "PWD=$PWD/apps/project remix vite:build",
"dev": "PWD=$PWD/apps/project remix vite:dev",
"lint": "deno lint . --fix",
"fmt": "deno fmt .",
"ui": "PWD=$PWD/packages/ui deno npm:shadcn@latest --"
},
"optionalDependencies": {
"@rollup/rollup-linux-arm64-musl": "^4.22.5",
"@rollup/rollup-linux-x64-gnu": "4.22.4"
},
"workspaces": [
"./apps/*",
"./packages/*"
]
}
May be related to #26305 , since import type
also doesn't work for workspace dependencies... since types cannot be resolved
I think it's related to my issue here: https://discord.com/channels/684898665143206084/1296203871827398696
I'm trying out Deno 2 in a full npm monorepo (so only package.json
files), and the types resolution for the check
command doesn't seem the read the package.json
's exports
key.
However the VS Code LSP is working fine. 🤔
Same here:
error: Failed resolving types. [ERR_TYPES_NOT_FOUND] Could not find types for 'file:///Users/raay/Chat/node_modules/.deno/web-push@3.6.7/node_modules/web-push/index.js' imported from 'file:///Users/raay/Chat/deno/config/main.ts'
at file:///Users/raay/Chat/deno/config/main.ts:1:21
Interesting part is that web-push
have in it's package.json "main": "src/index.js"
and deno check
is trying to resolve index.js
from root of the package and such file not exists.
deno lsp
is working fine.
I also have package.json
and deno.json
in the root of my project.
Version: Deno 2.0.0
tldr: Deno seems to be having problems resolving npm workspace dependency types with packages having only
package.json
; Maybe because the exports uses*
?My current structure is:
project/apps/project
-> Remix app with a package.json. Runtime runs vite w/ deno, and the imports are resolved just fine. Points toproject/packages/ui
via"@project/ui": "^1.0.0"
in package.json.project/packages/ui
-> React library exporting some components. Includes apackage.json
, but i've noticed that adding a deno.json kind of solves the type resolving (i'd have a package.json AND a deno.json just to be able to use deno check etc.; i've already done this for another package).But also ends up introducing another problem: exports using a wildcard (
*
) seems to make all exports in deno.json stop being detected. I've tested in different packages here, and everything works until you have any export using a wildcard. Inproject/packages/ui/package.json
, i have an exports map like that:This does not work in deno.json, so i have to either put an export for all files, or create a barrel file, that i'd really prefer not to.
Output of
deno check .
at root:Hovering the import, the Deno LSP shows me: