Skip to content

Commit

Permalink
Add convienient broccoli debug tooling.
Browse files Browse the repository at this point in the history
Allows easy debuging of input/output of babel trees via:

```js
BROCCOLI_DEBUG=ember-cli-babel:* ember b
```
  • Loading branch information
rwjblue committed Jun 1, 2017
1 parent 4e523f5 commit c53b873
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
20 changes: 18 additions & 2 deletions index.js
Expand Up @@ -5,6 +5,8 @@ const VersionChecker = require('ember-cli-version-checker');
const clone = require('clone');
const path = require('path');

let count = 0;

function addBaseDir(Plugin) {
let type = typeof Plugin;

Expand Down Expand Up @@ -34,8 +36,22 @@ module.exports = {
return this._getBabelOptions(config);
},

transpileTree(tree, config) {
return require('broccoli-babel-transpiler')(tree, this.buildBabelOptions(config));
_debugTree() {
if (!this._cachedDebugTree) {
this._cachedDebugTree = require('broccoli-debug').buildDebugCallback(`ember-cli-babel:${this._parentName()}`);
}

return this._cachedDebugTree.apply(null, arguments);
},

transpileTree(inputTree, config) {
let description = `000${++count}`.slice(-3);
let postDebugTree = this._debugTree(inputTree, `${description}:input`);

let BabelTranspiler = require('broccoli-babel-transpiler');
let output = new BabelTranspiler(postDebugTree, this.buildBabelOptions(config));

return this._debugTree(output, `${description}:output`);
},

setupPreprocessorRegistry: function(type, registry) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -41,6 +41,7 @@
"babel-polyfill": "^6.16.0",
"babel-preset-env": "^1.5.1",
"broccoli-babel-transpiler": "^6.0.0",
"broccoli-debug": "^0.6.2",
"broccoli-funnel": "^1.0.0",
"broccoli-source": "^1.1.0",
"clone": "^2.0.0",
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Expand Up @@ -951,6 +951,18 @@ broccoli-debug@^0.6.1:
symlink-or-copy "^1.1.8"
tree-sync "^1.2.2"

broccoli-debug@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/broccoli-debug/-/broccoli-debug-0.6.2.tgz#4c6e89459fc3de7d5d4fc7b77e57f46019f44db1"
dependencies:
broccoli-plugin "^1.2.1"
fs-tree-diff "^0.5.2"
heimdalljs "^0.2.1"
heimdalljs-logger "^0.1.7"
minimatch "^3.0.3"
symlink-or-copy "^1.1.8"
tree-sync "^1.2.2"

broccoli-funnel-reducer@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/broccoli-funnel-reducer/-/broccoli-funnel-reducer-1.0.0.tgz#11365b2a785aec9b17972a36df87eef24c5cc0ea"
Expand Down

0 comments on commit c53b873

Please sign in to comment.