D
Deno

help

how to use esbuild_deno_loader for local file?

Bboywithkeyboard3/7/2023
i have [join(tmpDir, './bundle.js')] as entry point (resulting as string e.g. c:\Users\User\AppData\Local\Temp\tempdir-33c4f2f8\bundle.js, but that gives me a Do not know how to load path error on console? what am i doing wrong?
ABAltair 680b3/7/2023
Are you bundling a bundle.js?? You have what looks like you desired output as the entry point. an esbuild example // build.ts
import * as esbuild from "https://deno.land/x/esbuild@v0.14.51/mod.js";
import { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.5.2/mod.ts";

type buildCFG = {
entry: string[],
out: string,
minify: boolean
}

// bundles an entrypoint into a single ESM output.
const build = async (cfg: buildCFG) => {
await esbuild.build({
plugins: [denoPlugin({})],
entryPoints: cfg.entry,
outfile: cfg.out,
bundle: true,
minify: cfg.minify,
keepNames: true,
banner: { js: '// deno-lint-ignore-file' },
format: "esm"
}).catch((e) => console.info(e));
esbuild.stop();
}

const cfg: buildCFG = {
entry: ["./mod.ts"],
minify: true,
out: './bundle.js'
}

build(cfg).then(() => {
console.log('Built bundle.js!')
}).catch((err) => {
console.info('build err - ', err)
})

// deno run build-A --unstable build.ts
import * as esbuild from "https://deno.land/x/esbuild@v0.14.51/mod.js";
import { denoPlugin } from "https://deno.land/x/esbuild_deno_loader@0.5.2/mod.ts";

type buildCFG = {
entry: string[],
out: string,
minify: boolean
}

// bundles an entrypoint into a single ESM output.
const build = async (cfg: buildCFG) => {
await esbuild.build({
plugins: [denoPlugin({})],
entryPoints: cfg.entry,
outfile: cfg.out,
bundle: true,
minify: cfg.minify,
keepNames: true,
banner: { js: '// deno-lint-ignore-file' },
format: "esm"
}).catch((e) => console.info(e));
esbuild.stop();
}

const cfg: buildCFG = {
entry: ["./mod.ts"],
minify: true,
out: './bundle.js'
}

build(cfg).then(() => {
console.log('Built bundle.js!')
}).catch((err) => {
console.info('build err - ', err)
})

// deno run build-A --unstable build.ts
The above utility builds/bundles starting from ./mod.ts and outputs a bundle at './bundle.js`
Bboywithkeyboard3/7/2023
just stupid naming xd but basically i have a full path as entry point as i'm in a totally different directory than the cwd like i already mentioned, my entry point is a full path like c:\Users\User\AppData\Local\Temp\tempdir-33c4f2f8\file.js and that doesn't work when i use the deno plugin
ABAltair 680b3/8/2023
I see. Sorry I wasn't any help.
KKyleJune3/8/2023
I haven't tried using an absolute path for the entrypoint. I've always used a relative path. I have used esbuild where the directory is different than the current directory. To do that, i set the workingDirectory to the directory my app is in, then set entry point as a relative path from the workingDirectory. Oh actually the build option is called absWorkingDir. I believe the outdir can be an absolute path if you want or need it to be outside of the absWorkingDir that you set.
Bboywithkeyboard3/8/2023
oh thanks @kylejune1415, i'll try it out right tomorrow! sounds promising

Looking for more? Join the community!

Recommended Posts
window variable in fresh islandsHow do I access `window` in islands? I need to modify DOM code client side.Warning Implicitly using latest version (0.178.0) for...Hello - Deno newb here. When running `deno task start` I get "Warning Implicitly using latest verHow to prevent std/http from gzipping and overriding EtagIt appears deno std/http applies gzip content-encoding magically sometimes depending on the type of Fresh in a Docker exiting processNot sure whats going wrong. Works fine on deno deploy. But when trying to run it inside a docker coneval script with stricter permissions in denoHi all, I wanted to know if its possible to eval a script in deno with more strict permissions. Somesolid-js with DenoI was wondering if it was possible to use solid-js with Deno natively without something like esbuildFeature Suggestion: Dark Mode for `std` library Docs.Deno's documentation is great. I find myself reading it more and more. I currently use a browser addRunning esbuild with esbuild_deno_loaderI've spent probably four or five hours trying to track down this issue, to the point where I actuall`fetch` request always fails onceHello, I got a script containing a `fetch` request. Once in a while, it throws the `connection closeSequentially write to TPC connectionHey, I experience errors when multiple async functions write to a TCP (`Deno.Conn`) connection. How I'd like to change the background colour of the `body` element in Fresh. How do I do that simply?(see title)Deno process watcher. How?This code when compile, runs a simple http server. ```ts import { serve } from "https://deno.land/stmonaco-editor on freshHello. First of all, I am a newbie in web development. I played around with Deno for a while. So I tdeno in Dockerfilei have successfully installed deno with theese commands: ``` # install denojs RUN curl -fsSL https:could not find npm package forI'm trying to make Hardhat CLI work with Deno but I stumbled upon this error which comes from Deno: Microsoft Transact SQLIs there official Deno driver for this or a recommended way?Remove std/node, it was merged into Deno itself (#3206)This used to work, but now it doesn't. Where do you show examples of where this was moved to and howFFI Difference between buffer and pointerI’ve been using interchangeably `Deno.UnsafePointer.of(new Uint8Array())` with type `pointer` and `nDetecting invalid JS stringsIs there any built-in way to "detect" invalid strings? Here's an example: ```ts // this is an invaError connecting to MongoDB AtlasHello, I'm trying to connect to MongoDB Atlas via `mongoose` (`npm:mongoose`) but encountered the fo