Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Babel 6 #221

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var createEspowerPlugin = require('babel-plugin-espower/create');
var requireFromString = require('require-from-string');
var loudRejection = require('loud-rejection/api')(process);
var resolveFrom = require('resolve-from');
var hasGenerator = require('has-generator');
var serializeValue = require('./serialize-value');
var send = require('./send');

Expand All @@ -13,7 +12,7 @@ var testPath = process.argv[2];
var babel;

try {
var localBabel = resolveFrom('.', 'babel-core') || resolveFrom('.', 'babel');
var localBabel = resolveFrom('.', 'babel-core');
babel = require(localBabel);
} catch (err) {
babel = require('babel-core');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should drop using the the user's local Babel version. Instead we should just document that to use npm@3 or npm deduplicate. The user can then just enforce any Babel 6 version and we will use the same since our dependency is loose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Expand All @@ -24,11 +23,9 @@ var powerAssert = createEspowerPlugin(babel, {
patterns: require('./enhance-assert').PATTERNS
});

// if generators are not supported, use regenerator
var options = {
blacklist: hasGenerator ? ['regenerator'] : [],
optional: hasGenerator ? ['asyncToGenerator', 'runtime'] : ['runtime'],
plugins: [powerAssert]
presets: ['stage-3', 'es2015'],
plugins: [powerAssert, 'transform-runtime']
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the generator check no longer needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious about this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it still would be if we want to avoid the unnecessary transform. I think maybe asyncToGenerator was rolled in a preset? There's certainly a way to continue doing what we were before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was included in that preset, that's why I dropped it. Every intention of adding it back.

We are still waiting on https://phabricator.babeljs.io/T6644. I will approach this again when that closes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize async functions went to stage3. That's great! :)

// check if test files required ava and show error, when they didn't
Expand All @@ -40,9 +37,7 @@ process.on('uncaughtException', function (exception) {

// include test file
var transpiled = babel.transformFileSync(testPath, options);
requireFromString(transpiled.code, testPath, {
appendPaths: module.paths
});
requireFromString(transpiled.code, testPath);

// if ava was not required, show an error
if (!exports.avaRequired) {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@
"dependencies": {
"arr-flatten": "^1.0.1",
"ava-init": "^0.1.0",
"babel-core": "^5.8.23",
"babel-plugin-espower": "^1.1.0",
"babel-runtime": "^5.8.29",
"babel-core": "6.0.14",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use caret ^ for the versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, at the time, latest was 6.0.18 which I couldn't get to work at all. That is why it is pinned.
They are on 6.3.x now, so this likely isn't necessary anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamestalmage Yeah, was only commenting what I want the final PR to look like. We can wait on doing it until this PR is ready.

"babel-plugin-espower": "^2.0.0",
"babel-plugin-transform-runtime": "6.0.14",
"babel-polyfill": "6.0.14",
"babel-preset-es2015": "6.0.14",
"babel-preset-stage-3": "6.0.14",
"babel-runtime": "^5.8.34",
"bluebird": "^3.0.0",
"chalk": "^1.0.0",
"co-with-promise": "^4.6.0",
Expand Down