Code Monkey home page Code Monkey logo

Comments (5)

nenitiko avatar nenitiko commented on June 8, 2024

These options were removed in favor of ES6 or ES2015 (http://www.ecma-international.org/ecma-262/6.0/). The generator uses a gulp task and a library (babel-core) to transform (transpile) from ES6 to a Javascript that will be understood by most modern browsers (since not all of them are still up to speed with the latest ES6 features.)

You can still use Typescript, but you may have to change the gulp files, or play with the Typescript configuration. Typescript can generate both ES6 and plan JS, it all depends what your needs are. The trend I'm seeing now is to adopt and consume ES6, and use TypeScript as an add-on if you really want its static type-checking capabilities and language features not in ES6.

from generator-ko.

bakersoft avatar bakersoft commented on June 8, 2024

The problem I have now with this is the resulting code in the js file cannot be executed by the browser. startup.js for example generates:

import 'jquery';
import 'bootstrap';
import ko from 'knockout';

which immediately throws an error in Chrome (syntax error). Are there some new steps that have to be taken to get actual JavaScript generating in these js files so the browser can actually execute them?

from generator-ko.

nenitiko avatar nenitiko commented on June 8, 2024

This is ES6 code, not for direct browser consumption (for now) but to be pre-processed by "babel" (https://babeljs.io/) the gulpfile.js has a section (or task) called js:babel which converts (transpiles/compiles) from ES6 to browser-understendable JavaScript. ES6 is the future (or the present?) of JavaScript and most of modern libraries and tools use it extensively including generator-knockout.

In order for your startup.js to be "transpiled" you must serve your code from the "dist" folder, which is copied transpiled/bundled and minified by running gulp and then gulp serve:dist, or from the src folder which is dynamically transpiled by the "connect" server by running the the gulp serve:src task.

from generator-ko.

carbontwelve avatar carbontwelve commented on June 8, 2024

I use gulp serve:src for development with this and have no issues.

from generator-ko.

SteveSanderson avatar SteveSanderson commented on June 8, 2024

As per @nenitiko's comments, this generator produces ES2015 only now (which is not TypeScript, BTW).

from generator-ko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.