Documentation
¶
Overview ¶
Package esbuild provides functions for building JavaScript resources.
Package esbuild provides functions for building JavaScript resources.
Package esbuild provides functions for building JavaScript resources.
Index ¶
- Constants
- func NewBatcherClient(deps *deps.Deps) (js.BatcherClient, error)
- func ResolveComponent[T any](impPath string, resolve func(string) (v T, found, isDir bool)) (v T, found bool)
- func ResolveResource(impPath string, resourceGetter resource.ResourceGetter) (r resource.Resource)
- func SourcesFromSourceMap(s string) []string
- func ValidateBatchID(id string, isTopLevel bool) error
- type BatcherClient
- type BuildClient
- type ErrorMessageResolved
- type ExternalOptions
- type InternalOptions
- type Options
- type Package
Constants ¶
const ( NsHugoImport = "ns-hugo-imp" NsHugoImportResolveFunc = "ns-hugo-imp-func" )
const ( PrefixHugoVirtual = "__hu_v" PrefixHugoMemory = "__hu_m" )
const (
NsBatch = "_hugo-js-batch"
)
Variables ¶
This section is empty.
Functions ¶
func NewBatcherClient ¶
func NewBatcherClient(deps *deps.Deps) (js.BatcherClient, error)
func ResolveComponent ¶
func ResolveComponent[T any](impPath string, resolve func(string) (v T, found, isDir bool)) (v T, found bool)
ResolveComponent resolves a component using the given resolver.
func ResolveResource ¶
func ResolveResource(impPath string, resourceGetter resource.ResourceGetter) (r resource.Resource)
ResolveResource resolves a resource using the given resourceGetter.
func ValidateBatchID ¶
ValidateBatchID validates the given ID according to some very
Types ¶
type BatcherClient ¶
type BatcherClient struct {
// contains filtered or unexported fields
}
BatcherClient is a client for building JavaScript packages.
type BuildClient ¶
type BuildClient struct {
// contains filtered or unexported fields
}
BuildClient is a client for building JavaScript resources using esbuild.
func NewBuildClient ¶
func NewBuildClient(fs *filesystems.SourceFilesystem, rs *resources.Spec) *BuildClient
NewBuildClient creates a new BuildClient.
func (*BuildClient) Build ¶
func (c *BuildClient) Build(opts Options) (api.BuildResult, error)
Build builds the given JavaScript resources using esbuild with the given options.
type ErrorMessageResolved ¶
type ErrorMessageResolved struct { Path string Message string Content hugio.ReadSeekCloser }
ErrorMessageResolved holds a resolved error message.
type ExternalOptions ¶
type ExternalOptions struct { // If not set, the source path will be used as the base target path. // Note that the target path's extension may change if the target MIME type // is different, e.g. when the source is TypeScript. TargetPath string // Whether to minify to output. Minify bool // One of "inline", "external", "linked" or "none". SourceMap string SourcesContent bool // The language target. // One of: es2015, es2016, es2017, es2018, es2019, es2020 or esnext. // Default is esnext. Target string // The output format. // One of: iife, cjs, esm // Default is to esm. Format string // One of browser, node, neutral. // Default is browser. // See https://esbuild.github.io/api/#platform Platform string // External dependencies, e.g. "react". Externals []string // This option allows you to automatically replace a global variable with an import from another file. // The filenames must be relative to /assets. // See https://esbuild.github.io/api/#inject Inject []string // User defined symbols. Defines map[string]any // This tells esbuild to edit your source code before building to drop certain constructs. // See https://esbuild.github.io/api/#drop Drop string // Maps a component import to another. Shims map[string]string // Configuring a loader for a given file type lets you load that file type with an // import statement or a require call. For example, configuring the .png file extension // to use the data URL loader means importing a .png file gives you a data URL // containing the contents of that image // // See https://esbuild.github.io/api/#loader Loaders map[string]string // User defined params. Will be marshaled to JSON and available as "@params", e.g. // import * as params from '@params'; Params any // What to use instead of React.createElement. JSXFactory string // What to use instead of React.Fragment. JSXFragment string // What to do about JSX syntax. // See https://esbuild.github.io/api/#jsx JSX string // Which library to use to automatically import JSX helper functions from. Only works if JSX is set to automatic. // See https://esbuild.github.io/api/#jsx-import-source JSXImportSource string // There is/was a bug in WebKit with severe performance issue with the tracking // of TDZ checks in JavaScriptCore. // // Enabling this flag removes the TDZ and `const` assignment checks and // may improve performance of larger JS codebases until the WebKit fix // is in widespread use. // // See https://bugs.webkit.org/show_bug.cgi?id=199866 // Deprecated: This no longer have any effect and will be removed. // TODO(bep) remove. See https://github.com/evanw/esbuild/commit/869e8117b499ca1dbfc5b3021938a53ffe934dba AvoidTDZ bool }
ExternalOptions holds user facing options for the js.Build template function.
func DecodeExternalOptions ¶
func DecodeExternalOptions(m map[string]any) (ExternalOptions, error)
DecodeExternalOptions decodes the given map into ExternalOptions.
type InternalOptions ¶
type InternalOptions struct { MediaType media.Type OutDir string Contents string SourceDir string ResolveDir string AbsWorkingDir string Metafile bool StdinSourcePath string DependencyManager identity.Manager Stdin bool // Set to true to pass in the entry point as a byte slice. Splitting bool TsConfig string EntryPoints []string ImportOnResolveFunc func(string, api.OnResolveArgs) string ImportOnLoadFunc func(api.OnLoadArgs) string ImportParamsOnLoadFunc func(args api.OnLoadArgs) json.RawMessage ErrorMessageResolveFunc func(api.Message) *ErrorMessageResolved ResolveSourceMapSource func(string) string // Used to resolve paths in error source maps. }
InternalOptions holds internal options for the js.Build template function.
type Options ¶
type Options struct { ExternalOptions InternalOptions // contains filtered or unexported fields }
Options holds the options passed to Build.