entrypoint_browser_bundle

package
v0.51.8 Latest Latest
Warning

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

Go to latest
Published: May 31, 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 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 BuildRendererBundle

func BuildRendererBundle(
	le *logrus.Entry,
	sourcesRoot,
	bldrDistRoot,
	buildDir,
	runtimeJsPath,
	runtimeSwPath,
	runtimeShwPath,
	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 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 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 ServiceWorkerBuildOpts

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

ServiceWorkerBuildOpts creates the BuildOpts for the service worker

func SharedWorkerBuildOpts

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

SharedWorkerBuildOpts creates the BuildOpts for the shared worker

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
	// 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"`
	CSS           []string `json:"css"`
	AutoStart     bool     `json:"autoStart,omitempty"`
}

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

Jump to

Keyboard shortcuts

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