SteveSanderson / generator-ko

63 stars 39 forks source link

Unexpected token import #24

Open zantinger opened 8 years ago

zantinger commented 8 years ago

Hi, I have run the generator successfully. Now, when I run http-server for src on the cmd I get an error Unexpected token import in startup.js. Same problem in Chrome 50 and Firefox on win10

sportechrobbie commented 8 years ago

Yes me too - stops on the import 'jquery'; statement, line 1 of the startup.js

sportechrobbie commented 8 years ago

The only way i could get this to run in my browser (Chrome) was to do the build, by running the gulp command and pointing my browser to the 'dist' folder - it seems the ES2015 change has something todo with it.

chrconlo commented 8 years ago

Just watched the video online today and tried deploying KO application using this generator. Ran into this issue where browser JS engine is complaining about import statements. Then tried compiling in Babel via Gulp script but hit Issue #19 in the process. Is this generator left for dead?

yskeat commented 8 years ago

Facing same problem, someone still maintaining this project?

chrconlo commented 8 years ago

This change looks like it was on purpose...to make this generator useless for people who just want to use plain JavaScript. Now struggling to get ko.mapping to work with ko components generated with this tool. I am quickly coming to the conclusion I should have bit the bullet and learned Angular...

Kevinio04 commented 8 years ago

Hey guys, there is a fix to this I found on SO. Well... there is a fix to getting the Gulp build to work anyway. Its a pretty simple fix and relates to how slashes are handled between windows and OSX.

At the top of gulpfile.js you need to add the following variable to the gulp and plugins variables: slash = require('slash');

Then at the bottom of the file edit the babelTranspile function. Add a new line at the top of the function and paste the following: pathname = slash(pathname);

This will allow the build to execute and the application will load from the dist folder. I have no idea how steve is running from the src folder in the demo however. No browsers support ES6 so the imports declarations in the startup file in my mind will never work, they would have to be updated to ES5 require statements.

Original answer to the gulp problem found here:

http://stackoverflow.com/questions/33198584/gulp-failing-default-task-due-to-jquery-error-for-generator-ko

cosmoKenney commented 7 years ago

I'm stuck on this too. I can only get it to run if I build with Gulp. I was so looking forward to using this. But it just doesn't seem to be complete.

I also thought this was ready for TypeScript??

dipaktelangre commented 7 years ago

@Kevinio04 I spend almost day to resolve same issue. Thanks for your solution, its works :) 👍