taco
taco
DDeno
Created by taco on 2/27/2025 in #help
Vite + Codemirror in SvelteKit 4 broken due to @codemirror/state being loaded twice
I am trying to migrate the SvelteKit project from Node to Deno, and this issue is preventing me from switching over. The npm modules installed alongside SvelteKit 4 needed to reproduce are codemirror @codemirror/lang-json I would imagine that being able to change the .deno directory to somewhere outside of node_modules would fix this. This is the error received in the browser on load: Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks. The 2 instances being loaded in the browser are at: node_modules/@codemirror/state/dist/index.js node_modules/.deno/@codemirror+state@6.5.2/node_modules/@codemirror/state/dist This is running in the denoland/deno:alpine docker container.
FROM denoland/deno:alpine as dev

COPY ./lib /app/lib

COPY ./web /app/web

WORKDIR /app/web

RUN deno install

EXPOSE 5173

CMD ["deno", "run", "-A", "npm:vite", "dev", "--host"]
FROM denoland/deno:alpine as dev

COPY ./lib /app/lib

COPY ./web /app/web

WORKDIR /app/web

RUN deno install

EXPOSE 5173

CMD ["deno", "run", "-A", "npm:vite", "dev", "--host"]
Deno version (in the container):
deno 2.2.2 (stable, release, x86_64-unknown-linux-gnu)
v8 13.4.114.9-rusty
typescript 5.7.3
deno 2.2.2 (stable, release, x86_64-unknown-linux-gnu)
v8 13.4.114.9-rusty
typescript 5.7.3
I have tried to deny .deno in vite.config.js in server/fs/deny. Neither denying node_modules/.deno or denying .deno work.
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
},
server: {
allowedHosts: ['mydomain.com'],
fs: {
deny: '.deno'
}
},

});
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [sveltekit()],
test: {
include: ['src/**/*.{test,spec}.{js,ts}'],
},
server: {
allowedHosts: ['mydomain.com'],
fs: {
deny: '.deno'
}
},

});
4 replies
DDeno
Created by taco on 1/7/2025 in #help
JSDoc inline import with Deno LSP does not find or apply type from npm package
Hello! When using the Deno LSP (tested in both VSCode with Deno for VSCode v3.43.2 and neovim with coc-deno 3.15.0), JSDoc imports from npm packages are not working. In the same project before initializing the Deno LSP, everything is found and functional with tsserver. I'm running Deno 2.1.3-1 on Arch Linux, kernel 6.6.63-1-lts Steps to reproduce, in a new folder:
deno init
deno add npm:pg
deno add npm:@types/pg
touch index.js
deno init
deno add npm:pg
deno add npm:@types/pg
touch index.js
This results in this deno.json:
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@types/pg": "npm:@types/pg@^8.11.10",
"pg": "npm:pg@^8.13.1"
}
}
{
"tasks": {
"dev": "deno run --watch main.ts"
},
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@types/pg": "npm:@types/pg@^8.11.10",
"pg": "npm:pg@^8.13.1"
}
}
In index.js:
/**
* @param {import('pg').}
*/
/**
* @param {import('pg').}
*/
Removing the . after import('pg') and placing it back causes tsserver to give all types from @types/pg. Nothing happens with the Deno LSP. The same exact thing can be seen with
/**
* @param {import('pg').Pool} pool
*/
const example = (pool) => {
pool // Remove and type pool to see the intellisense
}
/**
* @param {import('pg').Pool} pool
*/
const example = (pool) => {
pool // Remove and type pool to see the intellisense
}
With the Deno LSP, the type for pool is:
(parameter) pool: any
@param - pool
(parameter) pool: any
@param - pool
With tsserver, the type is:
(parameter) pool: Pool
@param pool
(parameter) pool: Pool
@param pool
The deno LSP status is in the attached text.
1 replies