Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove browserPolyfill option #191

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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