Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image integration not working on Node 18+ #5871

Merged
merged 3 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-mirrors-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---

Fix the integration failing to work properly on Node 18+
3 changes: 1 addition & 2 deletions packages/integrations/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/integrations/image/src/utils/workerPool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* tslint-disable ban-types */
import { TransformStream } from 'web-streams-polyfill';
import { parentPort, Worker } from 'worker_threads';

function uuid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

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