entrypoint_browser_bundle

package
v0.53.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EsbuildLogLevel = esbuild.LogLevelWarning

EsbuildLogLevel is the log level when bundling the bundle.

Functions

func ApplyRuntimeDistDepsResolver added in v0.52.0

func ApplyRuntimeDistDepsResolver(opts *esbuild.BuildOptions, buildPkgsDir string)

func ApplyTinyGoNodeFallbacks added in v0.51.7

func ApplyTinyGoNodeFallbacks(opts *esbuild.BuildOptions)

ApplyTinyGoNodeFallbacks keeps TinyGo's browser wasm_exec.js Node fallbacks external so the injected browser stubs can provide runtime globals instead.

func BrowserBuildOpts

func BrowserBuildOpts(workingDir string, minify, sourcemaps bool) esbuild.BuildOptions

BrowserBuildOpts are general options for building for the browser.

func BrowserEntrypointBuildOpts

func BrowserEntrypointBuildOpts(bldrDistRoot string, minify, sourcemaps bool) esbuild.BuildOptions

BrowserEntrypointBuildOpts creates the BuildOpts for the root browser entrypoint

func BuildOpfsWorkerBundle added in v0.52.0

func BuildOpfsWorkerBundle(le *logrus.Entry, bldrDistRoot, buildDir string, minify, sourcemaps, devMode bool) (string, error)

BuildOpfsWorkerBundle builds the OPFS protocol worker bundle.

Returns the filename of the OPFS worker output file (including the hash).

func BuildOpfsWorkerBundleWithRuntimeDeps added in v0.52.0

func BuildOpfsWorkerBundleWithRuntimeDeps(le *logrus.Entry, bldrDistRoot, buildDir, buildPkgsDir string, minify, sourcemaps, devMode bool) (string, error)

func BuildRendererBundle

func BuildRendererBundle(
	le *logrus.Entry,
	sourcesRoot,
	bldrDistRoot,
	buildDir,
	runtimeJsPath,
	runtimeSwPath,
	runtimeShwPath,
	runtimeOpfsWorkerPath,
	webStartupSrcPath,
	entrypointHash string,
	minify,
	sourcemaps,
	forceDedicatedWorkers,
	forceMessagePortWorkerComms,
	devMode bool,
	webPkgImportMap web_entrypoint_index.ImportMap,
) ([]string, error)

BuildRendererBundle builds the web renderer bundle files.

webStartupSrcPath is the path to the startup js module to load for the react app entrypoint (can be empty). entrypointHash, if set, builds into /entrypoint/{entrypointHash}/... BuildRendererBundle builds the web renderer bundle and returns CSS output paths relative to buildDir.

func BuildRendererIndex

func BuildRendererIndex(buildDir, entrypointPath string, importMap web_entrypoint_index.ImportMap) error

BuildRendererIndex builds the web renderer index.html.

importMap contains the web pkg import map entries (from BuildWebPkgsBundle).

func BuildServiceWorkerBundle

func BuildServiceWorkerBundle(le *logrus.Entry, bldrDistRoot, buildDir string, minify, sourcemaps, devMode bool) (string, error)

BuildServiceWorkerBundle builds specifically the service worker files.

Returns the filename of the service worker output file (including the hash).

func BuildServiceWorkerBundleWithRuntimeDeps added in v0.52.0

func BuildServiceWorkerBundleWithRuntimeDeps(le *logrus.Entry, bldrDistRoot, buildDir, buildPkgsDir string, minify, sourcemaps, devMode bool) (string, error)

func BuildSharedWorkerBundle

func BuildSharedWorkerBundle(le *logrus.Entry, bldrDistRoot, buildDir string, minify, sourcemaps, devMode bool) (string, error)

BuildSharedWorkerBundle builds specifically the shared worker files.

Returns the filename of the shared worker output file (including the hash).

func BuildSharedWorkerBundleWithRuntimeDeps added in v0.52.0

func BuildSharedWorkerBundleWithRuntimeDeps(le *logrus.Entry, bldrDistRoot, buildDir, buildPkgsDir string, minify, sourcemaps, devMode bool) (string, error)

func BuildWebPkgsBundle

func BuildWebPkgsBundle(ctx context.Context, le *logrus.Entry, stateDir string, plat bldr_platform.Platform, bldrDistRoot, buildDir, pathPrefix string, minify, sourcemaps, devMode bool) (web_entrypoint_index.ImportMap, error)

BuildWebPkgsBundle builds the web pkg bundle files.

stateDir is the directory where bun will be downloaded if not found in PATH. pathPrefix is the prefix to prepend to /pkgs/ for pkg paths Returns the import map entries mapping logical specifiers to hashed output paths.

func DefaultBanner

func DefaultBanner() map[string]string

