Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

AOT compile code if asked #7

Merged
merged 29 commits into from
Jul 1, 2015
Merged

AOT compile code if asked #7

merged 29 commits into from
Jul 1, 2015

Conversation

anaisbetts
Copy link
Contributor

This PR allows you to pre-build the cache folder ahead of time for every file in your app, via a new electron-compile CLI app:

Usage: electron-compile --target [target-path] paths...

Options:
  -t, --target   The target directory to write a cache directory to
  -v, --verbose  Print verbose information
  -h, --help     Show help

This PR also adds new methods exported to the main object for compiling via code:

// Public: Compiles a single file given its path.
//
// filePath: The path on disk to the file
// compilers: (optional) - An {Array} of objects conforming to {CompileCache}
//                         that will be tried in-order to compile code. You must
//                         call init() first if this parameter is null.
//
// Returns a {String} with the compiled output, or will throw an {Error} 
// representing the compiler errors encountered.
export function compile(filePath, compilers=null)

// Public: Recursively compiles an entire directory of files.
//
// rootDirectory: The path on disk to the directory of files to compile.
// compilers: (optional) - An {Array} of objects conforming to {CompileCache}
//                         that will be tried in-order to compile code.
//
// Returns nothing.
export function compileAll(rootDirectory, compilers=null)

// Public: Allows you to create new instances of all compilers that are 
// supported by electron-compile and use them directly. Currently supports
// Babel, CoffeeScript, TypeScript, LESS, and Sass/SCSS.
//
// Returns an {Array} of {CompileCache} objects.
export function createAllCompilers()

One Last Thing

This PR also fixes a semi-related bug where require in the renderer process wouldn't get transpiled files.

@anaisbetts anaisbetts changed the title Precompile AOT compile code if asked Jul 1, 2015
anaisbetts added a commit that referenced this pull request Jul 1, 2015
@anaisbetts anaisbetts merged commit f342576 into master Jul 1, 2015
@anaisbetts anaisbetts deleted the precompile branch July 1, 2015 00:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant