Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Add logs for polyfills. #59

Merged
merged 5 commits into from
Dec 5, 2016
Merged
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
30 changes: 20 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ export const validateWhitelistOption = (whitelistOpt = []) => {

let hasBeenLogged = false;

const logPlugin = (plugin, targets, list) => {
const envList = list[plugin];
const filteredList = Object.keys(targets)
.reduce((a, b) => {
a[b] = envList[b];
return a;
}, {});
const logStr = `\n ${plugin} ${JSON.stringify(filteredList)}`;
Copy link
Member

Choose a reason for hiding this comment

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

do we need the \n given its separate console.logs? I see that it's newlines? (Unless you think it looks better that way)

Using plugins:

 syntax-trailing-function-commas {}

Using polyfills:

 es6.typed.data-view {}

 es6.reflect.apply {}

 es6.reflect.own-keys {}

 es6.symbol.iterator {}

 es6.symbol.species {}

 es6.array.from {}
Using plugins:
syntax-trailing-function-commas {}

Using polyfills:
es6.typed.data-view {}
es6.reflect.apply {}
es6.reflect.own-keys {}
es6.symbol.iterator {}
es6.symbol.species {}
es6.array.from {}

console.log(logStr);
};

export default function buildPreset(context, opts = {}) {
const loose = validateLooseOption(opts.loose);
const moduleType = validateModulesOption(opts.modules);
Expand All @@ -155,23 +166,22 @@ export default function buildPreset(context, opts = {}) {

if (debug && !hasBeenLogged) {
hasBeenLogged = true;

console.log("babel-preset-env: `DEBUG` option");
console.log("");
console.log(`Using targets: ${JSON.stringify(targets, null, 2)}`);
console.log("");
console.log("Using plugins:");
console.log("");
console.log(`module: ${moduleType}`);
console.log("");
console.log("Using plugins:");
transformations.forEach((transform) => {
let envList = pluginList[transform];
let filteredList = Object.keys(targets)
.reduce((a, b) => {
a[b] = envList[b];
return a;
}, {});
console.log(transform, JSON.stringify(filteredList, null, 2));
logPlugin(transform, targets, pluginList);
});
console.log("\nUsing polyfills:");
if (useBuiltIns && polyfills.length) {
polyfills.forEach((polyfill) => {
logPlugin(polyfill, targets, builtInsList);
});
}
}

transformations = [...transformations, ...whitelist].map((pluginName) => {
Expand Down