revert: refactor: use a custom replacement build step instead of broccoli-replace
This reverts commit d5c528ac2b
.
This commit is contained in:
parent
a418397174
commit
72736a1b09
|
@ -1374,6 +1374,87 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"broccoli-replace": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "git://github.com/alexeagle/broccoli-replace.git#cd39a543b17b40db765a07762f099fbc85518290",
|
||||
"dependencies": {
|
||||
"minimatch": {
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"lru-cache": {
|
||||
"version": "2.6.2"
|
||||
},
|
||||
"sigmund": {
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"applause": {
|
||||
"version": "0.3.4",
|
||||
"dependencies": {
|
||||
"cson": {
|
||||
"version": "1.6.2",
|
||||
"dependencies": {
|
||||
"ambi": {
|
||||
"version": "2.2.0",
|
||||
"dependencies": {
|
||||
"typechecker": {
|
||||
"version": "2.0.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"coffee-script": {
|
||||
"version": "1.8.0",
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.3.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-opts": {
|
||||
"version": "2.2.0",
|
||||
"dependencies": {
|
||||
"typechecker": {
|
||||
"version": "2.0.8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"js2coffee": {
|
||||
"version": "0.3.5",
|
||||
"dependencies": {
|
||||
"coffee-script": {
|
||||
"version": "1.7.1",
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.3.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"file": {
|
||||
"version": "0.2.2"
|
||||
},
|
||||
"nopt": {
|
||||
"version": "3.0.1",
|
||||
"dependencies": {
|
||||
"abbrev": {
|
||||
"version": "1.0.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.6.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requirefresh": {
|
||||
"version": "1.1.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"broccoli-slow-trees": {
|
||||
"version": "1.1.0"
|
||||
},
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -48,6 +48,7 @@
|
|||
"broccoli-funnel": "igorminar/broccoli-funnel#perf-files",
|
||||
"broccoli-lodash": "^0.1.1",
|
||||
"broccoli-merge-trees": "^0.2.1",
|
||||
"broccoli-replace": "alexeagle/broccoli-replace#angular_patch",
|
||||
"broccoli-slow-trees": "^1.1.0",
|
||||
"broccoli-stew": "^0.2.1",
|
||||
"broccoli-writer": "^0.1.1",
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
import fs = require('fs');
|
||||
import fse = require('fs-extra');
|
||||
import path = require('path');
|
||||
import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';
|
||||
|
||||
var minimatch = require('minimatch');
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var FILE_ENCODING = {encoding: 'utf-8'};
|
||||
|
||||
/**
|
||||
* Intercepts each changed file and replaces its contents with
|
||||
* the associated changes.
|
||||
*/
|
||||
class DiffingReplace implements DiffingBroccoliPlugin {
|
||||
constructor(private inputPath, private cachePath, private options) {}
|
||||
|
||||
rebuild(treeDiff: DiffResult) {
|
||||
var patterns = this.options.patterns;
|
||||
var files = this.options.files;
|
||||
|
||||
treeDiff.changedPaths.forEach((changedFilePath) => {
|
||||
var sourceFilePath = path.join(this.inputPath, changedFilePath)
|
||||
var destFilePath = path.join(this.cachePath, changedFilePath);
|
||||
var destDirPath = path.dirname(destFilePath);
|
||||
|
||||
if (!fs.existsSync(destDirPath)) {
|
||||
fse.mkdirpSync(destDirPath);
|
||||
}
|
||||
|
||||
var fileMatches = files.some((filePath) => minimatch(changedFilePath, filePath));
|
||||
if (fileMatches) {
|
||||
var content = fs.readFileSync(sourceFilePath, FILE_ENCODING);
|
||||
patterns.forEach((pattern) => {
|
||||
var replacement = pattern.replacement;
|
||||
if (typeof replacement === 'function') {
|
||||
replacement = function(content) {
|
||||
return pattern.replacement(content, changedFilePath);
|
||||
};
|
||||
}
|
||||
content = content.replace(pattern.match, replacement);
|
||||
});
|
||||
fs.writeFileSync(destFilePath, content, FILE_ENCODING);
|
||||
} else {
|
||||
fs.symlinkSync(sourceFilePath, destFilePath);
|
||||
}
|
||||
});
|
||||
|
||||
treeDiff.removedPaths.forEach((removedFilePath) => {
|
||||
var destFilePath = path.join(this.cachePath, removedFilePath);
|
||||
fs.unlinkSync(destFilePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default wrapDiffingPlugin(DiffingReplace);
|
|
@ -5,12 +5,12 @@ var flatten = require('broccoli-flatten');
|
|||
var htmlReplace = require('../html-replace');
|
||||
import mergeTrees from '../broccoli-merge-trees';
|
||||
var path = require('path');
|
||||
var replace = require('broccoli-replace');
|
||||
var stew = require('broccoli-stew');
|
||||
|
||||
import compileWithTypescript from '../broccoli-typescript';
|
||||
import destCopy from '../broccoli-dest-copy';
|
||||
import {default as transpileWithTraceur, TRACEUR_RUNTIME_PATH} from '../traceur/index';
|
||||
import replace from '../broccoli-replace';
|
||||
|
||||
|
||||
var projectRootDir = path.normalize(path.join(__dirname, '..', '..', '..', '..'));
|
||||
|
@ -146,36 +146,25 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
|||
return funnels;
|
||||
}
|
||||
|
||||
var scriptPathPatternReplacement = {
|
||||
match: '@@FILENAME_NO_EXT',
|
||||
replacement: function(replacement, relativePath) {
|
||||
return relativePath.replace(/\.\w+$/, '');
|
||||
}
|
||||
};
|
||||
function writeScriptsForPath(relativePath, result) {
|
||||
return result.replace('@@FILENAME_NO_EXT', relativePath.replace(/\.\w+$/, ''));
|
||||
}
|
||||
|
||||
var htmlTree = new Funnel(modulesTree, {include: ['*/src/**/*.html'], destDir: '/'});
|
||||
htmlTree = replace(htmlTree, {
|
||||
files: ['examples*/**'],
|
||||
patterns: [
|
||||
{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')},
|
||||
scriptPathPatternReplacement
|
||||
]
|
||||
patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}],
|
||||
replaceWithPath: writeScriptsForPath
|
||||
});
|
||||
|
||||
htmlTree = replace(htmlTree, {
|
||||
files: ['benchmarks/**'],
|
||||
patterns: [
|
||||
{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')},
|
||||
scriptPathPatternReplacement
|
||||
]
|
||||
patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}],
|
||||
replaceWithPath: writeScriptsForPath
|
||||
});
|
||||
|
||||
htmlTree = replace(htmlTree, {
|
||||
files: ['benchmarks_external/**'],
|
||||
patterns: [
|
||||
{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')},
|
||||
scriptPathPatternReplacement
|
||||
]
|
||||
patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}],
|
||||
replaceWithPath: writeScriptsForPath
|
||||
});
|
||||
|
||||
var scripts = mergeTrees(servingTrees);
|
||||
|
|
|
@ -9,10 +9,10 @@ var glob = require('glob');
|
|||
import mergeTrees from '../broccoli-merge-trees';
|
||||
var path = require('path');
|
||||
var renderLodashTemplate = require('broccoli-lodash');
|
||||
var replace = require('broccoli-replace');
|
||||
var stew = require('broccoli-stew');
|
||||
import ts2dart from '../broccoli-ts2dart';
|
||||
import dartfmt from '../broccoli-dartfmt';
|
||||
import replace from '../broccoli-replace';
|
||||
|
||||
/**
|
||||
* A funnel starting at modules, including the given filters, and moving into the root.
|
||||
|
|
|
@ -7,7 +7,7 @@ var Funnel = require('broccoli-funnel');
|
|||
import mergeTrees from '../broccoli-merge-trees';
|
||||
var path = require('path');
|
||||
var renderLodashTemplate = require('broccoli-lodash');
|
||||
import replace from '../broccoli-replace';
|
||||
var replace = require('broccoli-replace');
|
||||
var stew = require('broccoli-stew');
|
||||
|
||||
var projectRootDir = path.normalize(path.join(__dirname, '..', '..', '..', '..'));
|
||||
|
@ -84,16 +84,19 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||
// TODO: remove this when we no longer use traceur
|
||||
var traceurCompatibleTsModulesTree = replace(modulesTree, {
|
||||
files: ['**/*.ts'],
|
||||
patterns: [{
|
||||
match: /$/,
|
||||
replacement: function(_, relativePath) {
|
||||
var content = ""; //we're matching an empty line
|
||||
if (!relativePath.endsWith('.d.ts')) {
|
||||
content += '\r\nexport var __esModule = true;\n';
|
||||
}
|
||||
return content;
|
||||
patterns: [
|
||||
{
|
||||
// Empty replacement needed so that replaceWithPath gets triggered...
|
||||
match: /$/g,
|
||||
replacement: ""
|
||||
}
|
||||
}]
|
||||
],
|
||||
replaceWithPath: function(path, content) {
|
||||
if (!path.endsWith('.d.ts')) {
|
||||
content += '\r\nexport var __esModule = true;\n';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
});
|
||||
|
||||
var typescriptTree = compileWithTypescript(traceurCompatibleTsModulesTree, {
|
||||
|
|
Loading…
Reference in New Issue