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

feat: implement [data_blobs] #743

Merged
merged 1 commit into from
Mar 31, 2022
Merged

feat: implement [data_blobs] #743

merged 1 commit into from
Mar 31, 2022

Conversation

threepointone
Copy link
Contributor

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.

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-bot
Copy link

changeset-bot bot commented Mar 31, 2022

🦋 Changeset detected

Latest commit: cb2c1e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@github-actions
Copy link
Contributor

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 with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2072931544/npm-package-wrangler-743 dev path/to/script.js

Copy link
Contributor

@caass caass left a 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,
Copy link
Contributor

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",
Copy link
Contributor

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

Copy link
Contributor Author

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"
Copy link
Contributor Author

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") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay

@threepointone
Copy link
Contributor Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants