Skip to content

Commit

Permalink
feat(api): add support for new parameter: 'minify'. Setting this will…
Browse files Browse the repository at this point in the history
… apply minification to the polyfill bundle. Useful in production for minimal bundle size.

feat(api): add support for new parameter: 'sourcemap'. Setting this will generate and return a sourcemap as part of the polyfill bundle. Useful in development.
feat(api): the Polyfill bundle will be transformed to the newest flavor of JavaScript supported by the runtime, instead of always ES3. This results in smaller Polyfill bundles.
feat(Intl): add support for Intl.DisplayNames.
feat(Intl): add support for Intl.Locale.
  • Loading branch information
wessberg committed Oct 21, 2020
1 parent c105963 commit a08f08f
Show file tree
Hide file tree
Showing 34 changed files with 1,962 additions and 5,671 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: "Deploy"

on:
push:
branches:
- master
release:
types: ["published"]

Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ When a browser (or robot) visits your site, `Polyfiller` evaluates the user agen
It is up to you to decide which polyfills you need, but the web service will automatically make sure to include every dependency of those polyfills, but only if the browser doesn't already support them.
See [this](#usage-in-a-web-workerservice-worker) or [this](#usage-in-node) section for details on how to use `Polyfiller` from Web Workers/ServiceWorkers and Node.

You can provide options to Polyfiller via query parameters such as `minify` and `sourcemap` to adjust the received payload to your liking.

## Examples

### Example 1:
Expand All @@ -181,9 +183,10 @@ In this example:
- `es` polyfills those EcmaScript features that the browser doesn't support.
- `intersection-observer` is polyfilled, _even if the browser supports it_, because it has the `force` option.
- `intl` is polyfilled, with the inclusion of `Intl.ListFormat` and `Intl.RelativeTimeFormat`, if the browser doesn't support it, and the `en` locale data is included.
- Sourcemaps are generated, and the bundle is minified

```html
<script crossorigin src="https://polyfill.app/api/polyfill?features=es,intersection-observer|force,intl|locale=en"></script>
<script crossorigin src="https://polyfill.app/api/polyfill?minify&sourcemap&features=es,intersection-observer|force,intl|locale=en"></script>
```

### Example 2:
Expand Down Expand Up @@ -225,10 +228,12 @@ Retrieves a bundle of polyfills.

#### Parameter overview

| Parameter | Description |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `features` | A comma-separated string of all the `feature`s you want to include in your bundle (if required by the browser). Each `feature` may receive zero or more `option`s. Some `option`s are supported for all `feature`s while others only support specific `feature`s. |
| `context` | Can be either `window`, `worker`, or `node`. Use this to instruct `Polyfiller` to optimize polyfills for the given environment, as well as to exclude polyfills that doesn't support the given context. |
| Parameter | Description |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `features` | A comma-separated string of all the `feature`s you want to include in your bundle (if required by the browser). Each `feature` may receive zero or more `option`s. Some `option`s are supported for all `feature`s while others only support specific `feature`s. |
| `context` | Can be either `window`, `worker`, or `node`. Use this to instruct `Polyfiller` to optimize polyfills for the given environment, as well as to exclude polyfills that doesn't support the given context. |
| `sourcemap` | If given, or if it has a value of `true`, `Polyfiller` will be instructed to generate SourceMaps. Use this in development for better stack traces. |
| `minify` | If given, `Polyfiller` will send back a minified Polyfill bundle. |

#### `feature`

Expand Down Expand Up @@ -708,8 +713,13 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `dom.collections.iterator`
- `dom.collections.for-each`
- **`intl`**
- `intl.core`
- `intl.date-time-format`
- `intl.display-names`
- `intl.get-canonical-locales`
- `intl.list-format`
- `intl.locale`
- `intl.number-format`
- `intl.plural-rules`
- `intl.relative-time-format`
- **`animation`**
- `web-animations`
Expand Down
Loading

0 comments on commit a08f08f

Please sign in to comment.