chore(package.json): upgrade traceur to v0.0.87
Fix in source-map test to follow through the sourcemap chain.
This commit is contained in:
parent
d304f41197
commit
9d21a6f40d
|
@ -34,13 +34,18 @@ module.exports = function atParser(AttachCommentTreeVisitor, SourceFile, Traceur
|
|||
var sourceFile = new SourceFile(moduleName, fileInfo.content);
|
||||
var comments = [];
|
||||
var moduleTree;
|
||||
var parser = new TraceurParser(sourceFile);
|
||||
var errorReporter = {
|
||||
reportError: function(position, message) {
|
||||
}
|
||||
};
|
||||
|
||||
traceurOptions.setFromObject(service.traceurOptions);
|
||||
var parser = new TraceurParser(sourceFile, errorReporter, traceurOptions);
|
||||
|
||||
// Configure the parser
|
||||
parser.handleComment = function(range) {
|
||||
comments.push({ range: range });
|
||||
};
|
||||
traceurOptions.setFromObject(service.traceurOptions);
|
||||
|
||||
try {
|
||||
// Parse the file as a module, attaching the comments
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = function traceurOptions() {
|
||||
return System.get(System.map.traceur + '/src/Options.js').options;
|
||||
var Options = System.get(System.map.traceur + "/src/Options.js").Options;
|
||||
return new Options();
|
||||
};
|
|
@ -717,13 +717,13 @@ export class Decorator extends Directive {
|
|||
compileChildren:boolean
|
||||
}={})
|
||||
{
|
||||
this.compileChildren = compileChildren;
|
||||
super({
|
||||
selector: selector,
|
||||
bind: bind,
|
||||
events: events,
|
||||
lifecycle: lifecycle
|
||||
});
|
||||
this.compileChildren = compileChildren;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
|||
export class For {
|
||||
viewContainer: ViewContainer;
|
||||
constructor(viewContainer:ViewContainer) {
|
||||
super();
|
||||
this.viewContainer = viewContainer;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ export class DefaultValueAccessor {
|
|||
onChange:Function;
|
||||
|
||||
constructor(@PropertySetter('value') setValueProperty:Function) {
|
||||
super();
|
||||
this._setValueProperty = setValueProperty;
|
||||
this.onChange = (_) => {};
|
||||
}
|
||||
|
@ -44,7 +43,6 @@ export class CheckboxControlValueAccessor {
|
|||
onChange:Function;
|
||||
|
||||
constructor(cd:ControlDirective, @PropertySetter('checked') setCheckedProperty:Function) {
|
||||
super();
|
||||
this._setCheckedProperty = setCheckedProperty;
|
||||
this.onChange = (_) => {};
|
||||
cd.valueAccessor = this; //ControlDirective should inject CheckboxControlDirective
|
||||
|
@ -126,7 +124,6 @@ export class ControlGroupDirective {
|
|||
_directives:List<ControlDirective>;
|
||||
|
||||
constructor(@Optional() @Ancestor() groupDirective:ControlGroupDirective) {
|
||||
super();
|
||||
this._groupDirective = groupDirective;
|
||||
this._directives = ListWrapper.create();
|
||||
}
|
||||
|
|
|
@ -228,4 +228,4 @@ export class ControlArray extends AbstractControl {
|
|||
this._errors = this.validator(this);
|
||||
this._status = isPresent(this._errors) ? INVALID : VALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -415,7 +415,6 @@ class WrappedValue {
|
|||
onChange:Function;
|
||||
|
||||
constructor(cd:ControlDirective, @PropertySetter('value') setProperty:Function) {
|
||||
super();
|
||||
this._setProperty = setProperty;
|
||||
cd.valueAccessor = this;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ describe('sourcemaps', function () {
|
|||
expect(errorLine).not.toBeNull();
|
||||
expect(errorColumn).not.toBeNull();
|
||||
|
||||
|
||||
var sourceMapData = fs.readFileSync(
|
||||
'dist/js/prod/es5/examples/src/sourcemap/index.js.map');
|
||||
var decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData));
|
||||
|
@ -32,9 +33,15 @@ describe('sourcemaps', function () {
|
|||
column: errorColumn
|
||||
});
|
||||
|
||||
var finalMapData = fs.readFileSync(
|
||||
'dist/js/prod/es6/examples/src/sourcemap/index.map');
|
||||
var finalDecoder = new sourceMap.SourceMapConsumer(JSON.parse(finalMapData));
|
||||
|
||||
var finalPosition = finalDecoder.originalPositionFor(originalPosition);
|
||||
|
||||
var sourceCodeLines = fs.readFileSync('modules/examples/src/sourcemap/index.js',
|
||||
{encoding: 'UTF-8'}).split('\n');
|
||||
expect(sourceCodeLines[originalPosition.line - 1])
|
||||
expect(sourceCodeLines[finalPosition.line - 1])
|
||||
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
"dependencies": {
|
||||
"es6-module-loader": "^0.9.2",
|
||||
"systemjs": "^0.9.1",
|
||||
"traceur": "0.0.82",
|
||||
"rx": "2.4.6",
|
||||
"traceur": "0.0.87",
|
||||
"which": "~1",
|
||||
"zone.js": "0.4.0",
|
||||
"googleapis": "1.0.x",
|
||||
|
@ -54,7 +54,7 @@
|
|||
"gulp-shell": "^0.2.10",
|
||||
"gulp-sourcemaps": "1.3.*",
|
||||
"gulp-template": "^3.0.0",
|
||||
"gulp-traceur": "0.16.*",
|
||||
"gulp-traceur": "0.17.*",
|
||||
"gulp-ts2dart": "^1.0.0",
|
||||
"gulp-webserver": "^0.8.7",
|
||||
"js-yaml": "^3.2.7",
|
||||
|
|
|
@ -40,12 +40,9 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
|
|||
moduleName = moduleName || inputPath;
|
||||
moduleName = moduleName.replace(/\.\w*$/, '');
|
||||
|
||||
var localOptions = extend(options, {
|
||||
moduleName: moduleName
|
||||
});
|
||||
var CompilerCls = System.get('transpiler/src/compiler').Compiler;
|
||||
|
||||
var compiler = new CompilerCls(localOptions);
|
||||
var compiler = new CompilerCls(options, moduleName);
|
||||
var result = {
|
||||
js: compiler.compile(source, inputPath, outputPath),
|
||||
sourceMap: null
|
||||
|
@ -56,7 +53,7 @@ exports.compile = function compile(options, paths, source, reloadTraceur) {
|
|||
result.sourceMap = JSON.parse(sourceMapString);
|
||||
}
|
||||
|
||||
if (localOptions.outputLanguage === 'es6' && source.indexOf('$traceurRuntime') === -1) {
|
||||
if (options.outputLanguage === 'es6' && source.indexOf('$traceurRuntime') === -1) {
|
||||
assert(result.js.indexOf('$traceurRuntime') === -1,
|
||||
'Transpile to ES6 must not add references to $traceurRuntime, '
|
||||
+ inputPath + ' is transpiled to:\n' + result.js);
|
||||
|
@ -94,7 +91,6 @@ function reloadCompiler(reloadTraceur) {
|
|||
useRttsAssertModuleForConvertingTypesToExpressions();
|
||||
supportSuperCallsInEs6Patch();
|
||||
convertTypesToExpressionsInEs6Patch();
|
||||
removeNonStaticFieldDeclarationsInEs6Patch();
|
||||
disableGetterSetterAssertionPatch();
|
||||
patchCommonJSModuleTransformerToSupportExportStar();
|
||||
}
|
||||
|
@ -111,9 +107,7 @@ function loadModule(filepath, transpile) {
|
|||
.replace(__dirname, 'transpiler')
|
||||
.replace(/\\/g, '/')
|
||||
.replace(/\.\w*$/, '');
|
||||
data = (new traceur.NodeCompiler(
|
||||
extend(SELF_COMPILE_OPTIONS, { moduleName: moduleName } )
|
||||
)).compile(data, filepath, filepath);
|
||||
data = traceur.compile(data, SELF_COMPILE_OPTIONS, moduleName);
|
||||
}
|
||||
|
||||
('global', eval)(data);
|
||||
|
@ -157,30 +151,15 @@ function convertTypesToExpressionsInEs6Patch() {
|
|||
PureES6Transformer.prototype.transform = function() {
|
||||
if (!this._patched) {
|
||||
this._patched = true;
|
||||
var self = this;
|
||||
this.treeTransformers_.splice(0,0, function(tree) {
|
||||
return new TypeToExpressionTransformer(new UniqueIdentifierGenerator(), this.reporter_).transformAny(tree);
|
||||
return new TypeToExpressionTransformer(new UniqueIdentifierGenerator(), self.reporter_, self.options_).transformAny(tree);
|
||||
});
|
||||
}
|
||||
return _transform.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO(tbosch): Don't write field declarations in classes when we output to ES6.
|
||||
// This just patches the writer and does not support moving initializers to the constructor.
|
||||
// See src/codegeneration/ClassTransformer.js for how to support initializers as well.
|
||||
// see https://github.com/google/traceur-compiler/issues/1708
|
||||
function removeNonStaticFieldDeclarationsInEs6Patch() {
|
||||
var traceurVersion = System.map['traceur'];
|
||||
var ParseTreeWriter = System.get(traceurVersion+'/src/outputgeneration/ParseTreeWriter').ParseTreeWriter;
|
||||
var options = System.get(traceurVersion + "/src/Options.js").options;
|
||||
var _visitPropertyVariableDeclaration = ParseTreeWriter.prototype.visitPropertyVariableDeclaration;
|
||||
ParseTreeWriter.prototype.visitPropertyVariableDeclaration = function() {
|
||||
if (options.outputLanguage !== 'es6') {
|
||||
return _visitPropertyVariableDeclaration.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// TODO(tbosch): Disable getter/setters for assertions until traceur has a flag
|
||||
// that allows to disable them while keeping assertions and member fields enabled.
|
||||
// see https://github.com/google/traceur-compiler/issues/1625
|
||||
|
|
|
@ -19,8 +19,8 @@ class SubFoo extends Foo {
|
|||
c;
|
||||
|
||||
constructor(a, b) {
|
||||
this.c = 3;
|
||||
super(a, b);
|
||||
this.c = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import {
|
|||
*/
|
||||
export class ClassTransformer extends ParseTreeTransformer {
|
||||
constructor(idGenerator, reporter) {
|
||||
super(idGenerator);
|
||||
this.reporter_ = reporter;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@ import {DestructuringTransformer} from './DestructuringTransformer';
|
|||
* Transforms ES6 + annotations to Dart code.
|
||||
*/
|
||||
export class DartTransformer extends MultiTransformer {
|
||||
constructor(reporter, idGenerator = new UniqueIdentifierGenerator()) {
|
||||
constructor(reporter, options) {
|
||||
super(reporter, options.validate);
|
||||
let idGenerator = new UniqueIdentifierGenerator();
|
||||
|
||||
var append = (transformer) => {
|
||||
this.append((tree) => {
|
||||
|
|
|
@ -51,6 +51,7 @@ function getIndexOfFirstNonImportStatement(items) {
|
|||
*/
|
||||
export class ExportTransformer extends ParseTreeTransformer {
|
||||
constructor(idGenerator, reporter) {
|
||||
super(idGenerator);
|
||||
this.reporter_ = reporter;
|
||||
this.importedVars_ = null;
|
||||
this.collectedExports_ = null;
|
||||
|
|
|
@ -4,20 +4,19 @@ import {DartParseTreeWriter} from './outputgeneration/DartParseTreeWriter';
|
|||
import {CollectingErrorReporter} from 'traceur/src/util/CollectingErrorReporter';
|
||||
import {Parser} from './parser';
|
||||
import {SourceFile} from 'traceur/src/syntax/SourceFile';
|
||||
import {
|
||||
options as traceurOptions
|
||||
} from 'traceur/src/Options';
|
||||
import {Options} from 'traceur/src/Options';
|
||||
|
||||
export class Compiler extends TraceurCompiler {
|
||||
|
||||
constructor(options, sourceRoot) {
|
||||
super(options, sourceRoot);
|
||||
this.moduleName_ = sourceRoot;
|
||||
}
|
||||
|
||||
transform(tree, moduleName = undefined) {
|
||||
if (this.options_.outputLanguage.toLowerCase() === 'dart') {
|
||||
var errorReporter = new CollectingErrorReporter();
|
||||
var transformer = new DartTransformer(errorReporter);
|
||||
var transformer = new DartTransformer(errorReporter, this.options_);
|
||||
var transformedTree = transformer.transform(tree);
|
||||
this.throwIfErrors(errorReporter);
|
||||
return transformedTree;
|
||||
|
@ -28,7 +27,7 @@ export class Compiler extends TraceurCompiler {
|
|||
|
||||
write(tree, outputName = undefined, sourceRoot = undefined) {
|
||||
if (this.options_.outputLanguage.toLowerCase() === 'dart') {
|
||||
var writer = new DartParseTreeWriter(this.options_.moduleName, outputName);
|
||||
var writer = new DartParseTreeWriter(this.moduleName_, outputName);
|
||||
writer.visitAny(tree);
|
||||
return writer.toString();
|
||||
} else {
|
||||
|
@ -45,13 +44,14 @@ export class Compiler extends TraceurCompiler {
|
|||
}
|
||||
|
||||
this.sourceMapGenerator_ = null;
|
||||
var traceurOptions = new Options();
|
||||
// Here we mutate the global/module options object to be used in parsing.
|
||||
traceurOptions.setFromObject(this.options_);
|
||||
|
||||
var errorReporter = new CollectingErrorReporter();
|
||||
sourceName = this.sourceName(sourceName);
|
||||
var sourceFile = new SourceFile(sourceName, content);
|
||||
var parser = new Parser(sourceFile, errorReporter);
|
||||
var parser = new Parser(sourceFile, errorReporter, this.options_);
|
||||
var tree =
|
||||
this.options_.script ? parser.parseScript() : parser.parseModule();
|
||||
this.throwIfErrors(errorReporter);
|
||||
|
|
|
@ -4,8 +4,8 @@ import {TypeName, ImportSpecifier, ImportedBinding, BindingIdentifier} from 'tra
|
|||
import {PERIOD, IMPORT, STAR, AS, FROM, CLOSE_ANGLE, OPEN_ANGLE, COMMA, OPEN_CURLY, CLOSE_CURLY, COLON} from 'traceur/src/syntax/TokenType';
|
||||
|
||||
export class Parser extends TraceurParser {
|
||||
constructor(file, errorReporter = new SyntaxErrorReporter()) {
|
||||
super(file, errorReporter);
|
||||
constructor(file, errorReporter = new SyntaxErrorReporter(), options) {
|
||||
super(file, errorReporter, options);
|
||||
}
|
||||
|
||||
// TODO: add support for object type literals to traceur!
|
||||
|
|
|
@ -16,6 +16,10 @@ import {
|
|||
} from 'traceur/src/codegeneration/PlaceholderParser.js';
|
||||
|
||||
export class TypeToExpressionTransformer extends ParseTreeTransformer {
|
||||
constructor(idGenerator, reporter, options) {
|
||||
super(idGenerator, reporter);
|
||||
this.options_ = options;
|
||||
}
|
||||
|
||||
transformTypeName(tree) {
|
||||
if (tree.moduleName) {
|
||||
|
|
|
@ -63,7 +63,7 @@ export class NamedParameterList extends ParseTree {
|
|||
* @param {Array.<ParseTree>} parameterNameAndValues
|
||||
*/
|
||||
constructor(location, parameterNameAndValues) {
|
||||
this.location = location;
|
||||
super(location);
|
||||
this.parameterNameAndValues = parameterNameAndValues;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ export class ObjectPatternBindingElement extends ParseTree {
|
|||
* @param {ParseTree} initializer
|
||||
*/
|
||||
constructor(location, binding, initializer) {
|
||||
this.location = location;
|
||||
super(location);
|
||||
this.binding = binding;
|
||||
this.initializer = initializer;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ export class ImplementsDeclaration extends ParseTree {
|
|||
* @param {Array.<ParseTree>} interfaces
|
||||
*/
|
||||
constructor(location, interfaces) {
|
||||
this.location = location;
|
||||
super(location);
|
||||
this.interfaces = interfaces;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,15 +111,17 @@ describe('transpile to es6', function() {
|
|||
it('should allow super() calls when transpiling to ES6 with source maps', function() {
|
||||
options = merge(options, {sourceMaps: true});
|
||||
var result = compiler.compile(options, "test.js",
|
||||
"class Test {" +
|
||||
"class Base {}\n" +
|
||||
"class Test extends Base {" +
|
||||
" constructor() { super(); }" +
|
||||
"}");
|
||||
expect(result.js).toBe("class Test {\n" +
|
||||
expect(result.js).toBe("class Base {}\n" +
|
||||
"class Test extends Base {\n" +
|
||||
" constructor() {\n"+
|
||||
" super();\n"+
|
||||
" }\n"+
|
||||
"}\n\n"+
|
||||
"//# sourceMappingURL=test.map\n");
|
||||
"}\n"+
|
||||
"//# sourceMappingURL=test.js.map\n");
|
||||
});
|
||||
|
||||
it('should convert types to expressions', function() {
|
||||
|
|
Loading…
Reference in New Issue