Merge branch 'master' into 2.0
This commit is contained in:
commit
243d5d1a02
@ -1,5 +1,46 @@
|
||||
# Changelog
|
||||
|
||||
## v1.3.3 (2017-04-07)
|
||||
|
||||
### :bug: Bug Fix
|
||||
|
||||
- Support electron version in a string format ([#252](https://github.com/babel/babel-preset-env/pull/252)) (@yavorsky)
|
||||
|
||||
Adding electron as a target was an inadvertent breaking change as it no longer
|
||||
allowed string versions. We added an exception for now, even though it is
|
||||
inconsistent with other versions. Just as a note, the upcoming version 2.x will
|
||||
allow _both_ number and string versions.
|
||||
|
||||
- Ensure const-check plugin order ([#257](https://github.com/babel/babel-preset-env/pull/257)) (@existentialism)
|
||||
|
||||
We now force the `const-es2015-check` plugin to run first (so that it can
|
||||
correctly report issues before they get transpiled away).
|
||||
|
||||
### :rocket: New Feature
|
||||
|
||||
- Allow use `babel-plugin-` prefix for include and exclude ([#242](https://github.com/babel/babel-preset-env/pull/242)) (@yavorsky)
|
||||
|
||||
The `include` and `exclude` options now allow both prefixed (`babel-plugin-transform-es2015-spread`)
|
||||
and prefix-less (`transform-es2015-spread`) plugin names.
|
||||
|
||||
### :memo: Documentation
|
||||
|
||||
- Note babel plugin prefix handling in include/exclude ([#245](https://github.com/babel/babel-preset-env/pull/245)) (@existentialism)
|
||||
- Fix README: debug option shows info in stdout. ([#236](https://github.com/babel/babel-preset-env/pull/236)) (@Gerhut)
|
||||
|
||||
### :house: Internal
|
||||
|
||||
- Add simple smoke-test ([#240](https://github.com/babel/babel-preset-env/pull/240)) (@existentialism)
|
||||
- Add prepublish script (@existentialism)
|
||||
|
||||
## v1.3.2 (2017-03-30)
|
||||
|
||||
- Fixed an issue with a broken publish
|
||||
|
||||
## v1.3.1 (2017-03-30)
|
||||
|
||||
- Fixed a regression with missing files due to `.npmignore`.
|
||||
|
||||
## v1.3.0 (2017-03-30)
|
||||
|
||||
### :bug: Bug Fix
|
||||
|
||||
@ -156,7 +156,11 @@ Outputs the targets/plugins used and the version specified in [plugin data versi
|
||||
|
||||
An array of plugins to always include.
|
||||
|
||||
Valid options include any of the [babel plugins](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js) or [built-ins](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js), such as `transform-es2015-arrow-functions`, `map`, `set`, or `object.assign`.
|
||||
Valid options include any:
|
||||
|
||||
- [Babel plugins](https://github.com/babel/babel-preset-env/blob/master/data/plugin-features.js) - both with (`babel-plugin-transform-es2015-spread`) and without prefix (`transform-es2015-spread`) are supported.
|
||||
|
||||
- [Built-ins](https://github.com/babel/babel-preset-env/blob/master/data/built-in-features.js), such as `map`, `set`, or `object.assign`.
|
||||
|
||||
This option is useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work.
|
||||
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
module.exports = {
|
||||
// es2015
|
||||
"check-es2015-constants": {
|
||||
features: [
|
||||
"const",
|
||||
],
|
||||
},
|
||||
"transform-es2015-arrow-functions": {
|
||||
features: [
|
||||
"arrow functions",
|
||||
@ -27,11 +32,6 @@ module.exports = {
|
||||
"object literal extensions / computed properties",
|
||||
],
|
||||
},
|
||||
"check-es2015-constants": {
|
||||
features: [
|
||||
"const",
|
||||
],
|
||||
},
|
||||
"transform-es2015-destructuring": {
|
||||
features: [
|
||||
"destructuring, assignment",
|
||||
|
||||
@ -1,4 +1,14 @@
|
||||
{
|
||||
"check-es2015-constants": {
|
||||
"chrome": "49",
|
||||
"edge": "14",
|
||||
"firefox": "51",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"ios": "10",
|
||||
"opera": "36",
|
||||
"electron": "1"
|
||||
},
|
||||
"transform-es2015-arrow-functions": {
|
||||
"chrome": "47",
|
||||
"edge": "13",
|
||||
@ -50,16 +60,6 @@
|
||||
"opera": "31",
|
||||
"electron": "0.31"
|
||||
},
|
||||
"check-es2015-constants": {
|
||||
"chrome": "49",
|
||||
"edge": "14",
|
||||
"firefox": "51",
|
||||
"safari": "10",
|
||||
"node": "6",
|
||||
"ios": "10",
|
||||
"opera": "36",
|
||||
"electron": "1"
|
||||
},
|
||||
"transform-es2015-destructuring": {
|
||||
"chrome": "51",
|
||||
"edge": "15",
|
||||
|
||||
@ -33,6 +33,11 @@ export const validateIncludesAndExcludes = (opts = [], type) => {
|
||||
return opts;
|
||||
};
|
||||
|
||||
export const normalizePluginName = plugin =>
|
||||
plugin.replace(/^babel-plugin-/, "");
|
||||
|
||||
export const normalizePluginNames = plugins => plugins.map(normalizePluginName);
|
||||
|
||||
export const checkDuplicateIncludeExcludes = (include = [], exclude = []) => {
|
||||
const duplicates = include.filter(opt => exclude.indexOf(opt) >= 0);
|
||||
|
||||
@ -79,6 +84,14 @@ export const validateUseBuiltInsOption = (builtInsOpt = true) => {
|
||||
};
|
||||
|
||||
export default function normalizeOptions(opts) {
|
||||
if (opts.exclude) {
|
||||
opts.exclude = normalizePluginNames(opts.exclude);
|
||||
}
|
||||
|
||||
if (opts.whitelist || opts.include) {
|
||||
opts.include = normalizePluginNames(opts.whitelist || opts.include);
|
||||
}
|
||||
|
||||
checkDuplicateIncludeExcludes(opts.include, opts.exclude);
|
||||
|
||||
return {
|
||||
|
||||
@ -9,12 +9,12 @@ Using targets:
|
||||
Modules transform: false
|
||||
|
||||
Using plugins:
|
||||
check-es2015-constants {"uglify":true}
|
||||
transform-es2015-arrow-functions {"uglify":true}
|
||||
transform-es2015-block-scoped-functions {"uglify":true}
|
||||
transform-es2015-block-scoping {"uglify":true}
|
||||
transform-es2015-classes {"uglify":true}
|
||||
transform-es2015-computed-properties {"uglify":true}
|
||||
check-es2015-constants {"uglify":true}
|
||||
transform-es2015-destructuring {"uglify":true}
|
||||
transform-es2015-duplicate-keys {"uglify":true}
|
||||
transform-es2015-for-of {"uglify":true}
|
||||
|
||||
@ -10,12 +10,12 @@ Using targets:
|
||||
Modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
check-es2015-constants {"ie":"10"}
|
||||
transform-es2015-arrow-functions {"ie":"10"}
|
||||
transform-es2015-block-scoped-functions {"ie":"10"}
|
||||
transform-es2015-block-scoping {"ie":"10"}
|
||||
transform-es2015-classes {"ie":"10"}
|
||||
transform-es2015-computed-properties {"ie":"10"}
|
||||
check-es2015-constants {"ie":"10"}
|
||||
transform-es2015-destructuring {"ie":"10","node":"6"}
|
||||
transform-es2015-duplicate-keys {"ie":"10"}
|
||||
transform-es2015-for-of {"ie":"10","node":"6"}
|
||||
|
||||
@ -15,8 +15,8 @@ Using targets:
|
||||
Modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
transform-es2015-block-scoping {"electron":"0.36"}
|
||||
check-es2015-constants {"electron":"0.36"}
|
||||
transform-es2015-block-scoping {"electron":"0.36"}
|
||||
transform-es2015-destructuring {"electron":"0.36"}
|
||||
transform-es2015-for-of {"electron":"0.36"}
|
||||
transform-es2015-function-name {"electron":"0.36"}
|
||||
|
||||
@ -13,12 +13,12 @@ Using targets:
|
||||
Modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
check-es2015-constants {"edge":"13","firefox":"49","ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-arrow-functions {"ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-block-scoped-functions {"ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-block-scoping {"edge":"13","firefox":"49","ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-classes {"ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-computed-properties {"ie":"10","safari":"7"}
|
||||
check-es2015-constants {"edge":"13","firefox":"49","ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-destructuring {"edge":"13","firefox":"49","ie":"10","ios":"9","safari":"7"}
|
||||
transform-es2015-duplicate-keys {"ie":"10","safari":"7"}
|
||||
transform-es2015-for-of {"edge":"13","firefox":"49","ie":"10","ios":"9","safari":"7"}
|
||||
|
||||
@ -19,12 +19,12 @@ Using targets:
|
||||
Modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
check-es2015-constants {"electron":"0.36","ie":"10"}
|
||||
transform-es2015-arrow-functions {"ie":"10"}
|
||||
transform-es2015-block-scoped-functions {"ie":"10"}
|
||||
transform-es2015-block-scoping {"electron":"0.36","ie":"10"}
|
||||
transform-es2015-classes {"ie":"10"}
|
||||
transform-es2015-computed-properties {"ie":"10"}
|
||||
check-es2015-constants {"electron":"0.36","ie":"10"}
|
||||
transform-es2015-destructuring {"electron":"0.36","node":"6.1","ie":"10"}
|
||||
transform-es2015-duplicate-keys {"ie":"10"}
|
||||
transform-es2015-for-of {"electron":"0.36","node":"6.1","ie":"10"}
|
||||
|
||||
@ -10,12 +10,12 @@ Using targets:
|
||||
Modules transform: commonjs
|
||||
|
||||
Using plugins:
|
||||
check-es2015-constants {"ie":"10"}
|
||||
transform-es2015-arrow-functions {"ie":"10"}
|
||||
transform-es2015-block-scoped-functions {"ie":"10"}
|
||||
transform-es2015-block-scoping {"ie":"10"}
|
||||
transform-es2015-classes {"ie":"10"}
|
||||
transform-es2015-computed-properties {"ie":"10"}
|
||||
check-es2015-constants {"ie":"10"}
|
||||
transform-es2015-destructuring {"ie":"10"}
|
||||
transform-es2015-duplicate-keys {"ie":"10"}
|
||||
transform-es2015-for-of {"ie":"10"}
|
||||
|
||||
2
experimental/babel-preset-env/test/fixtures/sanity/check-es2015-constants/exec.js
vendored
Normal file
2
experimental/babel-preset-env/test/fixtures/sanity/check-es2015-constants/exec.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
const one = 123;
|
||||
one = 432;
|
||||
6
experimental/babel-preset-env/test/fixtures/sanity/check-es2015-constants/options.json
vendored
Normal file
6
experimental/babel-preset-env/test/fixtures/sanity/check-es2015-constants/options.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"presets": [
|
||||
["../../../../lib"]
|
||||
],
|
||||
"throws": "\"one\" is read-only"
|
||||
}
|
||||
@ -8,9 +8,34 @@ const {
|
||||
validateIncludesAndExcludes,
|
||||
validateLooseOption,
|
||||
validateModulesOption,
|
||||
normalizePluginNames,
|
||||
} = normalizeOptions;
|
||||
|
||||
describe("normalize-options", () => {
|
||||
describe("normalizeOptions", () => {
|
||||
it("should return normalized `include` and `exclude`", () => {
|
||||
const normalized = normalizeOptions.default({
|
||||
include: [
|
||||
"babel-plugin-transform-es2015-spread",
|
||||
"transform-es2015-classes",
|
||||
],
|
||||
});
|
||||
assert.deepEqual(normalized.include, [
|
||||
"transform-es2015-spread",
|
||||
"transform-es2015-classes",
|
||||
]);
|
||||
});
|
||||
|
||||
it("should throw if duplicate names in `include` and `exclude`", () => {
|
||||
const normalizeWithSameIncludes = () => {
|
||||
normalizeOptions.default({
|
||||
include: ["babel-plugin-transform-es2015-spread"],
|
||||
exclude: ["transform-es2015-spread"],
|
||||
});
|
||||
};
|
||||
assert.throws(normalizeWithSameIncludes, Error);
|
||||
});
|
||||
});
|
||||
describe("validateLooseOption", () => {
|
||||
it("`undefined` option returns false", () => {
|
||||
assert(validateLooseOption() === false);
|
||||
@ -57,6 +82,27 @@ describe("normalize-options", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizePluginNames", function() {
|
||||
it("should drop `babel-plugin-` prefix if needed", function() {
|
||||
assert.deepEqual(
|
||||
normalizePluginNames([
|
||||
"babel-plugin-transform-es2015-object-super",
|
||||
"transform-es2015-parameters",
|
||||
]),
|
||||
["transform-es2015-object-super", "transform-es2015-parameters"],
|
||||
);
|
||||
});
|
||||
|
||||
it("should not throw if no duplicate names in both", function() {
|
||||
assert.doesNotThrow(
|
||||
() => {
|
||||
checkDuplicateIncludeExcludes(["transform-regenerator"], ["map"]);
|
||||
},
|
||||
Error,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateModulesOption", () => {
|
||||
it("`undefined` option returns commonjs", () => {
|
||||
assert(validateModulesOption() === "commonjs");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user