generator icon indicating copy to clipboard operation
generator copied to clipboard

ES2015 standards

Open bluzi opened this issue 8 years ago • 16 comments

Hi,

I am using this generator to kickstart most of my ExpressJS projects, and it's real good, but I always wonder why you use var and functions instead of let/const and arrow functions? I always change it myself when I kickstart a project.

Is there any particular reason for that? If not, I can make change and and create a pull request.

bluzi avatar Jul 17 '17 10:07 bluzi

Hi @bluzi the generator is designed to support the same version range of Node.js that Express.js itself supports, which is Node.js 0.10 and higher. Node.js 0.10 does not understand let/const and arrow functions, which is why the generated code doesn't use them.

Now, that's just the history. There is no reason why someone could not add in the ability to generate both the old ES5 style and the newer ES2015 style under a switch to let the users choose between the two. The generator could even automatically generate using ES2015 if the user didn't specify which one and the generator was run on a version of Node.js that supported ES2015.

dougwilson avatar Jul 17 '17 20:07 dougwilson

Hi @dougwilson , Thanks for the response. I will create a PR soon :)

bluzi avatar Jul 17 '17 20:07 bluzi

@dougwilson @bluzi Is this still being worked on? What else needs to be done?

benhalverson avatar Oct 08 '17 21:10 benhalverson

Hi @benhalverson, I couldn't find time to work on it yet. However, it seems like @sisisin created an ES2015 template on his fork, so maybe you should check that out.

bluzi avatar Oct 09 '17 07:10 bluzi

yes I guess majority of us are embracing eslint and es6 these days, if express-generator can catch up on this it will be fantastic.

laoshaw avatar Dec 18 '17 22:12 laoshaw

Why don't you add babel for compile ES6?

SilencerWeb avatar Jan 04 '18 02:01 SilencerWeb

This is quite long overdue. I think it will help a lot more people for this to be implemented than to maintain compatibility. What's stopping this from being implemented? I can make a pull request with my fork that is merged with version 4.15. Shall I merge it with 4.16?

wmthor avatar Jan 23 '18 06:01 wmthor

Pull request #176 addresses this and looks close to completion. They just need to figure out how it should behave and be tested on older versions of node.

bferris1 avatar Jan 23 '18 15:01 bferris1

If you want to keep compatibility with legacy node, a commandline flag would be a good choice for this.

The help output would look like

-6, --es6      generate output using ES6 features
-7, --es7      generate output using ES7 features

with the default choice being current/ES5 output.

Is node 0.10.0 even LTS anymore?

ogrotten avatar Feb 18 '18 20:02 ogrotten

@ogrotten no, Node.js 0.10.0 has been released in 2013... The current LTS is 8.10.0, and express-generator still didn't seem to adapt to this new version.

thatlizarddude avatar Mar 08 '18 01:03 thatlizarddude

I wish I was smart enough to help get PR #176 ready to be merged, but I'm not there yet with my coding.

However, as a new guy, I'm trying to focus my learning on ES2015/classes designs, and this would really help. Any update?

Thanks, guys.

tim-rohrer avatar May 21 '18 18:05 tim-rohrer

As https://github.com/expressjs/generator/pull/176 seems to have stalled and contains too many unrelated changes anyways I've created https://github.com/expressjs/generator/pull/200 that adds an --es6 flag. Feedback appreciated.

danielkhan avatar Jun 17 '18 15:06 danielkhan

@dougwilson, why do you need to maintain old version of node? Express-generator is here to help developers to generate new express repositories. If someone generated its own repo for node 0.10 or node 4, its build will still be valid, even if we upgrade express-generator to node v6.

Or we can say that if you want to generate a repo for node v0.10, you'll have to use express-generator vX.X, but those versions aren't maintained anymore.

Ayc0 avatar Jan 11 '19 11:01 Ayc0

Any roadmap when ES6 will be supported by a stable version of ExpressJS Generator out-of-box?

pubmikeb avatar Jan 14 '19 20:01 pubmikeb