-
Notifications
You must be signed in to change notification settings - Fork 760
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
feat: implement [data_blobs]
#743
Conversation
This implements `[data_blobs]` support for service-worker workers, as well as enabling Data module support for service-worker workers. `data_blob` is a supported binding type, but we never implemented support for it in v1. This implements support, and utilises it for supporting Data modules in service worker format. Implementation wise, it's incredibly similar to how we implemented `text_blobs`, with relevant changes. Partial fix for #740, pending local mode support.
🦋 Changeset detectedLatest commit: cb2c1e3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2072931544/npm-package-wrangler-743 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/743/npm-package-wrangler-743 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2072931544/npm-package-wrangler-743 dev path/to/script.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
@@ -2559,7 +2572,7 @@ export default{ | |||
}, | |||
], | |||
}, | |||
// text_blobs, vars, and wasm_modules are fine because they're object literals, | |||
// text_blobs, vars, wasm_modules and data_blobs are fine because they're object literals, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when he updates inline comments 😍
formData.set( | ||
name, | ||
new File([readFileSync(filePath)], filePath, { | ||
type: "application/octet-stream", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one of the sexiest content-types imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐙
@@ -156,7 +176,12 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData { | |||
const name = module.name.replace(/[^a-zA-Z0-9_$]/g, "_"); | |||
metadataBindings.push({ | |||
name, | |||
type: module.type === "compiled-wasm" ? "wasm_module" : "text_blob", | |||
type: | |||
module.type === "compiled-wasm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should just make module.type have the same values as binding.type, so we don't have to do this kind of check when converting. Next PR.
@@ -218,18 +218,12 @@ export default function createModuleCollector(props: { | |||
build.onLoad( | |||
{ filter: globToRegExp(glob) }, | |||
async (args: esbuild.OnLoadArgs) => { | |||
if (rule.type === "Data") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay
I'm pretty confident in this PR since it was mostly mechanical, and I tested it as well as I could, so I'm going to merge this in. Thank you for the review @caass! |
This implements
[data_blobs]
support for service-worker workers, as well as enabling Data module support for service-worker workers.data_blob
is a supported binding type, but we never implemented support for it in v1. This implements support, and utilises it for supporting Data modules in service worker format. Implementation wise, it's incredibly similar to how we implementedtext_blobs
, with relevant changes.Partial fix for #740, pending local mode support.