Use undici's FormData for polyfilling (#6413)

* fix(webapi): Use undici's FormData instead of a polyfill

* chore: changeset
This commit is contained in:
Erika 2023-03-03 14:47:24 +01:00 committed by GitHub
parent 13f6f591e3
commit 0abd1d3e42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 25 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/webapi': patch
---
Use undici's FormData instead of a polyfill

View file

@ -25,5 +25,3 @@ THE SOFTWARE.
Code from [@astrocommunity/webapi](https://www.npmjs.com/@astrocommunity/webapi) is licensed under the CC0-1.0 License. Code from [@astrocommunity/webapi](https://www.npmjs.com/@astrocommunity/webapi) is licensed under the CC0-1.0 License.
Code from [event-target-shim](https://www.npmjs.com/package/event-target-shim) is licensed under the MIT License (MIT), Copyright Toru Nagashima. Code from [event-target-shim](https://www.npmjs.com/package/event-target-shim) is licensed under the MIT License (MIT), Copyright Toru Nagashima.
Code from [formdata-polyfill](https://www.npmjs.com/package/formdata-polyfill) is licensed under the MIT License (MIT), Copyright Jimmy Wärting.

View file

@ -155,5 +155,3 @@ polyfill(globalThis, {
Thank you to Jon Neal for his work on the original [webapi](https://github.com/astro-community/webapi) project that this package is forked from. Licensed under the CC0-1.0 License. Thank you to Jon Neal for his work on the original [webapi](https://github.com/astro-community/webapi) project that this package is forked from. Licensed under the CC0-1.0 License.
Code from [event-target-shim](https://www.npmjs.com/package/event-target-shim) is licensed under the MIT License (MIT), Copyright Toru Nagashima. Code from [event-target-shim](https://www.npmjs.com/package/event-target-shim) is licensed under the MIT License (MIT), Copyright Toru Nagashima.
Code from [formdata-polyfill](https://www.npmjs.com/package/formdata-polyfill) is licensed under the MIT License (MIT), Copyright Jimmy Wärting.

View file

@ -1,13 +1,13 @@
// organize-imports-ignore // organize-imports-ignore
export { pathToPosix } from './lib/utils'; export { pathToPosix } from './lib/utils';
export { alert, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js'; export { alert, ByteLengthQueuingStrategy, cancelAnimationFrame, cancelIdleCallback, CanvasRenderingContext2D, CharacterData, clearTimeout, Comment, CountQueuingStrategy, CSSStyleSheet, CustomElementRegistry, CustomEvent, Document, DocumentFragment, DOMException, Element, Event, EventTarget, fetch, File, FormData, Headers, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLDocument, HTMLElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLSpanElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image, ImageData, IntersectionObserver, MediaQueryList, MutationObserver, Node, NodeFilter, NodeIterator, OffscreenCanvas, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, requestAnimationFrame, requestIdleCallback, ResizeObserver, Response, setTimeout, ShadowRoot, structuredClone, StyleSheet, Text, TransformStream, TreeWalker, URLPattern, Window, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, } from './mod.js';
export declare const polyfill: { export declare const polyfill: {
(target: any, options?: PolyfillOptions): any; (target: any, options?: PolyfillOptions): any;
internals(target: any, name: string): any; internals(target: any, name: string): any;
}; };
interface PolyfillOptions { interface PolyfillOptions {
exclude?: string | string[]; exclude?: string | string[];
override?: Record<string, { override?: Record<string, {
(...args: any[]): any; (...args: any[]): any;
}>; }>;
} }

View file

@ -63,7 +63,6 @@
"@ungap/structured-clone": "^0.3.4", "@ungap/structured-clone": "^0.3.4",
"chai": "^4.3.6", "chai": "^4.3.6",
"event-target-shim": "^6.0.2", "event-target-shim": "^6.0.2",
"formdata-polyfill": "^4.0.10",
"magic-string": "^0.27.0", "magic-string": "^0.27.0",
"mocha": "^9.2.2", "mocha": "^9.2.2",
"rollup": "^2.79.1", "rollup": "^2.79.1",

View file

@ -1,6 +1,5 @@
// @ts-check // @ts-check
import { Event, EventTarget } from 'event-target-shim' import { Event, EventTarget } from 'event-target-shim' // Look into removing when Node 18 is dropped for Node 20
import { FormData } from 'formdata-polyfill/esm.min.js'
import { import {
ByteLengthQueuingStrategy, ByteLengthQueuingStrategy,
CountQueuingStrategy, CountQueuingStrategy,
@ -14,18 +13,18 @@ import {
WritableStream, WritableStream,
WritableStreamDefaultController, WritableStreamDefaultController,
WritableStreamDefaultWriter, WritableStreamDefaultWriter,
} from 'node:stream/web' } from 'node:stream/web' // Remove when Node 16 is dropped for Node 18.
import { fetch, File, Headers, Request, Response } from 'undici' import { fetch, File, FormData, Headers, Request, Response } from 'undici' // Remove when Node 16 is dropped for Node 18.
import { URLPattern } from 'urlpattern-polyfill' import { URLPattern } from 'urlpattern-polyfill'
import { import {
cancelAnimationFrame, cancelAnimationFrame,
requestAnimationFrame, requestAnimationFrame,
} from './lib/AnimationFrame' } from './lib/AnimationFrame'
import { CharacterData, Comment, Text } from './lib/CharacterData' import { CharacterData, Comment, Text } from './lib/CharacterData'
import { CustomEvent } from './lib/CustomEvent' import { CustomEvent } from './lib/CustomEvent' // Look into removing when Node 18 is dropped for Node 20
import { DOMException } from './lib/DOMException' import { DOMException } from './lib/DOMException'
import { cancelIdleCallback, requestIdleCallback } from './lib/IdleCallback' import { cancelIdleCallback, requestIdleCallback } from './lib/IdleCallback'
import structuredClone from './lib/structuredClone' import structuredClone from './lib/structuredClone' // Remove when Node 16 is dropped for Node 18.
import { clearTimeout, setTimeout } from './lib/Timeout' import { clearTimeout, setTimeout } from './lib/Timeout'
import { TreeWalker } from './lib/TreeWalker' import { TreeWalker } from './lib/TreeWalker'

5
pnpm-lock.yaml generated
View file

@ -3694,7 +3694,6 @@ importers:
'@ungap/structured-clone': ^0.3.4 '@ungap/structured-clone': ^0.3.4
chai: ^4.3.6 chai: ^4.3.6
event-target-shim: ^6.0.2 event-target-shim: ^6.0.2
formdata-polyfill: ^4.0.10
magic-string: ^0.27.0 magic-string: ^0.27.0
mocha: ^9.2.2 mocha: ^9.2.2
rollup: ^2.79.1 rollup: ^2.79.1
@ -3715,7 +3714,6 @@ importers:
'@ungap/structured-clone': 0.3.4 '@ungap/structured-clone': 0.3.4
chai: 4.3.7 chai: 4.3.7
event-target-shim: 6.0.2 event-target-shim: 6.0.2
formdata-polyfill: 4.0.10
magic-string: 0.27.0 magic-string: 0.27.0
mocha: 9.2.2 mocha: 9.2.2
rollup: 2.79.1 rollup: 2.79.1
@ -10032,6 +10030,7 @@ packages:
dependencies: dependencies:
node-domexception: 1.0.0 node-domexception: 1.0.0
web-streams-polyfill: 3.2.1 web-streams-polyfill: 3.2.1
dev: false
/file-entry-cache/6.0.1: /file-entry-cache/6.0.1:
resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==}
@ -10144,6 +10143,7 @@ packages:
engines: {node: '>=12.20.0'} engines: {node: '>=12.20.0'}
dependencies: dependencies:
fetch-blob: 3.2.0 fetch-blob: 3.2.0
dev: false
/fraction.js/4.2.0: /fraction.js/4.2.0:
resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==} resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==}
@ -12380,6 +12380,7 @@ packages:
/node-domexception/1.0.0: /node-domexception/1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'} engines: {node: '>=10.5.0'}
dev: false
/node-fetch-native/1.0.1: /node-fetch-native/1.0.1:
resolution: {integrity: sha512-VzW+TAk2wE4X9maiKMlT+GsPU4OMmR1U9CrHSmd3DFLn2IcZ9VJ6M6BBugGfYUnPCLSYxXdZy17M0BEJyhUTwg==} resolution: {integrity: sha512-VzW+TAk2wE4X9maiKMlT+GsPU4OMmR1U9CrHSmd3DFLn2IcZ9VJ6M6BBugGfYUnPCLSYxXdZy17M0BEJyhUTwg==}