jaredhanson / jaredhanson/electrolyte

Babel transpile with babel-preset-es2015 + async function breaks Electrolyte

Open
#52 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
555
Forks
60
PR merge metrics
No merged PRs in 30d

Description

Something about the transpiling this class with babel-preset-2015 will cause Electrolyte to be unable to create the object:
```
'use strict';

class Test {
async home() {
}
}
module.exports = function() {
return new Test();
};

module.exports['@singleton'] = true;
```

The two specific things that cause the error are the async function, and using babel-preset-es2015. So if you're using babel-preset-latest, this problem will occur since that includes es2015. Using babel-preset-2016 and babel-present-2017 will **not** cause this problem.

Since the ES2015 (ES6) features are all part of the most recent versions of (Node 6+) this isn't really a huge problem since you don't need to transpile for ES6 anymore. I just wanted to post this here in case anybody else bangs there head against the wall trying to figure out why the most basic usage of this package isn't working.

Removing the "async" part of the function or not using babel-preset-es2015 fixes the problem.

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the supplied Test class as the minimal reproduction and run it with babel-preset-es2015, then compare it with the non-async and alternate-preset cases described in the issue. Trace Electrolyte's object-creation path and add a regression test if the relevant test location can be found; done means the failing transpiled case is handled or clearly documented by a passing test.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.