Mqx
Mqx
DDeno
Created by Mqx on 10/14/2024 in #help
import_map.json not working
I am currently trying to checkout an project in Deno 2.0.0 and when I try to run a task I get a warning and error:
Warning the configuration file "cwd/deno.json" contains an entry for "importMap" that is being ignored.
error: Relative import path "@std/cli/parse-args" not prefixed with / or ./ or ../ and not in import map from "project/config/build/index.ts"
Warning the configuration file "cwd/deno.json" contains an entry for "importMap" that is being ignored.
error: Relative import path "@std/cli/parse-args" not prefixed with / or ./ or ../ and not in import map from "project/config/build/index.ts"
My deno.json looks like this:
{
...
"importMap": "./config/import_map.json",
...
}
{
...
"importMap": "./config/import_map.json",
...
}
My import_map.json is placed at:
project/config/import_map.json
project/config/import_map.json
Does anyone know why I get this warning and error?
6 replies
DDeno
Created by Mqx on 9/13/2024 in #help
Using SolidJS with Deno
Hey I am currently trying to set up a template for SolidJS development with Deno and I am unable to figure out how to set the deno.json configuration correctly. Especially the compilerOptions. Can someone please give me an example on how to setup the JSX stuff? I am always getting errors that my config is invalid. Thanks.
14 replies
DDeno
Created by Mqx on 8/27/2024 in #help
Binary files in jsr package
Hey I am currently trying to understand the „new“ (for me) package format (jsr.json) for Deno packages and I was wandering how binary files are handled in such a package when using the package. For example if I have a DLL file for my ffi module can I just include it in the include statement inside the jsr.io file so that it gets cached when I use the package? Or do I need relay on a library like plug that downloads non ts/js files that I need?
11 replies
DDeno
Created by Mqx on 7/18/2024 in #help
Use ESLint with Deno
Is it possible to use ESLint with Deno? I know that Deno has a build in formatter and linter but the ruleset is kinda small and plug-ins are not supported yet. Are there any guides out there on how to use ESLint with Deno? Thanks
21 replies
DDeno
Created by Mqx on 4/9/2024 in #help
`declare module` doesn’t work
I was trying to declare a module like so:
declare module "*.scss";
declare module "*.scss";
But this simply doesn’t have any effect whatsoever. I also tried this:
declare module "*.scss" {
const content: string;
export default content;
}
declare module "*.scss" {
const content: string;
export default content;
}
None of this worked. I don’t know if .d.ts file are simply ignored by Deno or if this is a bug, or I have done something wrong. This is the GitHub Issue: https://github.com/denoland/deno/issues/23007 I appreciate any help 👍🏻 Thanks
35 replies
DDeno
Created by Mqx on 3/11/2024 in #help
Import SCSS in TS files
Hey, I am currently building a template for web development and I want to use ESBuild as a bundler. I use lit in combination with SASS. For SASS files I use the esbuild-sass-plugin from npm in Deno. This works fine and ESBuild successfully resolves and bundles the .scss files imported into the .ts files. However deno-ts marks the default import as red because it is not valid js/ts how can I specify this in the config for Deno so that the files get recognized as SCSS files/plain text?
import style from „style.scss“
// ^ Works but is red because style.scss does not have a default export.
import style from „style.scss“
// ^ Works but is red because style.scss does not have a default export.
51 replies
DDeno
Created by Mqx on 1/30/2024 in #help
Creating custom GitHub Action using Deno
Hey, I am currently trying to develop my first own custom GitHub Action. I have some trouble setting up my environment. I really don't want to use Node and try to stick to Deno, but this is easier said than done. Can someone help me setting a basic action up? Thanks! This is my current repo where I try to set everything up: https://github.com/Datapack-Registry/minecraft-manifest
7 replies
DDeno
Created by Mqx on 1/22/2024 in #help
walk() include only last directory...
Hey, I'm currently trying to write a replacer for file names, file content and folder names. My goal is to crawl over a certain directory and then replace a certain pattern in file names, file content and folder names. Currently I use the walk() function from the std library. My problem now is that walk() returns every single directory and not just the last one. In other words, walk() does not just give me:
file/to/directory
file/to/directory
but:
file
file/to
file/to/directory
file
file/to
file/to/directory
What is the best way to filter this? There may also be a better method... This is what my current attempt looks like:
import { parseArgs } from 'https://deno.land/std@0.212.0/cli/mod.ts';
import { walkSync } from 'https://deno.land/std@0.212.0/fs/mod.ts';
import { parseString as parseRegExpString } from 'https://raw.githubusercontent.com/TypeScriptPlayground/std/main/src/regexp/mod.ts'

