Use native built in FormData instead of using any other dependency and use built in fetch to send it instead.
|
import FormData from 'form-data'; |
|
const form = new FormData(); |
|
const lineBreak = '\r\n'; |
|
form.setBoundary('0f411892-ef48-488f-89d3-4f0546e84723'); |
|
form.append('vsix', packageStream, { |
|
header: `--${form.getBoundary()}${lineBreak}Content-Disposition: attachment; name=vsix; filename=\"${packageName}\"${lineBreak}Content-Type: application/octet-stream${lineBreak}${lineBreak}` |
|
}); |
|
form.append('sigzip', sigzipStream, { |
|
header: `--${form.getBoundary()}${lineBreak}Content-Disposition: attachment; name=sigzip; filename=\"${sigzipName}\"${lineBreak}Content-Type: application/octet-stream${lineBreak}${lineBreak}` |
|
}); |
|
|
|
const publishWithRetry = retry(handleWhen(err => err.message.includes('timeout')), { |
|
maxAttempts: 3, |
|
backoff: new IterableBackoff([5_000, 10_000, 20_000]) |
|
}); |
|
|
|
return await publishWithRetry.execute(async () => { |
|
return await api.publishExtensionWithPublisherSignature(undefined, form, manifest.publisher, manifest.name, extensionType); |
|
}); |
the only way to get a blob in nodejs and append it to a formdata is if you use fs.openAsBlob
import { openAsBlob } from 'node:fs';
const blob = await openAsBlob(path, { type: 'application/octet-stream' })
formData.append('vsix', blob, packageName)
fetch(...)
ever since ljharb took over form-data pkg, it only got more sub dependencies and increased size
the other alternative is to construct a own Blob/File yourself
Use native built in FormData instead of using any other dependency and use built in fetch to send it instead.
vscode-vsce/src/publish.ts
Line 13 in 2aeafb2
vscode-vsce/src/publish.ts
Lines 280 to 297 in 2aeafb2
vscode-vsce/package.json
Line 53 in 2aeafb2
the only way to get a blob in nodejs and append it to a formdata is if you use fs.openAsBlob
ever since ljharb took over form-data pkg, it only got more sub dependencies and increased size
the other alternative is to construct a own Blob/File yourself