diff --git a/package.json b/package.json index 7e15762..a3d56ba 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@astropub/webapi", "description": "Use Web APIs in Node", - "version": "0.10.3", + "version": "0.10.4", "type": "module", "exports": { ".": { @@ -42,17 +42,17 @@ "bugs": "https://github.com/astro-community/webapi/issues", "homepage": "https://github.com/astro-community/webapi#readme", "devDependencies": { - "@rollup/plugin-alias": "^3.1.8", - "@rollup/plugin-inject": "^4.0.3", - "@rollup/plugin-node-resolve": "^13.1.1", + "@rollup/plugin-alias": "^3.1.9", + "@rollup/plugin-inject": "^4.0.4", + "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-typescript": "^8.3.0", "abort-controller": "^3.0.0", "event-target-shim": "^6.0.2", - "fetch-blob": "^3.1.3", + "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10", "magic-string": "^0.25.7", - "node-fetch": "^3.1.0", - "rollup": "^2.61.1", + "node-fetch": "^3.2.0", + "rollup": "^2.66.0", "rollup-plugin-terser": "^7.0.2", "web-streams-polyfill": "^3.2.0" }, diff --git a/run/build.js b/run/build.js index 87f8e80..eb988d4 100644 --- a/run/build.js +++ b/run/build.js @@ -23,6 +23,7 @@ const plugins = [ { find: 'event-target-shim', replacement: pathToEventTargetShim }, { find: 'event-target-shim/dist/event-target-shim.js', replacement: pathToEventTargetShim }, { find: 'event-target-shim/dist/event-target-shim.umd.js', replacement: pathToEventTargetShim }, + { find: 'node-domexception', replacement: pathToDOMException }, ], }), nodeResolve({ @@ -32,6 +33,9 @@ const plugins = [ ] }), inject({ + // import { Promise as P } from 'es6-promise' + // P: [ 'es6-promise', 'Promise' ], + 'AbortController': [ 'abort-controller/dist/abort-controller.mjs', 'AbortController' ], 'DOMException': [pathToDOMException, 'DOMException'], 'Document': [ './Document', 'Document' ], @@ -60,7 +64,7 @@ const plugins = [ const replacements = [ // remove unused imports - [ /(^|\n)import\s+[^']+'node:(fs|path|worker_threads)'/g, `` ], + [ /(^|\n)import\s+[^']+'node:(buffer|fs|path|worker_threads)'/g, `` ], [ /const \{ stat \} = fs/g, `` ], // remove unused polyfill utils @@ -76,6 +80,7 @@ const plugins = [ [ /\nconst SymbolPolyfill\s*=[^;]+;/g, '\nconst SymbolPolyfill = Symbol;'], [ /\n(const|let) DOMException[^;]*;/g, `let DOMException$1=DOMException` ], [ /\nconst DOMException = globalThis.DOMException[\W\w]+?\}\)\(\)/g, `` ], + [ /\nimport DOMException from 'node-domexception'/g, `` ], // use shared AbortController methods [ / new DOMException\$1/g, `new DOMException` ], @@ -84,8 +89,11 @@ const plugins = [ [ /= createAbortController/g, `= new AbortController` ], [ /\nconst queueMicrotask = [\W\w]+?\n\}\)\(\)\;/g, `` ], - // patch node-fetch to use `arrayBuffer` instead of `buffer` - [ /this\.buffer/g, `this.arrayBuffer` ], + // remove Body.prototype.buffer deprecation notice + [ /\nBody\.prototype\.buffer[^\n]+/g, `` ], + + // remove Body.prototype.data deprecation notice + [ /\n data: \{get: deprecate[\W\w]+?\)\}/g, `` ] ] for (const [replacee, replacer] of replacements) { diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index fe3a951..aebb919 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -15,7 +15,7 @@ export const fetch = (resource: string | URL | Request, init?: Partial