---
title: js.Build
description: Bundle, transpile, tree shake, and minify JavaScript resources.
categories: []
keywords: []
params:
functions_and_methods:
aliases: []
returnType: resource.Resource
signatures: ['js.Build [OPTIONS] RESOURCE']
---
> [!NOTE]
> The `js.Build` function is backed by the [`evanw/esbuild`][] package, providing a mature, high-performance foundation for bundling, transformation, and minification.
Use the `js.Build` function to:
- Bundle
- Transpile (TypeScript and JSX)
- Tree shake
- Minify
- Create source maps
```go-html-template
{{ with resources.Get "js/main.js" }}
{{$opts := dict
"minify" (cond hugo.IsDevelopment false true)
"sourceMap" (cond hugo.IsDevelopment "linked" "none")
}}
{{ with . | js.Build $opts }}
{{ if hugo.IsDevelopment }}
{{ else }}
{{ with . | fingerprint }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
```
## Options
The `js.Build` function accepts an options map.
`format`
: (`string`) The output format. One of: `iife`, `cjs`, `esm`. Default is `iife`, a self-executing function, suitable for inclusion as a `
```
[`esbuild`]: https://esbuild.github.io/
[`evanw/esbuild`]: https://github.com/evanw/esbuild
[`hugo mod npm pack`]: /commands/hugo_mod_npm_pack/
[test project]: https://github.com/gohugoio/hugoTestProjectJSModImports
[turn it off]: /configuration/build/#nojsconfiginassets