create distribution file(s) for your deno project.

the buildDist function in this module provides a convenient way for you to bundle your deno-project using esbuild.

for more advanced bundling, use the bundle function, then proceed with additional transformations via the transform function, and then finally write the output to your filesystem via the createFiles utility function.

import { bundle, transform, esStop } from "jsr:@oazmi/build-tools/dist"
import { createFiles } from "jsr:@oazmi/build-tools/funcdefs"

const bundled_files = await bundle({
// when no input files are provided, the function reads your "deno.json" file to use its "exports" field as the input.
input: {
"my-lib.js": "./src/mod.ts",
"plugins/hello.js": "./src/plugins/hello.ts",
"plugins/world.js": "./src/plugins/world.ts",
},
deno: "./deno.json",
dir: "./dist/",
log: "verbose",
esbuild: { splitting: true }
})
const minified_files = await transform(bundled_files, [{}])
await createFiles(minified_files, {
dir: "./dist/", // this information is not really needed, as the file paths in `minified_files` are absolute.
dryrun: false,
log: "verbose",
})
// your output files are now saved to: "./dist/my-lib.js", "./dist/plugins/hello.js", and "./dist/plugins/world.js"

// it is important that you stop esbuild manually, otherwise the deno process will not quit automatically.
await esStop()

References

Re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins
Renames and re-exports denoPlugins