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

Throw upgrade error when babel version is less than 6.14.0 #116

Merged
merged 3 commits into from
Aug 29, 2016
Merged
Changes from 1 commit
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
69 changes: 51 additions & 18 deletions packages/babel-preset-babili/src/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
const err = new Error("Babili is supported only for babel version >=6.14.0");
Copy link
Member

Choose a reason for hiding this comment

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

We can be more specific here - babel is babel-core. Can explain you need to update babel-core, or cli, etc


function isVersion(versionStr) {
const version = versionStr.split(".").map((p) => parseInt(p));
if (version[0] >= 6 && version[1] >= 14) {
Copy link
Member

Choose a reason for hiding this comment

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

return version[0] >= 6 && version[1] >= 14 ? :)

return true;
}
return false;
}

module.exports = {
minified: true,
plugins: [
require("babel-plugin-minify-constant-folding"),
require("babel-plugin-minify-dead-code-elimination"),
require("babel-plugin-minify-flip-comparisons"),
require("babel-plugin-minify-guarded-expressions"),
require("babel-plugin-minify-infinity"),
require("babel-plugin-minify-mangle-names"),
require("babel-plugin-minify-replace"),
require("babel-plugin-minify-simplify"),
require("babel-plugin-minify-type-constructors"),
require("babel-plugin-transform-member-expression-literals"),
require("babel-plugin-transform-merge-sibling-variables"),
require("babel-plugin-transform-minify-booleans"),
require("babel-plugin-transform-property-literals"),
require("babel-plugin-transform-simplify-comparison-operators"),
require("babel-plugin-transform-undefined-to-void"),
],
plugins: [function({version}) {
if (!isVersion(version)) {
throw err;
}
return {
visitor: {}
};
}],
};

Object.defineProperty(module.exports, "buildPreset", {
configurable: true,
writable: true,
enumerable: false,
value: preset
});

function preset(context) {
if (!isVersion(context.version)) {
throw err;
}
return {
minified: true,
plugins: [
require("babel-plugin-minify-constant-folding"),
require("babel-plugin-minify-dead-code-elimination"),
require("babel-plugin-minify-flip-comparisons"),
require("babel-plugin-minify-guarded-expressions"),
require("babel-plugin-minify-infinity"),
require("babel-plugin-minify-mangle-names"),
require("babel-plugin-minify-replace"),
require("babel-plugin-minify-simplify"),
require("babel-plugin-minify-type-constructors"),
require("babel-plugin-transform-member-expression-literals"),
require("babel-plugin-transform-merge-sibling-variables"),
require("babel-plugin-transform-minify-booleans"),
require("babel-plugin-transform-property-literals"),
require("babel-plugin-transform-simplify-comparison-operators"),
require("babel-plugin-transform-undefined-to-void"),
],
};
}