Fix image integration not working on Node 18+ (#5871)

* fix(image): Remove unnecessary polyfill now that we dropped Node 14

* fix(squoosh): Remove fetch of local wasm binary since undici doesn't support that

* chore: changeset
This commit is contained in:
Erika 2023-01-17 15:48:06 +01:00 committed by GitHub
parent 998f412c57
commit 1bd42c6b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 12 additions and 215 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---
Fix the integration failing to work properly on Node 18+

View file

@ -48,8 +48,7 @@
"kleur": "^4.1.5",
"magic-string": "^0.25.9",
"mime": "^3.0.0",
"slash": "^4.0.0",
"web-streams-polyfill": "^3.2.1"
"slash": "^4.0.0"
},
"devDependencies": {
"@types/http-cache-semantics": "^4.0.1",

View file

@ -1,5 +1,4 @@
/* tslint-disable ban-types */
import { TransformStream } from 'web-streams-polyfill';
import { parentPort, Worker } from 'worker_threads';
function uuid() {

View file

@ -384,22 +384,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -431,25 +415,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -384,22 +384,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -431,25 +415,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -391,22 +391,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -438,25 +422,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -391,22 +391,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -438,25 +422,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -367,22 +367,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -414,25 +398,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -367,22 +367,6 @@ var Module = (function () {
}
}
function getBinaryPromise() {
if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) {
if (typeof fetch === 'function') {
return fetch(wasmBinaryFile, { credentials: 'same-origin' })
.then(function (response) {
if (!response['ok']) {
throw (
"failed to load wasm binary file at '" + wasmBinaryFile + "'"
)
}
return response['arrayBuffer']()
})
.catch(function () {
return getBinary(wasmBinaryFile)
})
}
}
return Promise.resolve().then(function () {
return getBinary(wasmBinaryFile)
})
@ -414,25 +398,7 @@ var Module = (function () {
})
}
function instantiateAsync() {
if (
!wasmBinary &&
typeof WebAssembly.instantiateStreaming === 'function' &&
!isDataURI(wasmBinaryFile) &&
typeof fetch === 'function'
) {
return fetch(wasmBinaryFile, { credentials: 'same-origin' }).then(
function (response) {
var result = WebAssembly.instantiateStreaming(response, info)
return result.then(receiveInstantiationResult, function (reason) {
err('wasm streaming compile failed: ' + reason)
err('falling back to ArrayBuffer instantiation')
return instantiateArrayBuffer(receiveInstantiationResult)
})
}
)
} else {
return instantiateArrayBuffer(receiveInstantiationResult)
}
return instantiateArrayBuffer(receiveInstantiationResult)
}
if (Module['instantiateWasm']) {
try {

View file

@ -2694,7 +2694,6 @@ importers:
sharp: ^0.31.0
slash: ^4.0.0
vite: ^4.0.3
web-streams-polyfill: ^3.2.1
dependencies:
'@altano/tiny-async-pool': 1.0.2
http-cache-semantics: 4.1.0
@ -2703,7 +2702,6 @@ importers:
magic-string: 0.25.9
mime: 3.0.0
slash: 4.0.0
web-streams-polyfill: 3.2.1
devDependencies:
'@types/http-cache-semantics': 4.0.1
'@types/mime': 2.0.3