Documentation
¶
Overview ¶
Package compile turns an lfm project into a deployable output folder.
One compile runs a fixed lifecycle. A stage starts only when the previous ones produced no errors, and every stage reports through the same diagnostics, so one run explains everything that needs fixing:
- load read lfm.json and data/
- prepare check template bindings and links statically, then render
- assemble resolve, bundle and pack every referenced resource
- optimize (release) split critical CSS after measuring it in Chrome
- finalize serialize and compact the document
- verify run every document check on the exact final bytes
- audit (release) runtime probe and Lighthouse in a headless browser
- publish replace output/ in one rename
Nothing is written before verify passes; a failed compile keeps the previous output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectCheckOptions ¶ added in v0.1.9
ProjectCheckOptions pairs an already built page with the same project facts and validation settings used by Compile. Resource bytes stay those of the target.
func Rules ¶
func Rules() []diagnostic.RuleInfo
Rules lists every rule any stage of the lifecycle can report, sorted by ID.
func TemplateHelp ¶ added in v0.1.9
func TemplateHelp() string
TemplateHelp describes the helper set installed by the compiler.
Types ¶
type AssetDecision ¶
type AssetDecision struct {
Source string `json:"source"`
Aliases []string `json:"aliases,omitempty"`
Pinned bool `json:"pinned,omitempty"`
Mode string `json:"mode"`
Bytes int `json:"bytes"`
Contribution int `json:"encodedContributionBytes"`
HTMLContribution int `json:"htmlContributionBytes"`
Occurrences int `json:"occurrences"`
Reason string `json:"reason"`
Output string `json:"output,omitempty"`
Encoding string `json:"encoding,omitempty"`
}
type Cost ¶
type Cost struct {
HTMLBytes int `json:"htmlBytes"`
GzipBytes int `json:"htmlGzipLevel1Bytes"`
SidecarBytes int `json:"sidecarBytes"`
TotalBytes int `json:"totalRawBytes"`
CSSBytes int `json:"totalCSSBytes"`
JSBytes int `json:"totalJSBytes"`
ExternalCSSBytes int `json:"externalCSSBytes"`
ExternalJSBytes int `json:"externalJSBytes"`
}
type Failure ¶
type Failure struct{ Errors int }
Failure is returned when diagnostics block the compile.
type File ¶
type File struct {
Name string `json:"name"`
Bytes int `json:"bytes"`
SHA256 string `json:"sha256"`
}
File is one emitted output file.
type Options ¶
type Options struct {
Release bool // browser-backed optimize and audit stages
Publish bool // replace output/ on success
Waiting func() // called when another compile of the project holds the lock
}
Options select the optional lifecycle stages.
type Result ¶
type Result struct {
Root string `json:"root"`
Output string `json:"output"`
PageURL string `json:"url,omitempty"`
Files []File `json:"files"`
Artifact map[string][]byte `json:"-"` // emitted bytes by file name
// Distribution holds the store packages per unit (each deliverable and
// the bundle) by file name, published to distribution/<unit>/ and never
// deployed. A unit without an entry is left as it is; an empty one is
// removed.
Distribution map[string]map[string][]byte `json:"-"`
// Previews are rendered deliverable pages lfm serve shows and publish
// never writes, such as each printable edition as HTML.
Previews map[string][]byte `json:"-"`
External []string `json:"externalAssets,omitempty"`
Validation *check.Report `json:"validation,omitempty"`
Published bool `json:"published"`
Release *release.Result `json:"release,omitempty"`
Packing []AssetDecision `json:"assets,omitempty"`
Cost *Cost `json:"cost,omitempty"`
Compaction *htmlcompact.Result `json:"htmlCompaction,omitempty"`
Images []imaging.Decision `json:"images,omitempty"`
Fonts []fontcheck.Info `json:"fonts,omitempty"`
Research research.Summary `json:"research"`
Concept concept.Summary `json:"concept"`
SocialMeta []string `json:"socialMetaRepairs,omitempty"`
FontHints int `json:"fontHintRepairs,omitempty"`
PageOffers bool `json:"pageOffers,omitempty"`
Starter bool `json:"starter"` // the template is still the starter page of lfm init
Book *book.Summary `json:"book,omitempty"`
Printable *printable.Summary `json:"printable,omitempty"`
Bundle *bundle.Summary `json:"bundle,omitempty"`
Spreadsheet *spreadsheet.Summary `json:"spreadsheet,omitempty"`
Document *document.Summary `json:"document,omitempty"`
Deck *deck.Summary `json:"deck,omitempty"`
// Optional names the helpers a release found missing and what each
// would add; no release needs them.
Optional []string `json:"optional,omitempty"`
Inputs []string `json:"-"` // resolved source files, for watchers
Duration time.Duration `json:"-"`
}
Result describes a compile, filled as far as the lifecycle got.
func Compile ¶
Compile runs the lifecycle on the project in dir. Cancelling ctx stops it between stages; a cancelled compile never publishes.
func (Result) PageNeeded ¶ added in v0.1.12
PageNeeded reports whether the current page participates in selling the deliverables.
Source Files
¶
- assets.go
- book.go
- book_images.go
- bookprint.go
- bundle.go
- bundles.go
- compare.go
- compile.go
- deck.go
- discovery.go
- document.go
- favicon.go
- fonts.go
- helpers.go
- hints.go
- html.go
- image_sizing.go
- images.go
- kit.go
- lock_unix.go
- packing.go
- prepare.go
- press.go
- printable.go
- project_check.go
- public.go
- publish.go
- release.go
- release_cache.go
- rules.go
- sharing_assets.go
- social_card.go
- spreadsheet.go
- units.go