Skip to content

Commit

Permalink
0.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Jan 23, 2022
1 parent 098d976 commit f6dd6a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@astropub/webapi",
"description": "Use Web APIs in Node",
"version": "0.10.3",
"version": "0.10.4",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -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"
},
Expand Down
14 changes: 11 additions & 3 deletions run/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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' ],
Expand Down Expand Up @@ -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
Expand All @@ -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` ],
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const fetch = (resource: string | URL | Request, init?: Partial<FetchInit
if (resourceURL.protocol.toLowerCase() === 'file:') {
return Promise.resolve(
new Response(
fs.createReadStream(resourceURL, { encoding: 'utf-8' })
fs.createReadStream(resourceURL)
)
)
} else {
Expand Down

0 comments on commit f6dd6a0

Please sign in to comment.