Skip to content

Commit

Permalink
Merge pull request #191 from nlfurniss/remove-browserPolyfill-option
Browse files Browse the repository at this point in the history
Remove browserPolyfill option
  • Loading branch information
rwjblue authored Oct 12, 2020
2 parents ff975c0 + 1063ce0 commit 8916e2d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 60 deletions.
24 changes: 0 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,6 @@ let scriptTree = esTranspiler(inputTree, {
});
```

## Polyfill

In order to use some of the ES6 features you must include the Babel
[polyfill](http://babeljs.io/docs/usage/polyfill/#usage-in-browser).

You don't always need this, review which features need the polyfill here: [ES6
Features](https://babeljs.io/docs/learn-es6).

```js
const esTranspiler = require('broccoli-babel-transpiler');
let scriptTree = esTranspiler(inputTree, { browserPolyfill: true });
```

By default, the polyfill will appear as `./browser-polyfill.js` in the output
tree. You can specify a custom output path and filename by supplying a (relative)
filename in the `browserPolyfillPath` option:

```js
let scriptTree = esTranspiler(inputTree, {
browserPolyfill: true,
browserPolyfillPath: 'vendor/polyfill.js'
})
```

## Plugins

Use of custom plugins works similarly to `babel` itself. You would pass a
Expand Down
14 changes: 0 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ function Babel(inputTree, _options) {
options.persist = 'persist' in options ? options.persist : true;
options.async = true;

if (options.browserPolyfill) {
let polyfillPath = require.resolve('@babel/polyfill/package.json');
polyfillPath = path.join(path.dirname(polyfillPath), "dist");

let browserPolyfillPath = options.browserPolyfillPath || "browser-polyfill.js"
let polyfill = funnel(polyfillPath, {
files: ['polyfill.js'],
getDestinationPath: () => browserPolyfillPath
});
inputTree = mergeTrees([polyfill, inputTree]);
}
delete options.browserPolyfill;
delete options.browserPolyfillPath;

Filter.call(this, inputTree, options);

delete options.persist;
Expand Down
22 changes: 0 additions & 22 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,28 +629,6 @@ describe('filters files to transform', function() {
});
});

describe('consume broccoli-babel-transpiler options', function() {
it('enabled', function() {
let options = {
browserPolyfill: true
};

babel = new Babel('foo', options);
let code = babel.processString('path', 'relativePath');
expect(code).to.be.ok;
});

it('explicitly disabled', function() {
let options = {
browserPolyfill: false
};

babel = new Babel('foo', options);
let code = babel.processString('path', 'relativePath');
expect(code).to.be.ok;
});
});

describe('when options change', function() {
let originalHash, options, fakeConsole, consoleMessages;

Expand Down

0 comments on commit 8916e2d

Please sign in to comment.