fivetanley / ember-cli-migrator

migrate your files to the standard ember-cli structure, preserving git history
MIT License
106 stars 22 forks source link

Error during recast #69

Closed sly7-7 closed 6 years ago

sly7-7 commented 9 years ago

I make an attempt of migrating the frontend part of my rails app to ember-cli. I encounter this error after the files were copied in the target directory.

v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:1097
                var afterEnd = lines.skipSpaces(trueLoc.end);
                                     ^
TypeError: undefined is not a function
    at .nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:1097:38
    at Array.forEach (native)
    at printStatementSequence (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:1055:14)
    at .nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:399:20
    at FastPath.call (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/fast-path.js:119:18)
    at genericPrintNoParens (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:398:26)
    at genericPrint (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:146:33)
    at printRootGenerically (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:94:16)
    at maybeReprint (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:88:16)
    at print (.nvm/versions/node/v0.12.1/lib/node_modules/ember-cli-migrator/node_modules/recast/lib/printer.js:81:16)

I don't know where to start with to debug, all ideas are welcome :)

igorT commented 9 years ago

Does a specific file trigger it? Can you extend your stacktrace so we can se where from the migrator code it comes from?

sly7-7 commented 9 years ago

I can"t see which file trigger that, the problem is that it's the whole stack :( Is there an option to make the thing more verbose ? Or maybe can I put some debugging trace anywhere ?

igorT commented 9 years ago

You can set how many lines the stack is, by saying Error.StackTraceLimit = 1000 for example. It's 20 by default in v8

jgadbois commented 9 years ago

I'm getting this same error - did you figure it out @sly7-7

sly7-7 commented 9 years ago

@jgadbois Unfortunately not. Though I will likely try again soon since I have to continue the migration. I will let you know if I find something.

jgadbois commented 9 years ago

I upgraded to latest version of recast in the migrator and that didn't help.

jgadbois commented 9 years ago

@igorT any suggestions? I added Error.StackTraceLimit = 1000 in the ember-cli-migrator binary and also in the specific file starting the stack trace and still got the short stack trace.

jgadbois commented 9 years ago

It's Error.stackTraceLimit

Here's the part of the stack trace coming directly from the migrator:

    at Object.print (/usr/local/lib/node_modules/ember-cli-migrator/node_modules/recast/main.js:6:33)
    at /usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:370:73
    at Array.map (native)
    at EmberMigrator.convertFile (/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:370:38)
    at EmberMigrator.processFile (/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:341:36)
    at /usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:172:10
    at Array.forEach (native)
    at EmberMigrator_run [as run] (/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:171:32)
    at Object.<anonymous> (/usr/local/lib/node_modules/ember-cli-migrator/bin/ember-cli-migrator:36:10)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
jgadbois commented 9 years ago

@sly7-7 I was able to fix by removing all the Sprockets import comments.

sly7-7 commented 9 years ago

@jgadbois Thanks for the tip, really usefull :+1: @fivetanley Do you think ember-cli-migrator should take care of sprockets require directives ?

fivetanley commented 9 years ago

It seems odd that sprockets directives would blow it up as they are just JavaScript comments. Unless there's erb?

Sent from Outlook

On Tue, Sep 15, 2015 at 11:47 PM -0700, "Sylvain MINA" notifications@github.com wrote:

@jgadbois Thanks for the tip, really usefull

@fivetanley Do you think ember-cli-migrator should take care of sprockets require directives ?

— Reply to this email directly or view it on GitHub.

jgadbois commented 9 years ago

I think the only other change I made in my file was changing something like

var app = WT = Ember.Application... to var app = Ember.Application...

I'm just about positive it was this file that was having problems.

sly7-7 commented 9 years ago

@jgadbois I was finally able to find out what lines cause ember-cli-migrator to blow up:

// Ember.ArrayProxy.prototype.flatten = Array.prototype.flatten = function() { // var r = []; // this.forEach(function(el) { // r.push.apply(r, Ember.isArray(el) ? el.flatten() : [el]); // }); // return r; // };

Seems like having a double assignment in a line is bad.

jgadbois commented 9 years ago

Ok so it wasn't the directives then it was the double assignment which I had also.