concatjs

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package concatjs provides a simple way of serving JavaScript sources in development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeConcatenatedJS

func ServeConcatenatedJS(manifestPath string, root string, preScripts []string, postScripts []string, fs FileSystem) http.Handler

ServeConcatenatedJS returns an http.Handler that serves the JavaScript files listed in manifestPath in one concatenated, eval separated response body.

This greatly speeds up development load times due to fewer HTTP requests, but still for easy debugging by giving the eval'ed fragments URLs through sourceURL comments.

Example usage:

  http.Handle("/app_combined.js",
	     concatjs.ServeConcatenatedJS("my/app/web_srcs.MF", ".", [], [], nil))

Relative paths in the manifest are resolved relative to the path given as root.

Types

type FileCache

type FileCache struct {
	// contains filtered or unexported fields
}

FileCache caches a set of files in memory and provides a single method, WriteFiles(), that streams them out in the concatjs format.

func NewFileCache

func NewFileCache(root string, fs FileSystem) *FileCache

NewFileCache constructs a new FileCache. Relative paths in the cache are resolved relative to root. fs injects file system access, and will use the real file system if nil.

func (*FileCache) WriteFiles

func (cache *FileCache) WriteFiles(w io.Writer, files []string) error

WriteFiles updates the cache for a list of files, then streams them into an io.Writer.

type FileSystem

type FileSystem interface {
	// contains filtered or unexported methods
}

FileSystem is the interface to reading files from disk. It's abstracted into an interface to allow tests to replace it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL