class JsCompiler extends RevisionCompiler

Traits

Constants

EMPTY_REVISION

Properties

protected callable[] $sourcesCallbacks from HasSources
protected array<string,string> $pendingSidecars Sidecar files (e.g. JsCompiler's `.map`) queued by renderOutput() during the current commit, written only if the primary file is — so an unchanged bundle rewrites nothing at all. from RevisionCompiler

Methods

void
addSources(callable $callback)

No description

array
getSources()

No description

array
allowedSourceTypes()

No description

__construct(Cloud $assetsDir, string $filename, SettingsRepositoryInterface $settings, VersionerInterface $versioner)

No description

string|null
getFilename()

No description

void
setFilename(string $filename)

No description

void
commit(bool $force = false)

Recompile this asset and record its revision. Files are only written when the compiled output actually differs from what the revision manifest says is on disk (or the file has gone missing) — so routine rebuilds of unchanged assets are complete no-ops with zero writes.

void
writePendingSidecars()

No description

string
hashOutput(string $content)

No description

string|null
renderOutput(array $sources)

Assemble the JS bundle and its sourcemap. The `.map` sidecar is written here as a side effect; the returned string is the JS file's content, which the parent commits and hashes for the revision. Hashing this — rather than the raw concatenated source — means the revision reflects the sourcemap comment and `format()` rewrite that the written file actually carries.

string|null
getUrl()

No description

string
compile(array $sources)

No description

string
format(string $string)

No description

void
flush()

No description

void
delete(string $file)

No description

Details

void addSources(callable $callback)

Parameters

callable $callback

Return Value

void

protected array getSources()

Return Value

array

abstract protected array allowedSourceTypes()

Return Value

array

__construct(Cloud $assetsDir, string $filename, SettingsRepositoryInterface $settings, VersionerInterface $versioner)

Parameters

Cloud $assetsDir
string $filename
SettingsRepositoryInterface $settings
VersionerInterface $versioner

string|null getFilename()

Return Value

string|null

void setFilename(string $filename)

Parameters

string $filename

Return Value

void

void commit(bool $force = false)

Recompile this asset and record its revision. Files are only written when the compiled output actually differs from what the revision manifest says is on disk (or the file has gone missing) — so routine rebuilds of unchanged assets are complete no-ops with zero writes.

Parameters

bool $force

Return Value

void

protected void writePendingSidecars()

Return Value

void

protected string hashOutput(string $content)

Parameters

string $content

Return Value

string

protected string|null renderOutput(array $sources)

Assemble the JS bundle and its sourcemap. The `.map` sidecar is written here as a side effect; the returned string is the JS file's content, which the parent commits and hashes for the revision. Hashing this — rather than the raw concatenated source — means the revision reflects the sourcemap comment and `format()` rewrite that the written file actually carries.

Parameters

array $sources

Return Value

string|null

string|null getUrl()

Return Value

string|null

protected string compile(array $sources)

Parameters

array $sources

Return Value

string

protected string format(string $string)

Parameters

string $string

Return Value

string

void flush()

Return Value

void

protected void delete(string $file)

Parameters

string $file

Return Value

void