Skip to content

Commit 7dd2bf0

Browse files
committed
Respect babel retainLines option.
1 parent d8f266c commit 7dd2bf0

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ interface EmberCLIBabelConfig {
7676
exclude?: string[];
7777
useBuiltIns?: boolean;
7878
sourceMaps?: boolean | "inline" | "both";
79+
retainLines?: boolean;
7980
plugins?: BabelPlugin[];
8081
};
8182

@@ -159,6 +160,22 @@ var app = new EmberApp(defaults, {
159160
});
160161
```
161162

163+
#### Enabling Retain Lines
164+
165+
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)
166+
167+
To enable it, pass `retainLines: true` in your `babel` options.
168+
169+
```js
170+
// ember-cli-build.js
171+
172+
var app = new EmberApp(defaults, {
173+
babel: {
174+
retainLines: true
175+
}
176+
});
177+
```
178+
162179
#### Modules
163180

164181
Older versions of Ember CLI (`< 2.12`) use its own ES6 module transpiler. Because of that, this plugin disables Babel

index.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,12 @@ module.exports = {
211211
sourceMaps = config.babel.sourceMaps;
212212
}
213213

214-
let options = {
215-
annotation: providedAnnotation || `Babel: ${this._parentName()}`,
216-
sourceMaps
217-
};
214+
let retainLines = false;
215+
if (config.babel && "retainLines" in config.babel) {
216+
retainLines = config.babel.retainLines;
217+
}
218+
219+
let options = { annotation: providedAnnotation || `Babel: ${this._parentName()}`, sourceMaps, retainLines };
218220

219221
let userPlugins = addonProvidedConfig.plugins;
220222
let userPostTransformPlugins = addonProvidedConfig.postTransformPlugins;

node-tests/addon-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,13 @@ describe('ember-cli-babel', function() {
718718
expect(result.sourceMaps).to.equal('inline');
719719
});
720720

721+
it("uses provided retainLines if specified", function() {
722+
let options = { babel: { retainLines: true } };
723+
724+
let result = this.addon.buildBabelOptions(options);
725+
expect(result.retainLines).to.equal(true);
726+
});
727+
721728
it('does not include all provided options', function() {
722729
let babelOptions = { blah: true };
723730
let options = {

0 commit comments

Comments
 (0)