Skip to content

Commit

Permalink
feat(FormData): add FormData polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Mar 8, 2021
1 parent c5c2f72 commit c25ff7e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ And, if you request `performance.now`, `date.now` will also be included since th

**Bold**-formatted polyfills are _aliases_ for one or several other related `feature`s.

- **`formdata`**
- `form-data`
- **`requestidlecallback`**
- `request-idle-callback`
- **`requestanimationframe`**
Expand All @@ -406,6 +408,8 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `es`
- **`es.promise`**
- `es.promise.constructor`
- `es.promise.any`
- `es.promise.all-settled`
- `es.promise.finally`
- **`es.object`**
- `es.object.assign`
Expand Down Expand Up @@ -497,6 +501,7 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `es.string.trim`
- `es.string.trim-start`
- `es.string.trim-end`
- `es.string.replace-all`
- **`es.regexp`**
- `es.regexp.constructor`
- `es.regexp.flags`
Expand Down Expand Up @@ -553,6 +558,7 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `es.symbol.to-primitive`
- `es.symbol.to-string-tag`
- `es.symbol.unscopables`
- `es.symbol.description`
- **`es.collections`**
- `es.map`
- `es.weak-map`
Expand Down Expand Up @@ -687,8 +693,6 @@ And, if you request `performance.now`, `date.now` will also be included since th
- **`esnext.number`**
- `es.number.from-string`
- **`esnext.promise`**
- `es.promise.all-settled`
- `es.promise.try`
- `es.promise.try`
- **`esnext.reflect`**
- `es.reflect.define-metadata`
Expand All @@ -704,9 +708,7 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `es.string.at`
- `es.string.code-points`
- `es.string.match-all`
- `es.string.replace-all`
- **`esnext.symbol`**
- `es.symbol.description`
- `es.symbol.pattern-match`
- **`dom.collections.iterable`**
- `dom.collections.iterator`
Expand Down Expand Up @@ -745,7 +747,6 @@ And, if you request `performance.now`, `date.now` will also be included since th
- `base64`
- `blob`
- `proxy`
- `es.promise.any`
- `es.string.replace`
- `pointer-event`
- `xhr`
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
"xhr-polyfill": "0.1.8",
"focus-visible": "5.2.0",
"zone.js": "0.11.3",
"pm2": "4.5.0"
"pm2": "4.5.0",
"formdata-polyfill": "3.0.20"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
13 changes: 12 additions & 1 deletion src/constant/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {IConstant} from "./i-constant";
import {environment} from "../environment/environment";
import tempDirectory from "temp-dir";
import {join} from "path";
import {ALL_CONTEXTS, WINDOW_CONTEXT, WINDOW_NODE_CONTEXT} from "../polyfill/polyfill-context";
import {ALL_CONTEXTS, WINDOW_CONTEXT, WINDOW_NODE_CONTEXT, WINDOW_WORKER_CONTEXT} from "../polyfill/polyfill-context";
import {booleanize} from "../util/booleanize/booleanize";

const tempRoot = join(
Expand Down Expand Up @@ -153,6 +153,17 @@ export const constant: IConstant = {
dependencies: ["base64", "url"],
contexts: ALL_CONTEXTS
},
formdata: {
polyfills: ["form-data"]
},
"form-data": {
library: "formdata-polyfill",
relativePaths: ["FormData.js"],
features: ["api.FormData", "api.FormData.get"],
version: environment.NPM_PACKAGE_DEPENDENCIES_FORMDATA_POLYFILL,
dependencies: ["base64", "url"],
contexts: WINDOW_WORKER_CONTEXT
},
requestidlecallback: {
polyfills: ["request-idle-callback"]
},
Expand Down
1 change: 1 addition & 0 deletions src/environment/environment-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const environmentDefaults = {
NPM_PACKAGE_DEPENDENCIES_PROXY_POLYFILL: "",
NPM_PACKAGE_DEPENDENCIES_PERFNOW: "",
NPM_PACKAGE_DEPENDENCIES_BLOB_POLYFILL: "",
NPM_PACKAGE_DEPENDENCIES_FORMDATA_POLYFILL: "",
NPM_PACKAGE_DEPENDENCIES_REQUESTANIMATIONFRAME: "",
NPM_PACKAGE_DEPENDENCIES_REQUESTIDLECALLBACK: "",
NPM_PACKAGE_DEPENDENCIES_URL_POLYFILL: "",
Expand Down
2 changes: 2 additions & 0 deletions src/polyfill/polyfill-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export declare type PolyfillName =
| "requestidlecallback"
| "setimmediate"
| "globalthis"
| "formdata"
| "adopted-style-sheets";

export declare type PolyfillDealiasedName =
Expand Down Expand Up @@ -357,6 +358,7 @@ export declare type PolyfillDealiasedName =
| "web-animations"
| "global-this"
| "broadcast-channel"
| "form-data"
| "constructable-style-sheets"
| "proto"
| "focus-visible";

0 comments on commit c25ff7e

Please sign in to comment.