Function parameter destructuring in Meteor for mailparser

Has anyone been using the mailparser npm package in Meteor?

I need to use it (or something just as simple) but, while it supports both callback and promise, the promise implementation in the simpleParser function is using a strange function parameter destructuring syntax (which I believe works in Node 6) that will not compile in Meteor 1.4+.

The offending js file is only 90 lines long at this location:

However, it is the last 10 lines (as follows) where the issue is:

function callbackPromise(resolve, reject) {
    return function (...args) {
        let err = args.shift();
        if (err) {
            reject(err);
        } else {
            resolve(...args);
        }
    };
}

The …args syntax causes an error. I am not using the promise mechanism and so I can edit this out in my local code but, of course, a CI build pulls down the module fresh.

Aside from forking the repo, making a very tiny change, and either issuing a pull request (or just using the modified repo directly), my questions are:

  • is there an easier way to fix this (e.g. beta version of babel or such that might handle the syntax)?
  • Is there any code similar to mailparser that others would recommend?
  • does anyone know the timeline for Meteor to support Node 6?

[I’m looking for a quick solution as I have a looming deadline - the long solution would just be to fix it myself which is not possible at present due to time constraints]

Rgds

Further to the above…

I pulled the node module out of the node_modules folder with a view to just keeping a local copy of this and “fixing” whatever was broken.

Suddenly, the code started working without modification.

It seems as though when it is being loaded from node_modules that the transpiler does not recognise the syntax but it is fine when it is directly imported from a path in my own root directory.

So, for now, I have a “solution” whereby I have removed it as an NPM package and have just incorporated the code directly myself.

This is, indeed. strange.