diff --git a/README.md b/README.md index 5eae4021..0a4c99a8 100755 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ interface EmberCLIBabelConfig { exclude?: string[]; useBuiltIns?: boolean; sourceMaps?: boolean | "inline" | "both"; + retainLines?: boolean; plugins?: BabelPlugin[]; }; @@ -171,6 +172,22 @@ let app = new EmberApp(defaults, { }); ``` +#### Enabling Retain Lines + +Babel generated source maps will enable you to debug your original ES6 source code. This is disabled by default because this will lead to wacky code but is handy for scenarios where you can't use source maps or breakpoints in external debugger are offset (vscode has this issue, see the extension https://github.com/Microsoft/vscode-chrome-debug) + +To enable it, pass `retainLines: true` in your `babel` options. + +```js +// ember-cli-build.js + +var app = new EmberApp(defaults, { + babel: { + retainLines: true + } +}); +``` + #### Modules Older versions of Ember CLI (`< 2.12`) use its own ES6 module transpiler. diff --git a/index.js b/index.js index 9f8a14ea..c11702f1 100644 --- a/index.js +++ b/index.js @@ -204,10 +204,16 @@ module.exports = { sourceMaps = config.babel.sourceMaps; } + let retainLines = false; + if (config.babel && "retainLines" in config.babel) { + retainLines = config.babel.retainLines; + } + let options = { annotation: providedAnnotation || `Babel: ${this._parentName()}`, sourceMaps, - throwUnlessParallelizable + throwUnlessParallelizable, + retainLines }; let userPlugins = addonProvidedConfig.plugins; diff --git a/node-tests/addon-test.js b/node-tests/addon-test.js index 103b3d10..8bf351e2 100644 --- a/node-tests/addon-test.js +++ b/node-tests/addon-test.js @@ -722,6 +722,13 @@ describe('ember-cli-babel', function() { expect(result.sourceMaps).to.equal('inline'); }); + it("uses provided retainLines if specified", function() { + let options = { babel: { retainLines: true } }; + + let result = this.addon.buildBabelOptions(options); + expect(result.retainLines).to.equal(true); + }); + it('does not include all provided options', function() { let babelOptions = { blah: true }; let options = {