Skip to content

tuist/SwiftyESBuild

Folders and files

NameName
Last commit message
Last commit date
Jan 17, 2024
Nov 11, 2023
Jun 27, 2023
Jun 21, 2023
Jun 20, 2023
Nov 11, 2023
Jun 22, 2023
Jun 20, 2023
Nov 11, 2023
Oct 2, 2024
Jun 27, 2023
Jun 23, 2023

Repository files navigation

SwiftyESBuild ⭐️

Netlify Status SwiftyESBuild

SwiftyESBuild is a Swift Package that wraps ESBuild to ease bringing bundling capabilities to Swift on Server apps.

Usage

First, you need to add SwiftyESBuild as a dependency in your project's Package.swift:

.package(url: "https://github.com/tuist/SwiftyESBuild.git", .upToNextMinor(from: "0.2.0"))

Once added, you'll create an instance of SwiftyESBuild specifying the version you'd like to use and where you'd like it to be downloaded.

let esbuild = SwiftyESBuild(version: .latest, directory: "./cache")

If you don't pass any argument, it defaults to the latest version in the system's default temporary directory. If you work in a team, we recommend fixing the version to minimize non-determinism across environments.

Running ESBuild

To run ESBuild you need to invoke the run function:

import TSCBasic // AbsolutePath

let entryPointPath = AbsolutePath(validating: "/project/index.js")
let outputBundlePath = AbsolutePath(validating: "/projects/build/index.js")
try await esbuild.run(entryPoint: entryPointPath, options: .bundle, .outfile(outputBundlePath))