Skip to content

Commit

Permalink
Added support for debug option (default=off)
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jun 29, 2017
1 parent 9cf8bfd commit 588b047
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ These are our default options. They can be tweaked by passing the required optio

```js
const defaults = {
// Whether to print hints on transpilation settings which were selected.
debug: false,

// One of the following:
// - "node"/nodejs"/"script"/"binary": any NodeJS related execution with wide support to last LTS aka 6.9.0
// - "current"/"test": current NodeJS version
Expand Down
25 changes: 18 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import es3PropertyLiterals from "babel-plugin-transform-es3-property-literals"
import es3ExpressionLiterals from "babel-plugin-transform-es3-member-expression-literals"

const defaults = {
// Whether to print hints on transpilation settings which were selected.
debug: false,

// One of the following:
// - "node"/nodejs"/"script"/"binary": any NodeJS related execution with wide support to last LTS aka 6.9.0
// - "current"/"test": current NodeJS version
Expand Down Expand Up @@ -64,7 +67,9 @@ export default function buildPreset(context, opts = {})
const envValue = process.env.BABEL_ENV || process.env.NODE_ENV || "development"
const isProduction = envValue === "production"

console.log("- Environment:", envValue)
if (options.debug) {
console.log("- Environment:", envValue)
}

// Auto select test target when running in test environment and no other info is available.
if (envValue === "test" && options.target == null) {
Expand Down Expand Up @@ -124,14 +129,18 @@ export default function buildPreset(context, opts = {})
"transform-es2015-modules-systemjs",
"transform-es2015-modules-amd",
"transform-es2015-modules-umd"

// This is already excluded by default
// "transform-regenerator"
)
}

if (options.target === "es2015") {
console.log("- Environment Targets: ES2015 capable")
} else {
console.log("- Environment Targets:", envTargets)
if (options.debug) {
if (options.target === "es2015") {
console.log("- Environment Targets: ES2015 capable")
} else {
console.log("- Environment Targets:", envTargets)
}
}

if (options.modules === "auto" || options.modules == null) {
Expand All @@ -147,8 +156,10 @@ export default function buildPreset(context, opts = {})
}
}

console.log("- Module Settings:", options.modules === false ? "ESM" : options.modules)
console.log("- Transpilation Compliance:", options.specMode ? "SPEC" : options.looseMode ? "LOOSE" : "DEFAULT")
if (options.debug) {
console.log("- Module Settings:", options.modules === false ? "ESM" : options.modules)
console.log("- Transpilation Compliance:", options.specMode ? "SPEC" : options.looseMode ? "LOOSE" : "DEFAULT")
}

presets.push([ envPreset, {
// Setting this to false will not transform modules.
Expand Down

0 comments on commit 588b047

Please sign in to comment.