Best approach to upgrade JS project to RC.0

I have JS project. I started it a while ago and have quite a lot of code by now. Up until now it wasn’t a problem to upgrade it from one Ionic2 beta to another. But now I’m trying to upgrade it to RC.0 and having problems that seems to be related to the fact that it’s JS project and not TS.

I tried to use both approaches (Copying files to a New Project and Creating New Project) and in both cases I end up with the same error:

bundle dev failed:  Unexpected character '@' (10:0) in /home/git/myapp/src/pages/home/home.js

[13:42:09]  SyntaxError: Unexpected character '@' (10:0) in /home/git/myapp/src/pages/home/home.js
    at Parser.pp$4.raise (/home/git/myapp/node_modules/rollup/dist/rollup.js:4070:13)
    at Parser.pp$7.getTokenFromCode (/home/git/myapp/node_modules/rollup/dist/rollup.js:4609:8)
    at Parser.pp$7.readToken (/home/git/myapp/node_modules/rollup/dist/rollup.js:4330:15)
    at Parser.pp$7.nextToken (/home/git/myapp/node_modules/rollup/dist/rollup.js:4321:13)
    at Parser.pp$7.next (/home/git/myapp/node_modules/rollup/dist/rollup.js:4266:8)
    at Parser.pp.eat (/home/git/myapp/node_modules/rollup/dist/rollup.js:2200:10)
    at Parser.pp.semicolon (/home/git/myapp/node_modules/rollup/dist/rollup.js:2245:13)
    at Parser.pp$1.parseImport (/home/git/myapp/node_modules/rollup/dist/rollup.js:2996:8)
    at Parser.pp$1.parseStatement (/home/git/myapp/node_modules/rollup/dist/rollup.js:2409:44)
    at Parser.pp$1.parseTopLevel (/home/git/myapp/node_modules/rollup/dist/rollup.js:2313:23)

What is the best way to upgrade JS project to RC.0? Should I transfer all my code to TS (I’d prefere not to do it at this point of my project) or is there other way?

Thanks!

I am facing the exact same issue. This happens for files that are loaded through sub-NgModules for me.

So I have the main module that loads “subModule1”. In that submodule I have a component that is declared and exported in the submodule1. The error happens on that file. If I use the same file directly to the main module, everything works.

In my case, I think it happens because my project was in JS. If I switch to TS this error disappears. Apparently, it’s not so hard to switch to JS: you should just rename all js file to ts files. Since JS is subset of TS, it works fine. You might have couple of syntax errors, but not something major. And of cause, you won’t be using all TS functionality at this point. But, I guess, you can deal with this later.

I am using typescript from day one, so I do not think this is related to that. Don’t know why it works for you when switching to ts

[21:21:05]  bundle dev failed:  Unexpected character '@' (3:0) in /projectpath/.tmp/app/tmp/temp.page.ts

[21:21:05]  SyntaxError: Unexpected character '@' (3:0) in /projectpath/.tmp/app/tmp/temp.page.ts
    at Parser.pp$4.raise (/projectpath/node_modules/rollup/dist/rollup.js:4070:13)
    at Parser.pp$7.getTokenFromCode (/projectpath/node_modules/rollup/dist/rollup.js:4609:8)
    at Parser.pp$7.readToken (/projectpath/node_modules/rollup/dist/rollup.js:4330:15)
    at Parser.pp$7.nextToken (/projectpath/node_modules/rollup/dist/rollup.js:4321:13)
    at Parser.pp$7.next (/projectpath/node_modules/rollup/dist/rollup.js:4266:8)
    at Parser.pp.eat (/projectpath/node_modules/rollup/dist/rollup.js:2200:10)
    at Parser.pp.semicolon (/projectpath/node_modules/rollup/dist/rollup.js:2245:13)
    at Parser.pp$1.parseImport (/projectpath/node_modules/rollup/dist/rollup.js:2996:8)
    at Parser.pp$1.parseStatement (/projectpath/node_modules/rollup/dist/rollup.js:2409:44)
    at Parser.pp$1.parseTopLevel (/projectpath/node_modules/rollup/dist/rollup.js:2313:23)

Just found what was causing my error. This path: /projectpath/.tmp/app/tmp/temp.page.ts is not the actual files path, but the generated during build file. My IDE’s refactoring messed up and used that path instead. Fixing the path solved the issue.

1 Like

I’m also with this problem. I just created a blank service and I associated with providers. It works with ionic serves but fails with ionic run android