Skip to content

Commit

Permalink
Return envs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannik Zschiesche committed Jun 27, 2019
1 parent 0a8032a commit c165914
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
4.0.0
=====

* Return environments (`legacy` and `modern`) instead of a single config.


3.0.1
=====

Expand Down
6 changes: 6 additions & 0 deletions .github/UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.x to 4.0
==========

* Removed default export and instead return to environments: `legacy` and `modern`.


2.x to 3.0
==========

Expand Down
48 changes: 31 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
module.exports = {
plugins: [
// ------------------------------------------------------------------------------------------
// Stage 3 proposals
// ------------------------------------------------------------------------------------------
["@babel/plugin-syntax-dynamic-import"],
["@babel/plugin-proposal-json-strings"],
const browserslistConfigs = require("@becklyn/browserslist-config/envs");

/**
* Builds the config for a given browser list
*/
function buildConfig (browserslistConfig)
{
return {
plugins: [
// ------------------------------------------------------------------------------------------
// Stage 3 proposals
// ------------------------------------------------------------------------------------------
["@babel/plugin-syntax-dynamic-import"],
["@babel/plugin-proposal-json-strings"],

// set with loose: true, as the compilation is pretty big
// https://babeljs.io/docs/plugins/transform-class-properties/
["@babel/plugin-proposal-class-properties", {loose: true}],
// set with loose: true, as the compilation is pretty big
// https://babeljs.io/docs/plugins/transform-class-properties/
["@babel/plugin-proposal-class-properties", {loose: true}],

// default env
["@babel/preset-env", {
spec: false,
useBuiltIns: "entry",
corejs: 3,
}],
]
// default env
["@babel/preset-env", {
spec: false,
useBuiltIns: "entry",
corejs: 3,
targets: browserslistConfig,
}],
],
};
}

module.exports = {
modern: buildConfig(browserslistConfigs.modern),
legacy: buildConfig(browserslistConfigs.legacy),
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-json-strings": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.4.5"
"@babel/preset-env": "^7.4.5",
"@becklyn/browserslist-config": "^2.1.0"
}
}

0 comments on commit c165914

Please sign in to comment.