Skip to content

Commit

Permalink
compatibility for es6 and lively acorn jsx / babel update
Browse files Browse the repository at this point in the history
  • Loading branch information
rksm committed May 28, 2015
1 parent 7bb382e commit 75fa2c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 6 additions & 4 deletions VersionedFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ util._extend(VersionedFileSystem.prototype, d.bindMethods({
for (idx = 0; idx <= maxIdx; idx++) {
var origNode = acorn.walk.findNodeByAstIndex(origAst, idx, false);
var rewrittenNode = acorn.walk.findNodeByAstIndex(rewrittenAst, idx, false);
if (origNode == null || rewrittenNode == null)
throw new Error('Could not find AST index ' + idx + ' in given ASTs!');
if (origNode == null || rewrittenNode == null) {
console.warn('Could not find AST index %s in given ASTs for file %s when generating source map', idx, origFile);
continue;
}
generator.addMapping({
original: { line: origNode.loc.start.line, column: origNode.loc.start.column },
generated: { line: rewrittenNode.loc.start.line, column: rewrittenNode.loc.start.column },
Expand All @@ -167,7 +169,7 @@ util._extend(VersionedFileSystem.prototype, d.bindMethods({
if (err) throw err;
var astId = (result.length == 1 ? result[0].lastId : 0);
this.astRegistry[record.path] = Array(astId);
var ast = lively.ast.acorn.parse(record.content, { locations: true, directSourceFile: record.path }),
var ast = lively.ast.parse(record.content, {locations: true, directSourceFile: record.path}),
rewrittenAst = lively.ast.Rewriting.rewrite(ast, this.astRegistry, record.path),
rewrittenCode = escodegen.generate(rewrittenAst);
record.rewritten = '(function() {\n' + rewrittenCode + '\n' + declarationForGlobals(rewrittenAst) + '\n})();';
Expand All @@ -187,7 +189,7 @@ util._extend(VersionedFileSystem.prototype, d.bindMethods({
else
return value;
}).replace(/\{"regexp":("\/.*?\/[gimy]*")\}/g, 'eval($1)');
lively.ast.acorn.rematchAstWithSource(rewrittenAst.body[0], record.rewritten, true, 'body.0.expression.callee.body.body.0');
acorn.rematchAstWithSource(rewrittenAst.body[0], record.rewritten, true, 'body.0.expression.callee.body.body.0');
// TODO: make lively.ast.SourceMap.Generator.mapForASTs work?!
record.sourceMap = mapForASTs(ast, rewrittenAst, path.basename(record.path));
console.log('Done rewriting ' + record.path + '...');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lively-davfs",
"version": "0.3.4",
"version": "0.4.0",
"description": "Manager for versioning and reading / writing resources.",
"main": "request-handler.js",
"repository": {
Expand Down Expand Up @@ -28,7 +28,7 @@
"async": "~0.9",
"sqlite3": "~3.0.5",
"concat-stream": "~1.0",
"source-map": ">=0.1.31",
"source-map": "^0.4.2",
"lively-loader": ">=0.2.2"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ util._extend(Repository.prototype, d.bindMethods({
this.pendingChangeQueue = [];
this.fs.once('initialized', function() { this.emit('initialized'); }.bind(this));
this._commitPendingChangesWatcherTimer = setInterval(this.commitPendingChangesWatcher.bind(this), 1000);
Object.freeze(this);
},

start: function(resetDatabase, thenDo) {
Expand Down

0 comments on commit 75fa2c2

Please sign in to comment.