Volt.Plugin.EmbeddedModule (Volt v0.14.12)

Copy Markdown View Source

A module embedded in a source file owned by a Volt plugin.

Embedded modules model single-file-component subresources such as <script> and <style> blocks. They are addressed as query modules derived from the real parent file instead of opaque synthetic ids, which preserves source-file identity for resolution, watching, and diagnostics.

Summary

Functions

Content type inferred from an embedded module kind.

Return a compiler-friendly filename for the embedded module.

Build the internal query-module id for an embedded module under a parent file.

Return true when an id addresses an embedded module.

Normalize legacy tuple modules or maps into embedded module structs.

Normalize a list of embedded modules and assign indexes where omitted.

Return the real parent file for ids that address embedded modules.

Parse an embedded query-module id.

Build an import specifier for an embedded module from its parent module.

Types

kind()

@type kind() :: :script | :style | :custom

t()

@type t() :: %Volt.Plugin.EmbeddedModule{
  content_type: String.t() | nil,
  extension: String.t(),
  index: non_neg_integer() | nil,
  source: String.t(),
  type: kind()
}

Functions

content_type(embedded_module)

@spec content_type(t()) :: String.t()

Content type inferred from an embedded module kind.

filename(parent, module)

@spec filename(String.t(), t() | nil) :: String.t()

Return a compiler-friendly filename for the embedded module.

id(parent, module)

@spec id(String.t(), t()) :: String.t()

Build the internal query-module id for an embedded module under a parent file.

id?(id)

@spec id?(String.t()) :: boolean()

Return true when an id addresses an embedded module.

normalize(module, index)

@spec normalize(term(), non_neg_integer()) :: t()

Normalize legacy tuple modules or maps into embedded module structs.

normalize_all(modules)

@spec normalize_all([term()]) :: [t()]

Normalize a list of embedded modules and assign indexes where omitted.

parent_path(id)

@spec parent_path(String.t()) :: String.t()

Return the real parent file for ids that address embedded modules.

parse_id(id)

@spec parse_id(String.t()) :: {:ok, Volt.Plugin.EmbeddedModule.ID.t()} | :error

Parse an embedded query-module id.

specifier(parent, module)

@spec specifier(String.t(), t()) :: String.t()

Build an import specifier for an embedded module from its parent module.