DefaultBanner is the default banner applied to code files.

func EnsureBldrDistDepsInstall added in v0.52.0

func EnsureBldrDistDepsInstall(ctx context.Context, le *logrus.Entry, stateDir, bldrDistRoot string) (string, error)

func OpfsWorkerBuildOpts added in v0.52.0

func OpfsWorkerBuildOpts(bldrDistRoot string, minify, sourcemaps, hash bool) esbuild.BuildOptions

OpfsWorkerBuildOpts creates the BuildOpts for the OPFS protocol worker.

func OpfsWorkerBuildOptsWithRuntimeDeps added in v0.52.0

func OpfsWorkerBuildOptsWithRuntimeDeps(bldrDistRoot, buildPkgsDir string, minify, sourcemaps, hash bool) esbuild.BuildOptions

func RuntimeDistDepsResolverPlugin added in v0.52.0

func RuntimeDistDepsResolverPlugin(buildPkgsDir, bldrDistRoot string) esbuild.Plugin

func ServiceWorkerBuildOpts

func ServiceWorkerBuildOpts(bldrDistRoot string, minify, sourcemaps, hash bool) esbuild.BuildOptions

ServiceWorkerBuildOpts creates the BuildOpts for the service worker

func ServiceWorkerBuildOptsWithRuntimeDeps added in v0.52.0

func ServiceWorkerBuildOptsWithRuntimeDeps(bldrDistRoot, buildPkgsDir string, minify, sourcemaps, hash bool) esbuild.BuildOptions

func SharedWorkerBuildOpts

func SharedWorkerBuildOpts(bldrDistRoot string, minify, sourcemaps, hash bool) esbuild.BuildOptions

SharedWorkerBuildOpts creates the BuildOpts for the shared worker

func SharedWorkerBuildOptsWithRuntimeDeps added in v0.52.0

func SharedWorkerBuildOptsWithRuntimeDeps(bldrDistRoot, buildPkgsDir string, minify, sourcemaps, hash bool) esbuild.BuildOptions

func WriteBuildManifest

func WriteBuildManifest(dir string, manifest *BuildManifest) error

WriteBuildManifest writes a manifest.json to the given directory.

func WriteStableBootAsset

func WriteStableBootAsset(dir string) error

WriteStableBootAsset writes the stable browser boot asset at the build root.

Types

type BrowserBundleResult

type BrowserBundleResult struct {
	// EntrypointPath is the path to the entrypoint mjs relative to the build dir.
	EntrypointPath string
	// ServiceWorkerFilename is the output filename of the service worker.
	ServiceWorkerFilename string
	// SharedWorkerFilename is the output filename of the shared worker.
	SharedWorkerFilename string
	// OpfsWorkerFilename is the output filename of the OPFS protocol worker.
	OpfsWorkerFilename string
	// CSSPaths contains CSS output file paths relative to the build dir.
	CSSPaths []string
}

BrowserBundleResult contains the output filenames from a browser bundle build.

func BuildBrowserBundle

func BuildBrowserBundle(
	ctx context.Context,
	le *logrus.Entry,
	stateDir,
	sourcesRoot,
	bldrDistRoot,
	buildDir,
	runtimeJsPath,
	runtimeSwPath,
	runtimeShwPath,
	webStartupSrcPath string,
	entrypointHash string,
	minify,
	sourcemaps,
	devMode,
	forceDedicatedWorkers,
	forceMessagePortWorkerComms bool,
) (*BrowserBundleResult, error)

BuildBrowserBundle builds and outputs the web & service worker files.

stateDir is the directory where bun will be downloaded if not found in PATH. webStartupSrcPath is the path to the startup js module to load for the react app entrypoint (can be empty). entrypointHash, if set, builds into /entrypoint/{entrypointHash}/...

type BuildManifest

type BuildManifest struct {
	Entrypoint            string                 `json:"entrypoint"`
	ServiceWorker         string                 `json:"serviceWorker"`
	SharedWorker          string                 `json:"sharedWorker"`
	Wasm                  string                 `json:"wasm,omitempty"`
	OpfsWorker            string                 `json:"opfsWorker,omitempty"`
	CSS                   []string               `json:"css"`
	AutoStart             bool                   `json:"autoStart,omitempty"`
	DefaultManifestBundle *DefaultManifestBundle `json:"defaultManifestBundle,omitempty"`
}

BuildManifest is the manifest.json structure written alongside index.html. The prerender build script reads this to discover asset URLs.

type DefaultManifestBundle added in v0.52.0

type DefaultManifestBundle struct {
	Metadata string `json:"metadata"`
	Pack     string `json:"pack"`
}

DefaultManifestBundle describes the browser-discoverable manifest bundle transport for first-boot range reads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL