Closed Hari70a closed 6 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+.
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.
;)
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
Import is in node 6+, we use it at my workplace in our plugins for Haraka.
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 ?\
We don't use Babel.
@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
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.
Personally, I'm going to support whatever is green for the most up to date LTS version of Node.
+1
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.
I feel that just
var
was replaced byconst
,let
andclass
.It doesn't haveimport
statements.Instead of that ,it's just replacedvar
withconst
andlet
.Also there is still 'use-strict'
which is not actually needed in es6 and es7