haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.07k stars 661 forks source link

Still conversion of es6 not happened quite clearly #2235

Closed Hari70a closed 6 years ago

Hari70a commented 7 years ago

I feel that just var was replaced by const, letand class.It doesn't have importstatements.Instead of that ,it's just replaced varwith constand let.Also there is still 'use-strict' which is not actually needed in es6 and es7

msimerson commented 7 years ago

Also there is still 'use-strict' which is not actually needed in es6 and es7

We aren't es6 exclusive. Yet. We're taking advantage of es6 features that are available in node 6+.

KingNoosh commented 7 years ago

It's a slow process updating syntax and making sure stuff still works. I'm aware import exists in node 6 so I'm going to start looking at that at some point. If you have any suggestions, throw them at us just in case. ;)

MuraraAllan commented 7 years ago

We have to pay attention to ECMA Standards (https://www.ecma-international.org/publications/standards/Ecma-262.htm here is general and es8 release notes, from July) x Node Engine.

Node doesn't support import. You need to transpile it in order to be able to use the import syntax, what doesn't mean you should apply to Haraka. Actually i don't see Haraka using it.

I strongly recommend you to read this one @Hari70a . It has a explanation about the principles of Synchronous / Asynchronous module load on NodeJS.

https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c

KingNoosh commented 7 years ago

Import is in node 6+, we use it at my workplace in our plugins for Haraka.

MuraraAllan commented 7 years ago

https://hackernoon.com/node-js-tc-39-and-modules-a1118aecf95e

"For Node.js, a challenge arises when “foo” is not a ESM with a lexically defined set of exports, but a CommonJS module with a dynamically defined set of exports. Specifically: when I say import {m} from “foo”, ESM currently requires that it is possible to determine that m is exported by “foo” before evaluation; but as we’ve already seen, since “foo” is a CommonJS module, it is not possible to determine that m is exported until after evaluation. The end result is that named exports and imports from CommonJS, a critically important feature of ECMAScript modules, simply would not be possible under the currently defined ESM specification."

They are still working over it, this topic is from october begining, aren't you using Babel @KingNoosh ?\

KingNoosh commented 7 years ago

We don't use Babel.

Hari70a commented 7 years ago

@MuraraAllan
I have read the link https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c.Got ur point.But it's mentioned clearly that if we use the transpiler Babel , the ESM and Common JS modules work the same(synchronous loading, evaluating code after import and export).So Why can't we go for Babel @msimerson and @KingNoosh

KingNoosh commented 7 years ago

Adding another pointless build step isn't needed. If Haraka was completely rewritten, sure I'd consider Babel or even TypeScript, but not for an on-going project.

Personally, I'm going to support whatever is green for the most up to date LTS version of Node.

msimerson commented 7 years ago

Personally, I'm going to support whatever is green for the most up to date LTS version of Node.

+1

msimerson commented 7 years ago

But with caveats for Harara, because there are significant costs to churn. I like to use node.green features in small doses until I grok them.