Documentation ¶
Index ¶
- Variables
- func New(path string, c []PackComponent, opts *NewSourceMapOpts) (dependtree.DependencySourceMap, error)
- type CachedEnvKeys
- type Component
- func (s *Component) BundleKey() string
- func (s *Component) Dependencies() []*jsparse.ImportDependency
- func (s *Component) IsStaticResource() bool
- func (s *Component) JsDocument() jsparse.JSDocument
- func (s *Component) Name() string
- func (s *Component) OriginalFilePath() string
- func (s *Component) Repack() error
- func (s *Component) RepackForWaitGroup(wg *sync.WaitGroup) error
- func (s *Component) WebWrapper() webwrap.JSWebWrapper
- type DefaultPackerOpts
- type JSDependencyTree
- type JSPacker
- type NewComponentOpts
- type NewSourceMapOpts
- type PackComponent
- type PackComponentFileMap
- type PackHook
- type PackedComponentList
- type Packer
- type SrcDependency
- type SyncHook
Constants ¶
This section is empty.
Variables ¶
var ErrComponentNotExported = errors.New("component not exported")
var ErrInvalidComponentType = errors.New("invalid component type")
var ErrInvalidPageName = errors.New("invalid page name")
var ErrParserError = errors.New("page can not be parsed")
Functions ¶
func New ¶
func New(path string, c []PackComponent, opts *NewSourceMapOpts) (dependtree.DependencySourceMap, error)
Types ¶
type CachedEnvKeys ¶
CachedEnvKeys represents a map where the key is the filepath for the env setting and where the value is a bundler key
type Component ¶
type Component struct { WebDir string JsParser jsparse.JSParser // contains filtered or unexported fields }
component that has been successfully ran, and output from a packing method. a component represents a source file that has a valid parser
func (*Component) Dependencies ¶
func (s *Component) Dependencies() []*jsparse.ImportDependency
Dependencies returns the dependencies on the component
func (*Component) IsStaticResource ¶ added in v0.7.0
func (*Component) JsDocument ¶ added in v0.21.0
func (s *Component) JsDocument() jsparse.JSDocument
func (*Component) OriginalFilePath ¶
OriginalFilePath returns the original file path on the component
func (*Component) Repack ¶
Repack repacks a component following the following processes
- parses the provided filepath with the the components jsparser
- reapplies the component web wrapper
- bundles the component
func (*Component) RepackForWaitGroup ¶
RepackForWaitGroup given a wait group, repacks the component using the underlying "Repack" method.
func (*Component) WebWrapper ¶
func (s *Component) WebWrapper() webwrap.JSWebWrapper
WebWrapper returns the instance of the webwrapper applied to the component
type DefaultPackerOpts ¶
type DefaultPackerOpts struct { WebDir string BundlerMode string NodeModuleDir string CachedBundleKeys CachedEnvKeys SkipFirstPassBundle bool }
DefaultPackerOpts options for creating a new default packer
type JSDependencyTree ¶
type JSDependencyTree struct { WebDir string JsParser jsparse.JSParser // contains filtered or unexported fields }
JSDependencyTree is a javascript dependency tree, used to create a dependency tree from javascript files this struct should salsify the requirements for "DependencyTree" interface
func (*JSDependencyTree) DirList ¶
func (s *JSDependencyTree) DirList(path string) ([]string, error)
func (*JSDependencyTree) PathDependencies ¶
func (s *JSDependencyTree) PathDependencies(path string) ([]string, error)
uses the js parser to get all of the dependencies for the specified file.
type JSPacker ¶ added in v0.3.6
type JSPacker struct { JsParser jsparse.JSParser ValidWebWrappers webwrap.JSWebWrapperList Logger log.Logger SkipFirstPassBundle bool AssetDir string WebDir string // contains filtered or unexported fields }
packer is the primary struct used for packing a directory of javascript files into valid web components.
func (*JSPacker) PackMany ¶ added in v0.3.6
func (s *JSPacker) PackMany(pages []string) (PackedComponentList, error)
PackMany packs the provided file paths into the orbit root directory
func (*JSPacker) PackSingle ¶ added in v0.3.6
type NewComponentOpts ¶
type NewComponentOpts struct { FilePath string WebDir string DefaultKey string JSParser jsparse.JSParser JSWebWrappers webwrap.JSWebWrapperList SkipFirstPassBundle bool }
NewComponentOpts options for creating a new component
type NewSourceMapOpts ¶ added in v0.7.0
type PackComponent ¶ added in v0.3.2
type PackComponent interface { Repack() error RepackForWaitGroup(wg *sync.WaitGroup) error OriginalFilePath() string Dependencies() []*jsparse.ImportDependency BundleKey() string Name() string WebWrapper() webwrap.JSWebWrapper IsStaticResource() bool JsDocument() jsparse.JSDocument }
func NewComponent ¶
func NewComponent(ctx context.Context, opts *NewComponentOpts) (PackComponent, error)
NewComponent creates a new component that represents a packaged & bundled web component
type PackComponentFileMap ¶ added in v0.7.0
type PackComponentFileMap map[string]PackComponent
func (PackComponentFileMap) Find ¶ added in v0.7.0
func (m PackComponentFileMap) Find(key string) PackComponent
Find finds the provided key if one exists
func (PackComponentFileMap) FindBundleKey ¶ added in v0.7.0
func (m PackComponentFileMap) FindBundleKey(key string) PackComponent
Find finds and returns the the first component with provided bundle key
func (PackComponentFileMap) Set ¶ added in v0.7.0
func (m PackComponentFileMap) Set(component PackComponent)
type PackHook ¶
type PackHook interface { Pre(filePath string) // "pre" runs before each component packing iteration Post(filepath string, elapsedTime float64) // "post" runs after each component packing iteration Close() }
hooks for logging the pre & post operations of the packing process.
type PackedComponentList ¶
type PackedComponentList []PackComponent
func (*PackedComponentList) RepackMany ¶
func (l *PackedComponentList) RepackMany(logger log.Logger) error
func (*PackedComponentList) Write ¶ added in v0.10.0
func (l *PackedComponentList) Write(path string) error
Write creates an audit file of all the current components to the specified file
type Packer ¶
type Packer interface { PackMany(pages []string) (PackedComponentList, error) PackSingle(logger log.Logger, file string) (PackComponent, error) ReattachLogger(logger log.Logger) Packer }
func NewDefaultPacker ¶
func NewDefaultPacker(logger log.Logger, opts *DefaultPackerOpts) Packer
type SrcDependency ¶
type SrcDependency interface { OriginalFilePath() string Dependencies() []*jsparse.ImportDependency }