adoublef
adoublef
DDeno
Created by adoublef on 2/26/2024 in #help
workspace import
I have a vsc root-level settings.json file
{
"deno.enable": true,
"deno.enablePaths": [
"./"
],
}
{
"deno.enable": true,
"deno.enablePaths": [
"./"
],
}
I want to be able to use the following inside of the deno projects inside the directory
{
"imports": {
"$std/":"https://deno.land/std@0.217.0/"
}
}
{
"imports": {
"$std/":"https://deno.land/std@0.217.0/"
}
}
but I am getting the following Relative import path "$std/assert/mod.ts" not prefixed with / or ./ or ../deno(import-prefix-missing)
4 replies
DDeno
Created by adoublef on 10/17/2023 in #help
Distroless Docker image fails with `libc.so: cannot open shared object file: No such file`
I am building a 1:1 with a Node project using the same base for a docker image distroless/cc. Both projects use the same external dependency pulled from npm called libsql however the Deno project seems to fail with the following error
libc.so: cannot open shared object file: No such file or directory
libc.so: cannot open shared object file: No such file or directory
I am unsure where to direct this issue as I can see that the container does include a file under /lib/x86_64-linux-gnu directory. Here is my current dockerfile
ARG DENO_VERSION=1.37.2

FROM denoland/deno:${DENO_VERSION} AS build
WORKDIR /app

USER deno

COPY deno.* deps.ts ./
RUN deno cache deps.ts

ADD . .

RUN deno cache cmd/www/main.ts

# ? --------------------------------

# FROM gcr.io/distroless/cc AS final
FROM denoland/deno:distroless-${DENO_VERSION} AS final
WORKDIR /app

COPY --from=build /deno-dir /deno-dir
COPY . .

CMD ["run", "-A", "--unstable", "cmd/www/main.ts"]

EXPOSE 8000
ARG DENO_VERSION=1.37.2

FROM denoland/deno:${DENO_VERSION} AS build
WORKDIR /app

USER deno

COPY deno.* deps.ts ./
RUN deno cache deps.ts

ADD . .

RUN deno cache cmd/www/main.ts

# ? --------------------------------

# FROM gcr.io/distroless/cc AS final
FROM denoland/deno:distroless-${DENO_VERSION} AS final
WORKDIR /app

COPY --from=build /deno-dir /deno-dir
COPY . .

CMD ["run", "-A", "--unstable", "cmd/www/main.ts"]

EXPOSE 8000
Any suggestions?
4 replies
DDeno
Created by adoublef on 9/8/2023 in #help
Deploy says Worker not defined for ESBuild (wasm.js)
@Deno AI Helper I am having trouble understanding how to get the esbuilder to work on Deno Deploy, using write: false here is what my conifg looks like currently
const result = await esbuild.build({
entryPoints: ["./hello_world.ts"],
platform: "browser",
target: ["chrome99", "firefox99", "safari15"],
format: "esm",
bundle: true,
minify: true,
absWorkingDir: Deno.cwd(),
outdir: ".",
write: false,
metafile: false,
// @ts-ignore been updated to v0.19.2
plugins: [...denoPlugins()],
});

console.log(result.outputFiles)
const result = await esbuild.build({
entryPoints: ["./hello_world.ts"],
platform: "browser",
target: ["chrome99", "firefox99", "safari15"],
format: "esm",
bundle: true,
minify: true,
absWorkingDir: Deno.cwd(),
outdir: ".",
write: false,
metafile: false,
// @ts-ignore been updated to v0.19.2
plugins: [...denoPlugins()],
});

console.log(result.outputFiles)
The error seems to suggest that the Worker is not defined even though I am using the wasm version of esbuild@v0.19.2
9 replies
DDeno
Created by adoublef on 9/4/2023 in #help
Does calling `bundle` inside a handler make sense?
hey all I wanted to understand if this is smart to do. I am using the cacheRoot option and wanted to know if that affects the way the code is executed here. As its being called inside a handler I am unsure if this is going to compile everytime or does the cacheRoot option speed that up?
app.get("/index.js", async (c) => {
const { code } = await bundle(
new URL("./components/mod.ts", import.meta.url),
{ cacheRoot: Deno.cwd() },
);
return c.text(code);
});
app.get("/index.js", async (c) => {
const { code } = await bundle(
new URL("./components/mod.ts", import.meta.url),
{ cacheRoot: Deno.cwd() },
);
return c.text(code);
});
4 replies
DDeno
Created by adoublef on 8/10/2023 in #help
extension method returning undefined for `text/plain`
Given the following:
console.log(
"text/plain",
extension("text/plain"),
extensionsByType("text/plain"),
parseMediaType("text/plain"),
[...extensions.entries()]
);
console.log(
"text/plain",
extension("text/plain"),
extensionsByType("text/plain"),
parseMediaType("text/plain"),
[...extensions.entries()]
);
I seem to get the result
text/plain undefined undefined [ "text/plain", undefined ] []
text/plain undefined undefined [ "text/plain", undefined ] []
Am I missing something?
11 replies
DDeno
Created by adoublef on 7/31/2023 in #help
denodrivers/sqlite and deno-sqlit behave different with multiple `?` args
I wanted to understand why these return different results
Deno.test("DB()", (_) => {
// deno-sqlite
const db = new DB(":memory:");

const stmt = db.prepareQuery("SELECT ?, ?");

const rs = stmt.all(["one", "two"]);
// ^? [ [ "one", "two" ] ]

stmt.finalize();

db.close();
});

Deno.test("Database() ? arguments", (_) => {
// denodrivers/sqlite
const db = new Database(":memory:");

const stmt = db.prepare("SELECT ?, ?");

const rs = stmt.all("one", "two");
// ^? [ { "?": "two" } ]

stmt.finalize();
db.close();
});

Deno.test("Database() : arguments", (_) => {
// denodrivers/sqlite
const db = new Database(":memory:");

const stmt = db.prepare("SELECT :one, :two");

const rs = stmt.all({ one: "one", two: "two" });
// ^? [ { ":one": "one", ":two": "two" } ]
console.log(rs);

stmt.finalize();
db.close();
});
Deno.test("DB()", (_) => {
// deno-sqlite
const db = new DB(":memory:");

const stmt = db.prepareQuery("SELECT ?, ?");

const rs = stmt.all(["one", "two"]);
// ^? [ [ "one", "two" ] ]

stmt.finalize();

db.close();
});

Deno.test("Database() ? arguments", (_) => {
// denodrivers/sqlite
const db = new Database(":memory:");

const stmt = db.prepare("SELECT ?, ?");

const rs = stmt.all("one", "two");
// ^? [ { "?": "two" } ]

stmt.finalize();
db.close();
});

Deno.test("Database() : arguments", (_) => {
// denodrivers/sqlite
const db = new Database(":memory:");

const stmt = db.prepare("SELECT :one, :two");

const rs = stmt.all({ one: "one", two: "two" });
// ^? [ { ":one": "one", ":two": "two" } ]
console.log(rs);

stmt.finalize();
db.close();
});
If I replace the denodrivers prepare statement to use named args I get correctly two values so unsure which method is needed to be called to get both to behave consistently
3 replies