Documentation
¶
Overview ¶
Package sitebuild compiles the TypeScript, TSX and JSX of a site's source tree into the JavaScript it serves (#2774). A release opts in with a _build.json at its root; each entry it names is bundled with the local modules it imports into one ES module beside it, and its imports of libraries go to the exact version URLs the file maps them to. The compile reads only the tree, and the network only when the release asks for its URL modules to be bundled.
Index ¶
Constants ¶
const ( // RemoteExternal leaves a URL import a URL, for the browser to load. RemoteExternal = "external" // RemoteBundle fetches it at publish and bundles it into the output. RemoteBundle = "bundle" )
The two answers to what a URL import becomes.
const ControlFile = "_build.json"
ControlFile is the file whose presence turns the compile on. It is source: read at publish and never served.
const Version = reviewedCompiler + "/1"
Version names what an output is a function of beyond its inputs: the compiler and these options. An output compiled under another version is compiled again.
Variables ¶
This section is empty.
Functions ¶
func IsSource ¶
IsSource reports whether a release path is compiled source, which a release with a control file never serves.
Types ¶
type Config ¶
type Config struct {
// Entries are the files compiled, each to its own output.
Entries []string `json:"entries"`
// Imports maps a bare specifier, or a prefix of one ending in /, to the
// exact-version URL it is loaded from.
Imports map[string]string `json:"imports"`
// Remote is RemoteExternal (the default) or RemoteBundle.
Remote string `json:"remote"`
// Sourcemap writes <output>.map beside each output, holding the source.
Sourcemap bool `json:"sourcemap"`
// Minify shortens the output.
Minify bool `json:"minify"`
}
Config is what a control file declares.
type Fetcher ¶
type Fetcher interface {
Fetch(ctx context.Context, url string) (body []byte, contentType string, err error)
}
Fetcher reads a module by URL, for a release that bundles its URL modules.
type LimitError ¶
LimitError is a compile stopped for reading or writing more than it may.
func (*LimitError) Error ¶
func (e *LimitError) Error() string
type Limits ¶
type Limits struct {
// Modules is how many modules, local and fetched, one entry may read.
Modules int
// FileBytes is the largest one module may be.
FileBytes int64
// InputBytes is what all of one entry's modules may hold together.
InputBytes int64
// OutputBytes is what one entry's outputs may hold together.
OutputBytes int64
}
Limits bound one entry's compile.
type Options ¶
type Options struct {
Config *Config
Limits Limits
// Fetch reads URL modules in bundle mode; nil refuses them.
Fetch Fetcher
}
Options are what a compile is given besides its tree and entry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package modfetch reads the modules a site release bundles at publish (#2774): by URL, through the egress guard, kept in the replica's memory by URL.
|
Package modfetch reads the modules a site release bundles at publish (#2774): by URL, through the egress guard, kept in the replica's memory by URL. |