# @qiwi/create-polyfill-service-url

> Analyse your JavaScript file and generate a polyfill.io URL based on all the features that are being used from within the JavaScript file.

Latest version **2.0.7** (published 2022-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @qiwi/create-polyfill-service-url
pnpm add @qiwi/create-polyfill-service-url
yarn add @qiwi/create-polyfill-service-url
bun add @qiwi/create-polyfill-service-url
```

Provides the command `create-polyfill-service-url`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2022-10-19 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 19.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jake Champion |
| Maintainers | antongolub, qiwibot, pismenskiy |

## Links

- npm: https://www.npmjs.com/package/@qiwi/create-polyfill-service-url
- Repository: https://github.com/qiwi-forks/polyfill-service-url-builder
- Homepage: https://github.com/qiwi-forks/polyfill-service-url-builder#readme
- Issues: https://github.com/qiwi-forks/polyfill-service-url-builder/issues
- npm.io page: https://npm.io/package/@qiwi/create-polyfill-service-url

## Dependencies (8)

- [snyk](https://npm.io/package/snyk.md) ^1.752.0
- [execa](https://npm.io/package/execa.md) ^4.0.0
- [yargs](https://npm.io/package/yargs.md) ^15.1.0
- [semver](https://npm.io/package/semver.md) ^7.1.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.16.0
- [browserslist](https://npm.io/package/browserslist.md) ^4.17.6
- [polyfill-library](https://npm.io/package/polyfill-library.md) ^3.108.0
- [@financial-times/js-features-analyser](https://npm.io/package/@financial-times/js-features-analyser.md) 0.0.4

## Recent versions

- 2.0.7 (latest) — 2022-10-19
- 2.0.6 — 2022-10-14
- 2.0.5 — 2022-10-11

## README

# @qiwi/polyfill-service-url-builder
> [Financial-Times/polyfill-service-url-builder](https://github.com/Financial-Times/polyfill-service-url-builder) fork to bring [pull/283](https://github.com/Financial-Times/polyfill-service-url-builder/pull/283) changes

## Usage
### CLI
This project requires [Node.js] 10.x and [npm]. You can run it with:

```bash
> npx create-polyfill-service-url analyse --file bundle.js [--cwd "/custom/pwd" --omit "Array.prototype.includes" --hostname "polyfill.io"]
```
You can pass multiple files as argument if you split your bundle files:
```bash
npx create-polyfill-service-url analyse --file app.js vendor.js
```

| Option                        | Description                                                                                                 | Default         |
|-------------------------------|-------------------------------------------------------------------------------------------------------------|-----------------|
| --file                        | The path to the JavaScript file(s) to analyse                                                               |                 |
| --cwd                         | The current working directory                                                                               | `process.cwd()` |
| --omit                        | A list of features to omit. Example: `Array.prototype.map`                                                  |                 |
| --hostname                    | The hostname of the polyfill service to use.                                                                | `polyfill.io`   |
| --use-compute-at-edge-backend | Defines the compute-at-edge-backend usage policy: `yes` or `no`. If empty the server will decide.           |                 |
| --flags                       | Configuration settings for every polyfill being requested. Possible values are `always` and `gated` or both |                 |
| --unknown                     | Defines the policy for unsupported browsers: `polyfill` or `ignore`                                         | `polyfill`      |

### JS API
```js
const analyze = require('create-polyfill-service-url');

const result = await analyze({
  file: ['bundle.js'],
  cwd: '/foo/bar',                    // Defaults to process.cwd()
  omit: ['Array.prototype.includes'], // Defaults to []
  hostname: 'example.com',            // Defaults to 'polyfill.io'
  unknown: 'polyfill',                // Defaults to null. Accepts 'polyfill' or 'ignore'
  useComputeAtEdgeBackend: 'yes',     // Defaults to null. Accepts 'yes' or 'no'
  flags: 'gated',                     // Defaults to null. Accepts 'always', 'gated' or both ['always', 'gated']
});
```

## Diff
* introduce `omit` option to suppress false-positive matches in case some custom polyfill is already present in the bundle or provided another way.
* add `cwd` option to avoid `cd` (monorepo build case)
* provide `hostname` customization
* introduce flags, `useComputeAtEdgeBackend` and `unknown` options
* expose `analyse` JS API
* add some tests for the CLI

## Licence

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

[issues]: https://github.com/Financial-Times/polyfill-service-url-builder/issues
[node.js]: https://nodejs.org/
[npm]: https://www.npmjs.com/

---
_Source: https://npm.io/package/@qiwi/create-polyfill-service-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
