diff --git a/package.json b/package.json
index 1c55a6eb74..1373432437 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"angular": "1.3.5",
"bower": "^1.3.12",
"broccoli": "^0.15.3",
+ "broccoli-filter": "^0.1.12",
"broccoli-flatten": "^0.1.1",
"broccoli-funnel": "igorminar/broccoli-funnel#perf-files",
"broccoli-lodash": "^0.1.1",
@@ -52,7 +53,6 @@
"broccoli-stew": "^0.2.1",
"broccoli-writer": "^0.1.1",
"canonical-path": "0.0.2",
- "copy-dereference": "^1.0.0",
"css": "mlaval/css#issue65",
"del": "~1",
"dgeni": "^0.4.1",
@@ -95,8 +95,8 @@
"temp": "^0.8.1",
"ternary-stream": "^1.2.3",
"through2": "^0.6.1",
- "typescript": "alexeagle/TypeScript#93dbbe2a2d0b42cefd02ac949e4bc8ab6b5b5823",
"ts2dart": "^0.3.0",
+ "typescript": "alexeagle/TypeScript#93dbbe2a2d0b42cefd02ac949e4bc8ab6b5b5823",
"vinyl": "^0.4.6",
"walk-sync": "^0.1.3",
"xtend": "^4.0.0",
diff --git a/tools/broccoli/broccoli-dest-copy.ts b/tools/broccoli/broccoli-dest-copy.ts
new file mode 100644
index 0000000000..928621120f
--- /dev/null
+++ b/tools/broccoli/broccoli-dest-copy.ts
@@ -0,0 +1,33 @@
+///
+///
+///
+
+import Filter = require('broccoli-filter');
+import fse = require('fs-extra');
+import path = require('path');
+
+/**
+ * Intercepts each file as it is copied to the destination tempdir,
+ * and tees a copy to the given path outside the tmp dir.
+ */
+class DestCopy extends Filter {
+ constructor(private inputTree, private outputRoot: string) { super(inputTree); }
+
+ getDestFilePath(relativePath: string): string { return relativePath; }
+
+ processString(content: string, relativePath: string): string { return content; }
+
+ processFile(srcDir, destDir, relativePath): Promise {
+ return super.processFile(srcDir, destDir, relativePath)
+ .then(x => {
+ var destFile = path.join(this.outputRoot, this.getDestFilePath(relativePath));
+ var dir = path.dirname(destFile);
+ fse.mkdirsSync(dir);
+ fse.copySync(path.join(srcDir, relativePath), destFile);
+ });
+ }
+}
+
+export = function destCopy(inputTree, outputRoot) {
+ return new DestCopy(inputTree, outputRoot);
+}
diff --git a/tools/broccoli/broccoli-filter.d.ts b/tools/broccoli/broccoli-filter.d.ts
new file mode 100644
index 0000000000..6944d24f58
--- /dev/null
+++ b/tools/broccoli/broccoli-filter.d.ts
@@ -0,0 +1,11 @@
+///
+
+
+declare class Filter {
+ constructor(inputTree: any);
+ processString(contents: string, relativePath: string): string;
+ // NB: This function is probably not intended as part of the public API
+ processFile(srcDir: string, destDir: string, relativePath: string): Promise;
+}
+
+export = Filter;
diff --git a/tools/broccoli/gulp/index.ts b/tools/broccoli/gulp/index.ts
index 530d997ffe..b9b5f35e4f 100644
--- a/tools/broccoli/gulp/index.ts
+++ b/tools/broccoli/gulp/index.ts
@@ -1,5 +1,5 @@
var broccoli = require('broccoli');
-var copyDereferenceSync = require('copy-dereference').sync;
+var destCopy = require('../broccoli-dest-copy');
var fse = require('fs-extra');
var path = require('path');
var printSlowTrees = require('broccoli-slow-trees');
@@ -26,31 +26,23 @@ function broccoliBuild(tree, outputRoot) {
// We do a clean build every time to avoid stale outputs.
// Broccoli's cache folders allow it to remain incremental without reading this dir.
fse.removeSync(distPath);
- fse.mkdirsSync(path.join(distPath, '..'));
+
+ tree = destCopy(tree, 'dist');
var builder = new broccoli.Builder(tree);
return builder.build()
- .then(function(hash) {
- console.log('=== Stats for %s (total: %ds) ===', outputRoot,
- Math.round(hash.totalTime / 1000000) / 1000);
- printSlowTrees(hash.graph);
-
- var dir = hash.directory;
- try {
- time('Write build output', function() {
- copyDereferenceSync(path.join(dir, outputRoot), distPath);
- });
- } catch (err) {
- if (err.code === 'EEXIST') err.message += ' (we cannot build into an existing directory)';
- throw err;
- }
- })
- .finally(function() {
- time('Build cleanup', function() { builder.cleanup(); });
-
- console.log('=== Done building %s ===', outputRoot);
- })
- .catch(function(err) {
+ .then(hash =>
+ {
+ console.log('=== Stats for %s (total: %ds) ===', outputRoot,
+ Math.round(hash.totalTime / 1000000) / 1000);
+ printSlowTrees(hash.graph);
+ })
+ .finally(() =>
+ {
+ time('Build cleanup', () => builder.cleanup());
+ console.log('=== Done building %s ===', outputRoot);
+ })
+ .catch(err => {
// Should show file and line/col if present
if (err.file) {
console.error('File: ' + err.file);
diff --git a/tools/broccoli/traceur/index.ts b/tools/broccoli/traceur/index.ts
index 1b2764054c..5015d63719 100644
--- a/tools/broccoli/traceur/index.ts
+++ b/tools/broccoli/traceur/index.ts
@@ -37,7 +37,7 @@ class TraceurFilter extends Writer {
// TODO: we should fix the sourceMappingURL written by Traceur instead of overriding
// (but we might switch to typescript first)
var mapFilepath = filepath.replace(/\.\w+$/, '') + this.destSourceMapExtension;
- result.js = result.js + '\n //# sourceMappingURL=./' + path.basename(mapFilepath);
+ result.js = result.js + '\n//# sourceMappingURL=./' + path.basename(mapFilepath);
var destFilepath = filepath.replace(/\.\w+$/, this.destExtension);
var destFile = path.join(destDir, destFilepath);