Documentation ¶
Overview ¶
This package wrap the npm module regenerator from Facebook to allow more people to use ES6 without having to compile lot's of files every new deploy.
If the user-agent is capable of handling es6 files, then no compilation is made.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct { // Prefix to remove from incoming http request // before searching for files Prefix string // List of directories to search for a given // file. The first match is used Dir []string // Command used to activate NPM // // When empty the env var "WEBVIEW_REGENERATOR" Regenerator string // Default parameters RegeneratorParams []string // Cache for regenerated files Cache CompilerCache // contains filtered or unexported fields }
Compiler is responsible for calling npm
type CompilerCache ¶
CompilerCache links a source file to a regenerated file
func (*CompilerCache) Open ¶
func (cc *CompilerCache) Open(source string) (io.ReadCloser, error)
Open will try to open a regenerated file for the given source file if the mtime from source is after the regenerated, then this will result in a error.
If source isn't found, an error is also returned.
func (*CompilerCache) Store ¶
func (cc *CompilerCache) Store(source, regen string)
Store will link source file to the regenerated one
type Regenerator ¶
type Regenerator struct {
Compiler
}
Regenerator wrap the compiler under the net/http.Handler interface
func (*Regenerator) ServeHTTP ¶
func (r *Regenerator) ServeHTTP(w http.ResponseWriter, req *http.Request)