const args = parseArgs<{
path : string,
pattern : string,
replacer : string
}>(Deno.args);

if (!args.path || !args.pattern || !args.replacer) {
console.log('Missing arguments');
Deno.exit();
}

const pattern = parseRegExpString(args.pattern);

const pathsToUpdate: Array<{ oldPath: string, newPath: string, isFile: boolean }> = [];

Deno.chdir(args.path);
for (const entry of walkSync('.')) {
const path = entry.path;
const pathReplaced = path.replace(pattern, args.replacer);

if (path !== pathReplaced) {
pathsToUpdate.push({ oldPath: path, newPath: pathReplaced, isFile: entry.isFile });
}
}

for (const { oldPath, newPath, isFile } of pathsToUpdate) {
if (isFile) {
const content = Deno.readTextFileSync(oldPath);
const contentReplaced = content.replace(pattern, args.replacer);
Deno.writeTextFileSync(newPath, contentReplaced);
} else {
Deno.renameSync(oldPath, newPath); //<- Error: /path/{{pattern}}/{{pattern}}
}
console.log(`Updated: ${oldPath} -> ${newPath}`);
}
import { parseArgs } from 'https://deno.land/std@0.212.0/cli/mod.ts';
import { walkSync } from 'https://deno.land/std@0.212.0/fs/mod.ts';
import { parseString as parseRegExpString } from 'https://raw.githubusercontent.com/TypeScriptPlayground/std/main/src/regexp/mod.ts'

const args = parseArgs<{
path : string,
pattern : string,
replacer : string
}>(Deno.args);

if (!args.path || !args.pattern || !args.replacer) {
console.log('Missing arguments');
Deno.exit();
}

const pattern = parseRegExpString(args.pattern);

const pathsToUpdate: Array<{ oldPath: string, newPath: string, isFile: boolean }> = [];

Deno.chdir(args.path);
for (const entry of walkSync('.')) {
const path = entry.path;
const pathReplaced = path.replace(pattern, args.replacer);

if (path !== pathReplaced) {
pathsToUpdate.push({ oldPath: path, newPath: pathReplaced, isFile: entry.isFile });
}
}

for (const { oldPath, newPath, isFile } of pathsToUpdate) {
if (isFile) {
const content = Deno.readTextFileSync(oldPath);
const contentReplaced = content.replace(pattern, args.replacer);
Deno.writeTextFileSync(newPath, contentReplaced);
} else {
Deno.renameSync(oldPath, newPath); //<- Error: /path/{{pattern}}/{{pattern}}
}
console.log(`Updated: ${oldPath} -> ${newPath}`);
}
6 replies
DDeno
Created by Mqx on 1/11/2024 in #help
ESBuild SASS Plugin
Hey, I have developed this Plugin: https://github.com/DenoPlayground/esbuild-plugin-sass But I have some problems with the import paths from the SASS module. Maybe someone can help me to debug this, since ESBuild does not have an official community server. The problem at the moment is that when the SASS module tries to resolve an import it does that by assuming that the path is relative to the root directory and not the file that is currently processed. Maybe there is a way to account for this issue. For example if we would assume that this is our file structure and we import colors.scss into style.scss.
/src/client/style.scss
/src/client/colors.scss
/src/client/style.scss
/src/client/colors.scss
When the SASS module resolves the import it is trying to load the colors.scss from:
/colors.scss
/colors.scss
Because this is where the initial task gets started. But I can not simply set the new root to:
/src/client
/src/client
Because then all my other tasks would not work.
28 replies
DDeno
Created by Mqx on 11/15/2023 in #help
How to uploading images from frontend to Deno.serve()
Hey, can someone please give me a vanilla code example on how to upload files from my frontend application to the server that uses Deno.serve(). I know how to upload the image in the frontend and send it to the Deno backend using a POST request, but how can I work with this image on the server side? Currently my backend is set up without any framework. Thanks!
9 replies
DDeno
Created by Mqx on 11/7/2023 in #help
Deno lint custom rules
Hey is there currently a way to create custom rules for Deno lint? And if so how can I specify a custom rule? If there is no way to create custom rules, can I use ESLint with Deno without having to install Node? And I know I can install ESLint as a global „script“ but that still requires Node to be installed. Thanks ~Mqx
3 replies
DDeno
Created by Mqx on 10/26/2023 in #help
Using ESBuild with Deno
Hey, is anyone more familiar with ESBuild? I am currently trying to transpile my Deno TypeScript project with ESBuild in JavaScript. But I don't want to bundle the files. I just want to transpile them and put them under the same path instead of src in dist. I'm currently doing the whole thing like this:
deno run -A https://deno.land/x/esbuild@v0.19.4/mod.js —target=es2022 —outdir=dist ./src/client/**
deno run -A https://deno.land/x/esbuild@v0.19.4/mod.js —target=es2022 —outdir=dist ./src/client/**
Problem with this is that it does not resolve the import paths properly. At the end there is still the .ts extension in the import. Another problem is, for example, the ESBuild tries to convert the .d.ts files into .d.js which are then simply empty.
38 replies
DDeno
Created by Mqx on 9/30/2023 in #help
Deno + Lit
Hey how can use the Lit framework with Deno? Is there a guide or config on how to use it with this framework?
22 replies
DDeno
Created by Mqx on 9/12/2023 in #help
Using Deno in Frontend.
Hey, I was wandering if it is possible to use Deno for Vanilla Frontend development. I dont want to use a Framework like Oak or Fresh, I just want to use Vanilla TypeScript instead of JavaScript in my Frontend. As an example I just want types/typechecking for developing, build my Frontend and then transpile the whole thing to a JS-Bundle that I can then load in the Frontend. Now I have 2 problems. First is how to transpile my TypeScript to a JS-Bundle (I can do that with the emit module), and the second is how can I get the DOM in TypeScript. I have found this in the manual but I am not really sure how to use it. Can someone explain to me how to setup the DOM for TypeScript development in the Frontend. And also whats about Deno.* APIs? How does the emit module handle this? Thanks! ~Mqx
20 replies
DDeno
Created by Mqx on 9/4/2023 in #help
dlopen() from web url
Hey, is it possible to provide a url to the dll file from a cdn server? For example if I want to dlopen the dll from this url: „https://raw.githubusercontent.com/TypeScripPlayground/Serial/main/ts/bin/windows.dll “ I get an error: Could not open library, module not found
3 replies
DDeno
Created by Mqx on 8/23/2023 in #help
Deno console.log() all items of array
No description
7 replies
DDeno
Created by Mqx on 8/1/2023 in #help
Generate jUnit XML file from Deno Tests
Hey is it possible that the Deno Test suite generates a jUnit XML about the Test? So that I can display the results on GitLab/GitHub?
12 replies
DDeno
Created by Mqx on 7/12/2023 in #help
Deno type enforcement
Hey, I have a question about the type checking.
function logging(message : number) {
console.log(message);
}

logging(“Hello”);
function logging(message : number) {
console.log(message);
}

logging(“Hello”);
This should throw an error when trying to run it, but apparently it does not. But why? We tried using the tsc compiler from Node and it clearly throws an error, saying that the type string is not assignable to type number. Is there something I need to change in the config for Deno to get the same error result? Thanks ~Mqx
2 replies
DDeno
Created by Mqx on 6/10/2023 in #help
VS-Code auto import local modules
Hey is there a way to enable some sort of auto import for local modules/files in VS-Code? Currently it only works if the file is opened in an other tab. When I close the tab an try to use autocomplete an exported module from that file it does not auto import. Is there a fix to this? Or some settings? Thanks for any help!
3 replies
DDeno
Created by Mqx on 5/22/2023 in #help
Reclaim an already registered module?
Is it possible to reclaim an already registered third party module? For example if the module that is already registered doesn’t get any updates or is deprecated?
27 replies