Skip to content

Instantly share code, notes, and snippets.

@guybedford
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guybedford/10010537 to your computer and use it in GitHub Desktop.
Save guybedford/10010537 to your computer and use it in GitHub Desktop.
Build Tool

Goals

  1. Support source maps
  2. Plugin-based compilation
  3. Perform compilation in memory, not file system.

Key Innovation: Use source map information to determine which changed files result in which files having to be rebuilt.

Source Maps and this innovation concept is why I'm even considering polluting this noisy space even further!

Proposed Plugin API

plugin.compile = function(files) {
  return files
  .filter(function(file) {
    return file.name.match(/\.coffee$/);
  })
  .map(function(file) {
    // note we allow an input source map for multi-step builds
    var compiled = compile(file.source, file.sourceMap);
    file.source = compiled.source;
    file.sourceMap = compiled.sourceMap;
    return file;
  });
}

Deleting files is not provided as an option. We can only add or modify files as specified in the returned files array.

The tool would then watch the input folder, do a build, and selectively rebuild just what changes, having discovered the build dependencies from the source maps.

External API still being worked out exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment