deno.land / x / packup@v0.1.12 / bundle_util.ts

bundle_util.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { resolve, toFileUrl } from "./deps.ts";import { logger } from "./logger_util.ts";import { build, load } from "https://deno.land/x/esbuild_loader@v0.12.8/mod.ts";import { denoPlugin } from "./vendor/esbuild_deno_loader/mod.ts";
type Builder = typeof build;let b: Builder | null = null;async function loadBuilder(wasmPath: string): Promise<Builder> { if (b) { return b; } const start = Date.now(); const { build } = await load(wasmPath); logger.debug(`Esbuild loaded in ${Date.now() - start}ms`); b = build; return b;}export async function bundleByEsbuild( path: string, wasmPath: string,): Promise<string> { const build = await loadBuilder(wasmPath);
const bundle = await build({ entryPoints: [toFileUrl(resolve(path)).href], plugins: [denoPlugin()], bundle: true, });
return bundle.outputFiles![0].text;}
packup
📦 Zero-config web application packager in Deno
GitHub Repositorykt3k/packup
GitHub Stars
260

Version Info

Tagged at
4 months ago