From 37a06da563d951f4c8ee82d6edde518b236ade7a Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 18 Mar 2021 10:51:37 -0400 Subject: [PATCH] Expose `getSupportedExtensions` method. --- README.md | 11 +++++++++++ index.js | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41d62668..ce6b8fbe 100755 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ allow you to use latest Javascript in your Ember CLI project. + [Adding Custom Plugins](#adding-custom-plugins) + [Additional Trees](#additional-trees) + [`buildBabelOptions` usage](#buildbabeloptions-usage) + + [`getSupportedExtensions` usage](#getsupportedextensions-usage) + [`transpileTree` usage](#transpiletree-usage) * [Debug Tooling](#debug-tooling) + [Debug Macros](#debug-macros) @@ -412,6 +413,16 @@ let options = babelAddon.buildBabelOptions(config) require('babel-core').transform('something', options); ``` +#### `getSupportedExtensions` usage + +```js +// find your babel addon (can use `this.findAddonByName('ember-cli-babel')` in ember-cli@2.14 and newer) +let babelAddon = this.addons.find(addon => addon.name === 'ember-cli-babel'); + +// create the babel options to use elsewhere based on the config above +let extensions = babelAddon.getSupportedExtensions(config) +``` + #### `transpileTree` usage ```js diff --git a/index.js b/index.js index 2d775bf3..992d341d 100644 --- a/index.js +++ b/index.js @@ -83,6 +83,10 @@ module.exports = { return this._cachedDebugTree.apply(null, arguments); }, + getSupportedExtensions(config) { + return _getExtensions(config, this.parent); + }, + _buildBroccoliBabelTranspilerOptions(config = {}) { let emberCLIBabelConfig = config["ember-cli-babel"]; @@ -104,7 +108,7 @@ module.exports = { annotation: providedAnnotation || `Babel: ${_parentName(this.parent)}`, sourceMaps, throwUnlessParallelizable, - filterExtensions: _getExtensions(config, this.parent), + filterExtensions: this.getSupportedExtensions(config), plugins: [] };